forked from 2010yhh/springBoot-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:利用git上比较好的paheHelper增加mybatis分页;增加前端测试代码
- Loading branch information
Showing
158 changed files
with
24,656 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
springboot-static/src/main/java/com/ctg/test/Async/AsyncTaskService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.ctg.test.Async; | ||
|
||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* @Description: TODO | ||
* @Author: yanhonghai | ||
* @Date: 2018/11/8 18:32 | ||
*/ | ||
@Service | ||
public class AsyncTaskService { | ||
@Async | ||
void execute(int i){ | ||
System.out.print("线程ID"+Thread.currentThread().getId()+"执行序号:"+i+"\n"); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
springboot-static/src/main/java/com/ctg/test/Async/TaskExecutorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.ctg.test.Async; | ||
|
||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.AsyncConfigurer; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* @Description: TODO | ||
* @Author: yanhonghai | ||
* @Date: 2018/11/8 18:35 | ||
*/ | ||
@Configuration | ||
@EnableAsync | ||
@Component | ||
public class TaskExecutorConfig implements AsyncConfigurer { | ||
@Override | ||
public Executor getAsyncExecutor() { | ||
ThreadPoolTaskExecutor threadPoolTaskExecutor=new ThreadPoolTaskExecutor(); | ||
threadPoolTaskExecutor.setCorePoolSize(10); | ||
threadPoolTaskExecutor.setMaxPoolSize(15); | ||
threadPoolTaskExecutor.setQueueCapacity(10); | ||
threadPoolTaskExecutor.initialize(); | ||
return threadPoolTaskExecutor; | ||
} | ||
|
||
@Override | ||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { | ||
return null; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
springboot-static/src/main/java/com/ctg/test/Async/TestMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ctg.test.Async; | ||
|
||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
|
||
/** | ||
* @Description: TODO | ||
* @Author: yanhonghai | ||
* @Date: 2018/11/8 18:38 | ||
*/ | ||
public class TestMain { | ||
public static void main(String[] args) { | ||
AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext(AsyncTaskService.class); | ||
AsyncTaskService asyncTaskService=context.getBean(AsyncTaskService.class); | ||
for(int i=0;i<10;i++){ | ||
asyncTaskService.execute(i); | ||
} | ||
context.close(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
springboot-static/src/main/java/com/ctg/test/Configure/XmlConfigure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ctg.test.Configure; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.ImportResource; | ||
|
||
/** | ||
* @Description: | ||
* @Configuration可理解为用spring的时候xml里面的<beans>标签 | ||
* @Bean可理解为用spring的时候xml里面的<bean>标签 | ||
* @Author: yanhonghai | ||
* @Date: 2018/9/28 11:50 | ||
*/ | ||
@Configuration | ||
@ImportResource(locations= {"classpath:application-bean.xml"}) | ||
public class XmlConfigure { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
springboot-static/src/main/java/com/ctg/test/controller/IndexController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.ctg.test.controller; | ||
|
||
import com.ctg.test.model.User; | ||
import com.ctg.test.service.UserService; | ||
import com.ctg.test.util.DefaultProperies; | ||
import com.ctg.test.util.DefaultProperies2; | ||
import com.ctg.test.util.DefaultProperies3; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.util.CollectionUtils; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
*http://localhost:8090/login?userName=yhh&passWord=yhh | ||
*/ | ||
@Controller | ||
@EnableAutoConfiguration | ||
public class IndexController { | ||
@Autowired | ||
UserService userService; | ||
@RequestMapping(value = {"/login"}) | ||
@ResponseBody | ||
public Object login(@RequestParam String userName, @RequestParam String passWord, | ||
HttpServletRequest request, HttpServletResponse response) { | ||
Map<String,Object> result=new HashMap<>(); | ||
List<User>users=userService.findByUserName(userName,passWord); | ||
if(!CollectionUtils.isEmpty(users)){ | ||
result.put("code","200"); | ||
result.put("msg","success"); | ||
result.put("user",users); | ||
}else | ||
{ | ||
result.put("code","-1"); | ||
result.put("msg","error!"); | ||
} | ||
return result; | ||
} | ||
@RequestMapping("/logout") | ||
public String logout() { | ||
return "logout"; | ||
} | ||
@RequestMapping("/index2") | ||
String index2(HttpServletRequest request) { | ||
// 逻辑处理 | ||
request.setAttribute("key", "index"); | ||
return "/index2"; | ||
} | ||
@RequestMapping("/") | ||
String index(HttpServletRequest request) { | ||
return "/index"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
springboot-static/src/main/java/com/ctg/test/controller/TestPropertyController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.ctg.test.controller; | ||
|
||
import com.ctg.test.model.User; | ||
import com.ctg.test.service.UserService; | ||
import com.ctg.test.util.DefaultProperies; | ||
import com.ctg.test.util.DefaultProperies2; | ||
import com.ctg.test.util.DefaultProperies3; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
*http://localhost:8090/test | ||
*/ | ||
@Controller | ||
@EnableAutoConfiguration | ||
public class TestPropertyController { | ||
@Autowired | ||
UserService userService; | ||
@Autowired | ||
DefaultProperies defaultProperies; | ||
@Autowired | ||
DefaultProperies2 defaultProperies2; | ||
@Autowired | ||
private Environment env; | ||
@RequestMapping(value = {"/test"}) | ||
@ResponseBody | ||
public Object test( | ||
HttpServletRequest request, HttpServletResponse response) { | ||
Map<String,Object> result=new HashMap<>(); | ||
result.put("DefaultProperies",defaultProperies); | ||
result.put("DefaultProperies2",defaultProperies2); | ||
DefaultProperies3 defaultProperies3=new DefaultProperies3(); | ||
defaultProperies3.setUserName(env.getProperty("default.userName")); | ||
defaultProperies3.setPassWord(env.getProperty("default.passWord")); | ||
result.put("DefaultProperies3",defaultProperies3); | ||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.