作者 朱兆平

卡口用户登录验证OK

正在显示 31 个修改的文件 包含 786 行增加591 行删除
@@ -23,7 +23,7 @@ spring: @@ -23,7 +23,7 @@ spring:
23 static-locations: classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,file:${web.upload-path} 23 static-locations: classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,file:${web.upload-path}
24 24
25 application: 25 application:
26 - name: cloud-user-center 26 + name: cloud-kako-user-center
27 redis: 27 redis:
28 # host: 127.0.0.1 28 # host: 127.0.0.1
29 host: 192.168.1.53 29 host: 192.168.1.53
@@ -57,7 +57,7 @@ spring: @@ -57,7 +57,7 @@ spring:
57 #username=CGOETL 57 #username=CGOETL
58 #password=1q2w3e4r 58 #password=1q2w3e4r
59 #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 59 #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码
60 - url: jdbc:mysql://118.31.66.166:3306/statistics?useUnicode=true&characterEncoding=utf8 60 + url: jdbc:mysql://118.31.66.166:3306/station?useUnicode=true&characterEncoding=utf8
61 username: 110 61 username: 110
62 password: QAHqCJf2kFYCLirM 62 password: QAHqCJf2kFYCLirM
63 driver-class-name: com.mysql.cj.jdbc.Driver 63 driver-class-name: com.mysql.cj.jdbc.Driver
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true --> 4 <!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
5 <!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 --> 5 <!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
6 <!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 --> 6 <!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
7 -<configuration scan="true" scanPeriod="10 seconds"> 7 +<configuration scan="true" scanPeriod="60 seconds">
8 8
9 <!--<include resource="org/springframework/boot/logging/logback/base.xml" />--> 9 <!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
10 10
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> 25 <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
26 <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> 26 <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
27 <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> 27 <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
28 - <level>info</level> 28 + <level>debug</level>
29 </filter> 29 </filter>
30 <encoder> 30 <encoder>
31 <Pattern>${CONSOLE_LOG_PATTERN}</Pattern> 31 <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
@@ -169,7 +169,7 @@ @@ -169,7 +169,7 @@
169 不能设置为INHERITED或者同义词NULL。默认是DEBUG 169 不能设置为INHERITED或者同义词NULL。默认是DEBUG
170 可以包含零个或多个元素,标识这个appender将会添加到这个logger。 170 可以包含零个或多个元素,标识这个appender将会添加到这个logger。
171 --> 171 -->
172 - <logger name="com.tianbo.warehouse.dao" level="info" /> 172 + <logger name="com.tianbo.warehouse.dao" level="debug" />
173 <!--开发环境:打印控制台--> 173 <!--开发环境:打印控制台-->
174 <springProfile name="dev"> 174 <springProfile name="dev">
175 <logger name="org.springframework.security" level="debug"/> 175 <logger name="org.springframework.security" level="debug"/>
@@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
21 <fastjson_version>1.2.28</fastjson_version> 21 <fastjson_version>1.2.28</fastjson_version>
22 <lombok_sersion>1.18.6</lombok_sersion> 22 <lombok_sersion>1.18.6</lombok_sersion>
23 <swagger2_version>2.9.2</swagger2_version> 23 <swagger2_version>2.9.2</swagger2_version>
  24 + <shiro.version>1.2.5</shiro.version>
24 </properties> 25 </properties>
25 26
26 <dependencies> 27 <dependencies>
@@ -205,10 +206,10 @@ @@ -205,10 +206,10 @@
205 <groupId>org.springframework.boot</groupId> 206 <groupId>org.springframework.boot</groupId>
206 <artifactId>spring-boot-starter-data-redis</artifactId> 207 <artifactId>spring-boot-starter-data-redis</artifactId>
207 </dependency> 208 </dependency>
208 - <dependency>  
209 - <groupId>org.springframework.cloud</groupId>  
210 - <artifactId>spring-cloud-starter-zipkin</artifactId>  
211 - </dependency> 209 +<!-- <dependency>-->
  210 +<!-- <groupId>org.springframework.cloud</groupId>-->
  211 +<!-- <artifactId>spring-cloud-starter-zipkin</artifactId>-->
  212 +<!-- </dependency>-->
212 213
213 <dependency> 214 <dependency>
214 <groupId>de.codecentric</groupId> 215 <groupId>de.codecentric</groupId>
@@ -220,6 +221,12 @@ @@ -220,6 +221,12 @@
220 <artifactId>spring-boot-starter-actuator</artifactId> 221 <artifactId>spring-boot-starter-actuator</artifactId>
221 </dependency> 222 </dependency>
222 223
  224 + <!-- 兼容卡口登录插件需要用shiro-->
  225 + <dependency>
  226 + <groupId>org.apache.shiro</groupId>
  227 + <artifactId>shiro-core</artifactId>
  228 + <version>${shiro.version}</version>
  229 + </dependency>
223 </dependencies> 230 </dependencies>
224 231
225 <dependencyManagement> 232 <dependencyManagement>
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; @@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo;
5 import com.tianbo.warehouse.annotation.LogAnnotation; 5 import com.tianbo.warehouse.annotation.LogAnnotation;
6 import com.tianbo.warehouse.annotation.RequestRequire; 6 import com.tianbo.warehouse.annotation.RequestRequire;
7 import com.tianbo.warehouse.annotation.UserPasswordMd5; 7 import com.tianbo.warehouse.annotation.UserPasswordMd5;
  8 +import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheDelTarget;
8 import com.tianbo.warehouse.controller.response.ResultJson; 9 import com.tianbo.warehouse.controller.response.ResultJson;
9 import com.tianbo.warehouse.model.USERS; 10 import com.tianbo.warehouse.model.USERS;
10 import com.tianbo.warehouse.model.UserRole; 11 import com.tianbo.warehouse.model.UserRole;
@@ -74,6 +75,7 @@ public class UserController { @@ -74,6 +75,7 @@ public class UserController {
74 @LogAnnotation(moduleName = "用户管理",operate = "用户编辑") 75 @LogAnnotation(moduleName = "用户管理",operate = "用户编辑")
75 @PutMapping("/edit") 76 @PutMapping("/edit")
76 public ResultJson updateUserById(@Validated(UpdateUser.class) @RequestBody USERS user){ 77 public ResultJson updateUserById(@Validated(UpdateUser.class) @RequestBody USERS user){
  78 + user.setPassword(null);
77 int i = userService.updateByPrimaryKeySelective(user); 79 int i = userService.updateByPrimaryKeySelective(user);
78 ResultJson resultJson = new ResultJson(); 80 ResultJson resultJson = new ResultJson();
79 return i==1 ? new ResultJson("200","success") :new ResultJson("500","update faild"); 81 return i==1 ? new ResultJson("200","success") :new ResultJson("500","update faild");
@@ -127,6 +129,7 @@ public class UserController { @@ -127,6 +129,7 @@ public class UserController {
127 * 刷新redis权限缓存 129 * 刷新redis权限缓存
128 */ 130 */
129 @ApiOperation(value = "更新用户权限缓存", notes = "重新生成用户的信息到redis") 131 @ApiOperation(value = "更新用户权限缓存", notes = "重新生成用户的信息到redis")
  132 + @RedisCacheDelTarget(cacheKey = "com.tianbo.warehouse.service.imp.PermissionServiceImp")
130 @PutMapping("/resetToken") 133 @PutMapping("/resetToken")
131 public ResultJson resetToken(HttpServletRequest request,HttpServletResponse respons) { 134 public ResultJson resetToken(HttpServletRequest request,HttpServletResponse respons) {
132 /** 135 /**
1 -package com.tianbo.warehouse.controller.staff;  
2 -  
3 -  
4 -import com.github.pagehelper.PageInfo;  
5 -import com.tianbo.warehouse.annotation.LogAnnotation;  
6 -import com.tianbo.warehouse.controller.response.ResultJson;  
7 -import com.tianbo.warehouse.model.StaffApartmentComeCar;  
8 -import com.tianbo.warehouse.model.StaffApartmentMaintain;  
9 -import com.tianbo.warehouse.service.satff.ComeCarService;  
10 -import com.tianbo.warehouse.service.satff.MaintainService;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.web.bind.annotation.*;  
13 -  
14 -import javax.servlet.http.HttpServletRequest;  
15 -import javax.servlet.http.HttpServletResponse;  
16 -import javax.validation.Valid;  
17 -  
18 -@RestController  
19 -@RequestMapping("/come_car")  
20 -public class ComeCarController {  
21 -  
22 - @Autowired  
23 - ComeCarService comeCarService;  
24 -  
25 - @GetMapping("/list")  
26 - public PageInfo<StaffApartmentComeCar> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")  
27 - int pageNum,  
28 - @RequestParam(value = "pageSize",required = false,defaultValue = "5")  
29 - int pageSize,  
30 - @RequestParam(value = "cometovisitname", required = false)  
31 - String comeToVisitName){  
32 - return comeCarService.findAll(pageNum,pageSize,comeToVisitName);  
33 -  
34 - }  
35 -  
36 - @LogAnnotation(moduleName = "职工公寓人员,车辆来访登记",operate = "职工公寓人员,车辆来访登记添加")  
37 - @PostMapping("/add")  
38 - public ResultJson add(@RequestBody StaffApartmentComeCar staffApartmentComeCar){  
39 -  
40 - int i =comeCarService.insertSelective(staffApartmentComeCar);  
41 -  
42 - ResultJson resultJson = new ResultJson();  
43 - if (1==i){  
44 - resultJson = new ResultJson("200","添加成功");  
45 - }else {  
46 - resultJson = new ResultJson("500","insert faild");  
47 - }  
48 - return resultJson;  
49 - }  
50 -  
51 - @LogAnnotation(moduleName = "职工公寓人员,车辆来访登记",operate = "职工公寓人员,车辆来访登记修改")  
52 - @PutMapping("/edit")  
53 - @ResponseBody  
54 - public ResultJson edit(@RequestBody @Valid StaffApartmentComeCar staffApartmentComeCar){  
55 -  
56 - int i =comeCarService.updateByPrimaryKeySelective(staffApartmentComeCar);  
57 -  
58 - ResultJson resultJson = new ResultJson();  
59 - if (1==i){  
60 - resultJson = new ResultJson("200","修改成功");  
61 - }else {  
62 - resultJson = new ResultJson("500","insert faild");  
63 - }  
64 - return resultJson;  
65 - }  
66 -  
67 - @LogAnnotation(moduleName = "职工公寓人员,车辆来访登记",operate = "职工公寓人员,车辆来访登记删除")  
68 - @DeleteMapping("/del")  
69 - public ResultJson reomve(@RequestBody StaffApartmentComeCar staffApartmentComeCar, HttpServletRequest request, HttpServletResponse response){  
70 -  
71 - int i =comeCarService.deleteByPrimaryKey(staffApartmentComeCar.getId());  
72 -  
73 - ResultJson resultJson = new ResultJson();  
74 - if (1==i){  
75 - resultJson = new ResultJson("200","删除成功");  
76 - }else {  
77 - resultJson = new ResultJson("500","insert faild");  
78 - }  
79 - return resultJson;  
80 - }  
81 -  
82 - @LogAnnotation(moduleName = "职工公寓人员,车辆来访登记",operate = "职工公寓人员,车辆来访登记删除")  
83 - @GetMapping("/batchremove")  
84 - public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){  
85 -  
86 - ResultJson resultJson = new ResultJson();  
87 -  
88 - if (comeCarService.deleteByPrimaryKey(ids)>0){  
89 - resultJson = new ResultJson("200","删除成功");  
90 - }else {  
91 - resultJson = new ResultJson("500","insert faild");  
92 - }  
93 - return resultJson;  
94 - }  
95 -  
96 -}  
1 -package com.tianbo.warehouse.controller.staff;  
2 -  
3 -  
4 -import com.github.pagehelper.PageInfo;  
5 -import com.tianbo.warehouse.annotation.LogAnnotation;  
6 -import com.tianbo.warehouse.controller.response.ResultJson;  
7 -import com.tianbo.warehouse.model.StaffApartmentSpareKey;  
8 -import com.tianbo.warehouse.model.StaffSecurityInspection;  
9 -import com.tianbo.warehouse.service.satff.KeyService;  
10 -import com.tianbo.warehouse.service.satff.StaffSecurityInspectionService;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.web.bind.annotation.*;  
13 -  
14 -import javax.servlet.http.HttpServletRequest;  
15 -import javax.servlet.http.HttpServletResponse;  
16 -import javax.validation.Valid;  
17 -  
18 -@RestController  
19 -@RequestMapping("/key")  
20 -public class KeyController {  
21 -  
22 - @Autowired  
23 - KeyService keyService;  
24 -  
25 - @GetMapping("/list")  
26 - public PageInfo<StaffApartmentSpareKey> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")  
27 - int pageNum,  
28 - @RequestParam(value = "pageSize",required = false,defaultValue = "5")  
29 - int pageSize,  
30 - @RequestParam(value = "staffname", required = false)  
31 - String staffname){  
32 - return keyService.findAll(pageNum,pageSize,staffname);  
33 -  
34 - }  
35 -  
36 - @LogAnnotation(moduleName = "职工公寓备用钥匙使用记录管理",operate = "职工公寓备用钥匙使用记录添加")  
37 - @PostMapping("/add")  
38 - public ResultJson add(@RequestBody StaffApartmentSpareKey staffApartmentSpareKey){  
39 -  
40 - int i =keyService.insertSelective(staffApartmentSpareKey);  
41 -  
42 - ResultJson resultJson = new ResultJson();  
43 - if (1==i){  
44 - resultJson = new ResultJson("200","添加成功");  
45 - }else {  
46 - resultJson = new ResultJson("500","insert faild");  
47 - }  
48 - return resultJson;  
49 - }  
50 -  
51 - @LogAnnotation(moduleName = "职工公寓备用钥匙使用记录管理",operate = "职工公寓备用钥匙使用记录修改")  
52 - @PutMapping("/edit")  
53 - @ResponseBody  
54 - public ResultJson edit(@RequestBody @Valid StaffApartmentSpareKey staffApartmentSpareKey){  
55 -  
56 - int i =keyService.updateByPrimaryKeySelective(staffApartmentSpareKey);  
57 -  
58 - ResultJson resultJson = new ResultJson();  
59 - if (1==i){  
60 - resultJson = new ResultJson("200","修改成功");  
61 - }else {  
62 - resultJson = new ResultJson("500","insert faild");  
63 - }  
64 - return resultJson;  
65 - }  
66 -  
67 - @LogAnnotation(moduleName = "职工公寓备用钥匙使用记录管理",operate = "职工公寓备用钥匙使用记录删除")  
68 - @DeleteMapping("/del")  
69 - public ResultJson reomve(@RequestBody StaffApartmentSpareKey staffApartmentSpareKey, HttpServletRequest request, HttpServletResponse response){  
70 -  
71 - int i =keyService.deleteByPrimaryKey(staffApartmentSpareKey.getId());  
72 -  
73 - ResultJson resultJson = new ResultJson();  
74 - if (1==i){  
75 - resultJson = new ResultJson("200","删除成功");  
76 - }else {  
77 - resultJson = new ResultJson("500","insert faild");  
78 - }  
79 - return resultJson;  
80 - }  
81 -  
82 - @LogAnnotation(moduleName = "职工公寓备用钥匙使用记录管理",operate = "职工公寓备用钥匙使用记录删除")  
83 - @GetMapping("/batchremove")  
84 - public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){  
85 -  
86 - ResultJson resultJson = new ResultJson();  
87 -  
88 - if (keyService.deleteByPrimaryKey(ids)>0){  
89 - resultJson = new ResultJson("200","删除成功");  
90 - }else {  
91 - resultJson = new ResultJson("500","insert faild");  
92 - }  
93 - return resultJson;  
94 - }  
95 -  
96 -}  
1 -package com.tianbo.warehouse.controller.staff;  
2 -  
3 -  
4 -import com.github.pagehelper.PageInfo;  
5 -import com.tianbo.warehouse.annotation.LogAnnotation;  
6 -import com.tianbo.warehouse.controller.response.ResultJson;  
7 -import com.tianbo.warehouse.model.StaffApartmentMaintain;  
8 -import com.tianbo.warehouse.model.StaffApartmentSpareKey;  
9 -import com.tianbo.warehouse.service.satff.KeyService;  
10 -import com.tianbo.warehouse.service.satff.MaintainService;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.web.bind.annotation.*;  
13 -  
14 -import javax.servlet.http.HttpServletRequest;  
15 -import javax.servlet.http.HttpServletResponse;  
16 -import javax.validation.Valid;  
17 -  
18 -@RestController  
19 -@RequestMapping("/maintain")  
20 -public class MaintainController {  
21 -  
22 - @Autowired  
23 - MaintainService maintainService;  
24 -  
25 - @GetMapping("/list")  
26 - public PageInfo<StaffApartmentMaintain> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")  
27 - int pageNum,  
28 - @RequestParam(value = "pageSize",required = false,defaultValue = "5")  
29 - int pageSize,  
30 - @RequestParam(value = "repairsname", required = false)  
31 - String repairsname){  
32 - return maintainService.findAll(pageNum,pageSize,repairsname);  
33 -  
34 - }  
35 -  
36 - @LogAnnotation(moduleName = "职工公寓设施设备维修记录管理",operate = "职工公寓设施设备维修记录添加")  
37 - @PostMapping("/add")  
38 - public ResultJson add(@RequestBody StaffApartmentMaintain staffApartmentMaintain){  
39 -  
40 - int i =maintainService.insertSelective(staffApartmentMaintain);  
41 -  
42 - ResultJson resultJson = new ResultJson();  
43 - if (1==i){  
44 - resultJson = new ResultJson("200","添加成功");  
45 - }else {  
46 - resultJson = new ResultJson("500","insert faild");  
47 - }  
48 - return resultJson;  
49 - }  
50 -  
51 - @LogAnnotation(moduleName = "职工公寓设施设备维修记录管理",operate = "职工公寓设施设备维修记录修改")  
52 - @PutMapping("/edit")  
53 - @ResponseBody  
54 - public ResultJson edit(@RequestBody @Valid StaffApartmentMaintain staffApartmentMaintain){  
55 -  
56 - int i =maintainService.updateByPrimaryKeySelective(staffApartmentMaintain);  
57 -  
58 - ResultJson resultJson = new ResultJson();  
59 - if (1==i){  
60 - resultJson = new ResultJson("200","修改成功");  
61 - }else {  
62 - resultJson = new ResultJson("500","insert faild");  
63 - }  
64 - return resultJson;  
65 - }  
66 -  
67 - @LogAnnotation(moduleName = "职工公寓设施设备维修记录管理",operate = "职工公寓设施设备维修记录删除")  
68 - @DeleteMapping("/del")  
69 - public ResultJson reomve(@RequestBody StaffApartmentMaintain staffApartmentMaintain, HttpServletRequest request, HttpServletResponse response){  
70 -  
71 - int i =maintainService.deleteByPrimaryKey(staffApartmentMaintain.getId());  
72 -  
73 - ResultJson resultJson = new ResultJson();  
74 - if (1==i){  
75 - resultJson = new ResultJson("200","删除成功");  
76 - }else {  
77 - resultJson = new ResultJson("500","insert faild");  
78 - }  
79 - return resultJson;  
80 - }  
81 -  
82 - @LogAnnotation(moduleName = "职工公寓设施设备维修记录管理",operate = "职工公寓设施设备维修记录删除")  
83 - @GetMapping("/batchremove")  
84 - public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){  
85 -  
86 - ResultJson resultJson = new ResultJson();  
87 -  
88 - if (maintainService.deleteByPrimaryKey(ids)>0){  
89 - resultJson = new ResultJson("200","删除成功");  
90 - }else {  
91 - resultJson = new ResultJson("500","insert faild");  
92 - }  
93 - return resultJson;  
94 - }  
95 -  
96 -}  
1 -package com.tianbo.warehouse.controller.staff;  
2 -  
3 -  
4 -import com.github.pagehelper.PageInfo;  
5 -import com.tianbo.warehouse.annotation.LogAnnotation;  
6 -import com.tianbo.warehouse.controller.response.ResultJson;  
7 -import com.tianbo.warehouse.model.StaffApartmentMaintain;  
8 -import com.tianbo.warehouse.model.StaffApartmentOnduty;  
9 -import com.tianbo.warehouse.service.satff.MaintainService;  
10 -import com.tianbo.warehouse.service.satff.OnDutyService;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.web.bind.annotation.*;  
13 -  
14 -import javax.servlet.http.HttpServletRequest;  
15 -import javax.servlet.http.HttpServletResponse;  
16 -import javax.validation.Valid;  
17 -  
18 -@RestController  
19 -@RequestMapping("/on_duty")  
20 -public class OnDutyController {  
21 -  
22 - @Autowired  
23 - OnDutyService onDutyService;  
24 -  
25 - @GetMapping("/list")  
26 - public PageInfo<StaffApartmentOnduty> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")  
27 - int pageNum,  
28 - @RequestParam(value = "pageSize",required = false,defaultValue = "5")  
29 - int pageSize,  
30 - @RequestParam(value = "warchkeeper", required = false)  
31 - String warchkeeper){  
32 - return onDutyService.findAll(pageNum,pageSize,warchkeeper);  
33 -  
34 - }  
35 -  
36 - @LogAnnotation(moduleName = "职工公寓值班巡视管理",operate = "职工公寓值班巡视添加")  
37 - @PostMapping("/add")  
38 - public ResultJson add(@RequestBody StaffApartmentOnduty staffApartmentOnduty){  
39 -  
40 - int i =onDutyService.insertSelective(staffApartmentOnduty);  
41 -  
42 - ResultJson resultJson = new ResultJson();  
43 - if (1==i){  
44 - resultJson = new ResultJson("200","添加成功");  
45 - }else {  
46 - resultJson = new ResultJson("500","insert faild");  
47 - }  
48 - return resultJson;  
49 - }  
50 -  
51 - @LogAnnotation(moduleName = "职工公寓值班巡视管理",operate = "职工公寓值班巡视修改")  
52 - @PutMapping("/edit")  
53 - @ResponseBody  
54 - public ResultJson edit(@RequestBody @Valid StaffApartmentOnduty staffApartmentOnduty){  
55 -  
56 - int i =onDutyService.updateByPrimaryKeySelective(staffApartmentOnduty);  
57 -  
58 - ResultJson resultJson = new ResultJson();  
59 - if (1==i){  
60 - resultJson = new ResultJson("200","修改成功");  
61 - }else {  
62 - resultJson = new ResultJson("500","insert faild");  
63 - }  
64 - return resultJson;  
65 - }  
66 -  
67 - @LogAnnotation(moduleName = "职工公寓值班巡视管理",operate = "职工公寓值班巡视删除")  
68 - @DeleteMapping("/del")  
69 - public ResultJson reomve(@RequestBody StaffApartmentOnduty staffApartmentOnduty, HttpServletRequest request, HttpServletResponse response){  
70 -  
71 - int i =onDutyService.deleteByPrimaryKey(staffApartmentOnduty.getId());  
72 -  
73 - ResultJson resultJson = new ResultJson();  
74 - if (1==i){  
75 - resultJson = new ResultJson("200","删除成功");  
76 - }else {  
77 - resultJson = new ResultJson("500","insert faild");  
78 - }  
79 - return resultJson;  
80 - }  
81 -  
82 - @LogAnnotation(moduleName = "职工公寓值班巡视管理",operate = "职工公寓值班巡视删除")  
83 - @GetMapping("/batchremove")  
84 - public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){  
85 -  
86 - ResultJson resultJson = new ResultJson();  
87 -  
88 - if (onDutyService.deleteByPrimaryKey(ids)>0){  
89 - resultJson = new ResultJson("200","删除成功");  
90 - }else {  
91 - resultJson = new ResultJson("500","insert faild");  
92 - }  
93 - return resultJson;  
94 - }  
95 -  
96 -}  
1 -package com.tianbo.warehouse.controller.staff;  
2 -  
3 -  
4 -import com.github.pagehelper.PageInfo;  
5 -import com.tianbo.warehouse.annotation.LogAnnotation;  
6 -import com.tianbo.warehouse.controller.response.ResultJson;  
7 -import com.tianbo.warehouse.model.StaffSecurityInspection;  
8 -import com.tianbo.warehouse.service.satff.StaffSecurityInspectionService;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.web.bind.annotation.*;  
11 -  
12 -import javax.servlet.http.HttpServletRequest;  
13 -import javax.servlet.http.HttpServletResponse;  
14 -import javax.validation.Valid;  
15 -  
16 -@RestController  
17 -@RequestMapping("/inspection")  
18 -public class StaffSecurityInspectionController {  
19 -  
20 - @Autowired  
21 - StaffSecurityInspectionService staffSecurityInspectionService;  
22 -  
23 - @GetMapping("/list")  
24 - public PageInfo<StaffSecurityInspection> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")  
25 - int pageNum,  
26 - @RequestParam(value = "pageSize",required = false,defaultValue = "5")  
27 - int pageSize,  
28 - @RequestParam(value = "securityInspectionName", required = false)  
29 - String securityInspectionName){  
30 - return staffSecurityInspectionService.findAll(pageNum,pageSize,securityInspectionName);  
31 -  
32 - }  
33 -  
34 - @LogAnnotation(moduleName = "职工公寓安全巡视管理",operate = "职工公寓安全巡视添加")  
35 - @PostMapping("/add")  
36 - public ResultJson add(@RequestBody StaffSecurityInspection staffSecurityInspection){  
37 -  
38 - int i =staffSecurityInspectionService.insertSelective(staffSecurityInspection);  
39 -  
40 - ResultJson resultJson = new ResultJson();  
41 - if (1==i){  
42 - resultJson = new ResultJson("200","添加成功");  
43 - }else {  
44 - resultJson = new ResultJson("500","insert faild");  
45 - }  
46 - return resultJson;  
47 - }  
48 -  
49 - @LogAnnotation(moduleName = "职工公寓安全巡视管理",operate = "职工公寓安全巡视修改")  
50 - @PutMapping("/edit")  
51 - @ResponseBody  
52 - public ResultJson edit(@RequestBody @Valid StaffSecurityInspection staffSecurityInspection){  
53 -  
54 - int i =staffSecurityInspectionService.updateByPrimaryKeySelective(staffSecurityInspection);  
55 -  
56 - ResultJson resultJson = new ResultJson();  
57 - if (1==i){  
58 - resultJson = new ResultJson("200","修改成功");  
59 - }else {  
60 - resultJson = new ResultJson("500","insert faild");  
61 - }  
62 - return resultJson;  
63 - }  
64 -  
65 - @LogAnnotation(moduleName = "职工公寓安全巡视管理",operate = "职工公寓安全巡视删除")  
66 - @DeleteMapping("/del")  
67 - public ResultJson reomve(@RequestBody StaffSecurityInspection staffSecurityInspection, HttpServletRequest request, HttpServletResponse response){  
68 -  
69 - int i =staffSecurityInspectionService.deleteByPrimaryKey(staffSecurityInspection.getSecurityInspectionId());  
70 -  
71 - ResultJson resultJson = new ResultJson();  
72 - if (1==i){  
73 - resultJson = new ResultJson("200","删除成功");  
74 - }else {  
75 - resultJson = new ResultJson("500","insert faild");  
76 - }  
77 - return resultJson;  
78 - }  
79 -  
80 - @LogAnnotation(moduleName = "职工公寓安全巡视管理",operate = "职工公寓安全巡视删除")  
81 - @GetMapping("/batchremove")  
82 - public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){  
83 -  
84 - ResultJson resultJson = new ResultJson();  
85 -  
86 - if (staffSecurityInspectionService.deleteByPrimaryKey(ids)>0){  
87 - resultJson = new ResultJson("200","删除成功");  
88 - }else {  
89 - resultJson = new ResultJson("500","insert faild");  
90 - }  
91 - return resultJson;  
92 - }  
93 -  
94 -}  
1 -package com.tianbo.warehouse.controller.water;  
2 -  
3 -import com.github.pagehelper.PageInfo;  
4 -import com.tianbo.warehouse.annotation.LogAnnotation;  
5 -import com.tianbo.warehouse.controller.response.ResultJson;  
6 -import com.tianbo.warehouse.model.Company;  
7 -import com.tianbo.warehouse.model.WaterStationsPatrol;  
8 -import com.tianbo.warehouse.service.CompanyService;  
9 -import com.tianbo.warehouse.service.water.WaterStationsPatrolService;  
10 -import org.springframework.beans.factory.annotation.Autowired;  
11 -import org.springframework.web.bind.annotation.*;  
12 -  
13 -import javax.servlet.http.HttpServletRequest;  
14 -import javax.servlet.http.HttpServletResponse;  
15 -import javax.validation.Valid;  
16 -  
17 -@RestController  
18 -@RequestMapping("/water_stations_patrol")  
19 -public class WaterStationsPatrolController {  
20 -  
21 - @Autowired  
22 - WaterStationsPatrolService waterStationsPatrolService;  
23 -  
24 - @GetMapping("/list")  
25 - public PageInfo<WaterStationsPatrol> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")  
26 - int pageNum,  
27 - @RequestParam(value = "pageSize",required = false,defaultValue = "5")  
28 - int pageSize){  
29 - return waterStationsPatrolService.findAll(pageNum,pageSize);  
30 -  
31 - }  
32 -  
33 - @LogAnnotation(moduleName = "二水厂-水站巡视记录单管理",operate = "二水厂-水站巡视记录单管理添加")  
34 - @PostMapping("/add")  
35 - public ResultJson add(@RequestBody WaterStationsPatrol waterStationsPatrol){  
36 -  
37 - int i =waterStationsPatrolService.insertSelective(waterStationsPatrol);  
38 -  
39 - ResultJson resultJson = new ResultJson();  
40 - if (1==i){  
41 - resultJson = new ResultJson("200","添加成功");  
42 - }else {  
43 - resultJson = new ResultJson("500","insert faild");  
44 - }  
45 - return resultJson;  
46 - }  
47 -  
48 - @LogAnnotation(moduleName = "二水厂-水站巡视记录单管理",operate = "二水厂-水站巡视记录单管理修改")  
49 - @PutMapping("/edit")  
50 - @ResponseBody  
51 - public ResultJson edit(@RequestBody @Valid WaterStationsPatrol waterStationsPatrol){  
52 -  
53 - int i =waterStationsPatrolService.updateByPrimaryKeySelective(waterStationsPatrol);  
54 -  
55 - ResultJson resultJson = new ResultJson();  
56 - if (1==i){  
57 - resultJson = new ResultJson("200","修改成功");  
58 - }else {  
59 - resultJson = new ResultJson("500","insert faild");  
60 - }  
61 - return resultJson;  
62 - }  
63 -  
64 - @LogAnnotation(moduleName = "二水厂-水站巡视记录单管理",operate = "二水厂-水站巡视记录单管理删除")  
65 - @DeleteMapping("/del")  
66 - public ResultJson reomve(@RequestBody WaterStationsPatrol waterStationsPatrol, HttpServletRequest request, HttpServletResponse response){  
67 -  
68 - int i =waterStationsPatrolService.deleteByPrimaryKey(waterStationsPatrol.getId());  
69 -  
70 - ResultJson resultJson = new ResultJson();  
71 - if (1==i){  
72 - resultJson = new ResultJson("200","删除成功");  
73 - }else {  
74 - resultJson = new ResultJson("500","insert faild");  
75 - }  
76 - return resultJson;  
77 - }  
78 -  
79 - @LogAnnotation(moduleName = "二水厂-水站巡视记录单管理",operate = "二水厂-水站巡视记录单管理批量删除")  
80 - @GetMapping("/batchremove")  
81 - public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){  
82 -  
83 - ResultJson resultJson = new ResultJson();  
84 -  
85 - if (waterStationsPatrolService.deleteByPrimaryKey(ids)>0){  
86 - resultJson = new ResultJson("200","删除成功");  
87 - }else {  
88 - resultJson = new ResultJson("500","insert faild");  
89 - }  
90 - return resultJson;  
91 - }  
92 -  
93 -}  
@@ -26,6 +26,8 @@ public interface PERMISSIONMapper { @@ -26,6 +26,8 @@ public interface PERMISSIONMapper {
26 26
27 List<PERMISSION> findByUserId(Integer userId); 27 List<PERMISSION> findByUserId(Integer userId);
28 28
  29 + List<PERMISSION> findByUserIdKako(String userId);
  30 +
29 /** 31 /**
30 * 登录验证成功后获取用户权限列表非树形结构 32 * 登录验证成功后获取用户权限列表非树形结构
31 * @param userId 33 * @param userId
@@ -33,6 +35,8 @@ public interface PERMISSIONMapper { @@ -33,6 +35,8 @@ public interface PERMISSIONMapper {
33 */ 35 */
34 List<PERMISSION> findByUserIdWithLogin(Integer userId); 36 List<PERMISSION> findByUserIdWithLogin(Integer userId);
35 37
  38 + List<PERMISSION> findByUserIdWithLoginKako(String userId);
  39 +
36 List<PERMISSION> findByRoleId(Integer roleId); 40 List<PERMISSION> findByRoleId(Integer roleId);
37 41
38 List<String> findRoleListByUrl(String permissionUrl); 42 List<String> findRoleListByUrl(String permissionUrl);
@@ -16,6 +16,8 @@ public interface ROLEMapper { @@ -16,6 +16,8 @@ public interface ROLEMapper {
16 16
17 List<ROLE> findRolesByUserId(Integer userId); 17 List<ROLE> findRolesByUserId(Integer userId);
18 18
  19 + List<ROLE> findRolesByUserIdKako(String userId);
  20 +
19 List<ROLE> selectByParentId(Integer roleId); 21 List<ROLE> selectByParentId(Integer roleId);
20 22
21 List<ROLE> findAll(@Param("roleName") String roleName, 23 List<ROLE> findAll(@Param("roleName") String roleName,
@@ -65,8 +65,8 @@ public class PERMISSION implements Serializable { @@ -65,8 +65,8 @@ public class PERMISSION implements Serializable {
65 return ismenu; 65 return ismenu;
66 } 66 }
67 67
68 - public void setIsmenu(String ismenu) {  
69 - this.ismenu = "0".equals(ismenu)?false:true ; 68 + public void setIsmenu(Boolean ismenu) {
  69 + this.ismenu = ismenu ;
70 } 70 }
71 71
72 public Integer getParentId() { 72 public Integer getParentId() {
@@ -24,7 +24,7 @@ public class USERS implements UserDetails { @@ -24,7 +24,7 @@ public class USERS implements UserDetails {
24 private Integer userId; 24 private Integer userId;
25 25
26 @NotBlank(message="用户名不能为空",groups={InsertUser.class, UpdateUser.class}) 26 @NotBlank(message="用户名不能为空",groups={InsertUser.class, UpdateUser.class})
27 - @Length(min = 5, max = 11, message = "username 长度必须在 {min} - {max} 之间",groups={InsertUser.class, UpdateUser.class}) 27 + @Length(min = 4, max = 11, message = "username 长度必须在 {min} - {max} 之间",groups={InsertUser.class, UpdateUser.class})
28 @CheckUserExist(message = "用户已存在",groups=InsertUser.class) 28 @CheckUserExist(message = "用户已存在",groups=InsertUser.class)
29 private String username; 29 private String username;
30 30
@@ -11,7 +11,6 @@ public class UserRole { @@ -11,7 +11,6 @@ public class UserRole {
11 @DecimalMin("1") 11 @DecimalMin("1")
12 private Integer id; 12 private Integer id;
13 13
14 - @DecimalMin("1")  
15 private Integer userId; 14 private Integer userId;
16 15
17 @DecimalMin("1") 16 @DecimalMin("1")
1 package com.tianbo.warehouse.security.config; 1 package com.tianbo.warehouse.security.config;
2 2
3 -import com.netflix.discovery.converters.Auto;  
4 import com.tianbo.warehouse.security.CustomUserDetailService; 3 import com.tianbo.warehouse.security.CustomUserDetailService;
5 import com.tianbo.warehouse.security.filter.JwtAuthenticationTokenFilter; 4 import com.tianbo.warehouse.security.filter.JwtAuthenticationTokenFilter;
6 import com.tianbo.warehouse.security.handel.*; 5 import com.tianbo.warehouse.security.handel.*;
7 import com.tianbo.warehouse.security.MyFilterSecurityInterceptor; 6 import com.tianbo.warehouse.security.MyFilterSecurityInterceptor;
  7 +import com.tianbo.warehouse.security.handel.kakologin.MyKakoAuthenticationSuccessHandler;
  8 +import com.tianbo.warehouse.security.handel.kakologin.MyLoginAuthenticationProcessFilter;
8 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.beans.factory.annotation.Qualifier; 10 import org.springframework.beans.factory.annotation.Qualifier;
10 -import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;  
11 import org.springframework.boot.autoconfigure.security.servlet.PathRequest; 11 import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
12 import org.springframework.context.annotation.Configuration; 12 import org.springframework.context.annotation.Configuration;
13 import org.springframework.core.annotation.Order; 13 import org.springframework.core.annotation.Order;
14 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 14 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
15 -import org.springframework.security.config.annotation.authentication.configuration.EnableGlobalAuthentication;  
16 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 15 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
17 import org.springframework.security.config.annotation.web.builders.HttpSecurity; 16 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
18 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 17 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
19 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 18 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
20 import org.springframework.security.config.http.SessionCreationPolicy; 19 import org.springframework.security.config.http.SessionCreationPolicy;
21 -import org.springframework.security.core.userdetails.UserDetailsService;  
22 import org.springframework.security.crypto.password.PasswordEncoder; 20 import org.springframework.security.crypto.password.PasswordEncoder;
23 import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; 21 import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
24 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 22 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@@ -37,7 +35,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @@ -37,7 +35,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
37 private PasswordEncoder passwordEncoder; 35 private PasswordEncoder passwordEncoder;
38 36
39 @Autowired 37 @Autowired
40 - private MyAuthenticationSuccessHandler successHandler; 38 + private MyKakoAuthenticationSuccessHandler successHandler;
41 39
42 @Autowired 40 @Autowired
43 private MyAuthenticationFailHandler failHandler; 41 private MyAuthenticationFailHandler failHandler;
@@ -58,6 +56,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @@ -58,6 +56,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
58 @Autowired 56 @Autowired
59 private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter; 57 private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;
60 58
  59 + private final MyLoginAuthenticationProcessFilter adminAuthenticationProcessingFilter;
  60 +
61 @Override 61 @Override
62 protected void configure(AuthenticationManagerBuilder auth) throws Exception { 62 protected void configure(AuthenticationManagerBuilder auth) throws Exception {
63 //user Details Service验证 63 //user Details Service验证
@@ -66,6 +66,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @@ -66,6 +66,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
66 auth.eraseCredentials(false); 66 auth.eraseCredentials(false);
67 } 67 }
68 68
  69 +
  70 + /**
  71 + * 用户密码校验过滤器
  72 + */
  73 +
  74 +
  75 + public WebSecurityConfig(MyLoginAuthenticationProcessFilter adminAuthenticationProcessingFilter) {
  76 + this.adminAuthenticationProcessingFilter = adminAuthenticationProcessingFilter;
  77 + }
  78 +
69 /** 79 /**
70 * 在configure(HttpSecurity http)方法中, 80 * 在configure(HttpSecurity http)方法中,
71 * 通过withObjectPostProcessor将刚刚创建的UrlFilterInvocationSecurityMetadataSource和UrlAccessDecisionManager注入进来。 81 * 通过withObjectPostProcessor将刚刚创建的UrlFilterInvocationSecurityMetadataSource和UrlAccessDecisionManager注入进来。
@@ -130,6 +140,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @@ -130,6 +140,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
130 //关闭session 140 //关闭session
131 http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); 141 http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
132 142
  143 + // 自定义过滤器认证用户名密码
  144 + http.addFilterAt(adminAuthenticationProcessingFilter, UsernamePasswordAuthenticationFilter.class);
133 145
134 //session管理 146 //session管理
135 //session失效后跳转 147 //session失效后跳转
  1 +/**
  2 + * Copyright (c) 2005-2012 springside.org.cn
  3 + */
  4 +package com.tianbo.warehouse.security.handel.kakologin;
  5 +
  6 +import org.apache.commons.codec.DecoderException;
  7 +import org.apache.commons.codec.binary.Base64;
  8 +import org.apache.commons.codec.binary.Hex;
  9 +
  10 +import java.io.UnsupportedEncodingException;
  11 +
  12 +/**
  13 + * 封装各种格式的编码解码工具类.
  14 + * 1.Commons-Codec的 hex/base64 编码
  15 + * 2.自制的base62 编码
  16 + * 3.Commons-Lang的xml/html escape
  17 + * 4.JDK提供的URLEncoder
  18 + * @author calvin
  19 + * @version 2013-01-15
  20 + */
  21 +public class Encodes {
  22 +
  23 + private static final String DEFAULT_URL_ENCODING = "UTF-8";
  24 + private static final char[] BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
  25 +
  26 + /**
  27 + * Hex编码.
  28 + */
  29 + public static String encodeHex(byte[] input) {
  30 + return new String(Hex.encodeHex(input));
  31 + }
  32 +
  33 + /**
  34 + * Hex解码.
  35 + */
  36 + public static byte[] decodeHex(String input) {
  37 + try {
  38 + return Hex.decodeHex(input.toCharArray());
  39 + } catch (DecoderException e) {
  40 + throw Exceptions.unchecked(e);
  41 + }
  42 + }
  43 +
  44 + /**
  45 + * Base64编码.
  46 + */
  47 + public static String encodeBase64(byte[] input) {
  48 + return new String(Base64.encodeBase64(input));
  49 + }
  50 +
  51 + /**
  52 + * Base64编码.
  53 + */
  54 + public static String encodeBase64(String input) {
  55 + try {
  56 + return new String(Base64.encodeBase64(input.getBytes(DEFAULT_URL_ENCODING)));
  57 + } catch (UnsupportedEncodingException e) {
  58 + return "";
  59 + }
  60 + }
  61 +
  62 +// /**
  63 +// * Base64编码, URL安全(将Base64中的URL非法字符'+'和'/'转为'-'和'_', 见RFC3548).
  64 +// */
  65 +// public static String encodeUrlSafeBase64(byte[] input) {
  66 +// return Base64.encodeBase64URLSafe(input);
  67 +// }
  68 +
  69 + /**
  70 + * Base64解码.
  71 + */
  72 + public static byte[] decodeBase64(String input) {
  73 + return Base64.decodeBase64(input.getBytes());
  74 + }
  75 +
  76 + /**
  77 + * Base64解码.
  78 + */
  79 + public static String decodeBase64String(String input) {
  80 + try {
  81 + return new String(Base64.decodeBase64(input.getBytes()), DEFAULT_URL_ENCODING);
  82 + } catch (UnsupportedEncodingException e) {
  83 + return "";
  84 + }
  85 + }
  86 +
  87 + /**
  88 + * Base62编码。
  89 + */
  90 + public static String encodeBase62(byte[] input) {
  91 + char[] chars = new char[input.length];
  92 + for (int i = 0; i < input.length; i++) {
  93 + chars[i] = BASE62[((input[i] & 0xFF) % BASE62.length)];
  94 + }
  95 + return new String(chars);
  96 + }
  97 +
  98 +}
  1 +/**
  2 + * Copyright (c) 2005-2012 springside.org.cn
  3 + */
  4 +package com.tianbo.warehouse.security.handel.kakologin;
  5 +
  6 +import javax.servlet.http.HttpServletRequest;
  7 +import java.io.PrintWriter;
  8 +import java.io.StringWriter;
  9 +
  10 +/**
  11 + * 关于异常的工具类.
  12 + * @author calvin
  13 + * @version 2013-01-15
  14 + */
  15 +public class Exceptions {
  16 +
  17 + /**
  18 + * 将CheckedException转换为UncheckedException.
  19 + */
  20 + public static RuntimeException unchecked(Exception e) {
  21 + if (e instanceof RuntimeException) {
  22 + return (RuntimeException) e;
  23 + } else {
  24 + return new RuntimeException(e);
  25 + }
  26 + }
  27 +
  28 + /**
  29 + * 将ErrorStack转化为String.
  30 + */
  31 + public static String getStackTraceAsString(Throwable e) {
  32 + if (e == null){
  33 + return "";
  34 + }
  35 + StringWriter stringWriter = new StringWriter();
  36 + e.printStackTrace(new PrintWriter(stringWriter));
  37 + return stringWriter.toString();
  38 + }
  39 +
  40 + /**
  41 + * 判断异常是否由某些底层的异常引起.
  42 + */
  43 + public static boolean isCausedBy(Exception ex, Class<? extends Exception>... causeExceptionClasses) {
  44 + Throwable cause = ex.getCause();
  45 + while (cause != null) {
  46 + for (Class<? extends Exception> causeClass : causeExceptionClasses) {
  47 + if (causeClass.isInstance(cause)) {
  48 + return true;
  49 + }
  50 + }
  51 + cause = cause.getCause();
  52 + }
  53 + return false;
  54 + }
  55 +
  56 + /**
  57 + * 在request中获取异常类
  58 + * @param request
  59 + * @return
  60 + */
  61 + public static Throwable getThrowable(HttpServletRequest request){
  62 + Throwable ex = null;
  63 + if (request.getAttribute("exception") != null) {
  64 + ex = (Throwable) request.getAttribute("exception");
  65 + } else if (request.getAttribute("javax.servlet.error.exception") != null) {
  66 + ex = (Throwable) request.getAttribute("javax.servlet.error.exception");
  67 + }
  68 + return ex;
  69 + }
  70 +
  71 +}
  1 +package com.tianbo.warehouse.security.handel.kakologin;
  2 +
  3 +import com.tianbo.warehouse.model.KakoUser;
  4 +import com.tianbo.warehouse.service.kakoImp.KakoUserService;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.security.core.userdetails.UserDetails;
  7 +import org.springframework.security.core.userdetails.UserDetailsService;
  8 +import org.springframework.security.core.userdetails.UsernameNotFoundException;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import java.util.List;
  12 +
  13 +@Service
  14 +public class KakoUserDetailService implements UserDetailsService {
  15 +
  16 + @Autowired
  17 + private KakoUserService userService;
  18 +
  19 + @Override
  20 + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
  21 +
  22 +
  23 + UserDetails user = userService.loadByUsername(username);
  24 + if (user == null) {
  25 + throw new UsernameNotFoundException("用户名不存在");
  26 +// throw new BadCredentialsException("用户名不存在");
  27 + }
  28 +
  29 + return user;
  30 +
  31 + }
  32 +}
  1 +package com.tianbo.warehouse.security.handel.kakologin;
  2 +
  3 +import org.springframework.security.authentication.AuthenticationManager;
  4 +import org.springframework.security.authentication.ProviderNotFoundException;
  5 +import org.springframework.security.core.Authentication;
  6 +import org.springframework.security.core.AuthenticationException;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import java.util.Objects;
  10 +
  11 +/**
  12 + * 自定义认证管理器
  13 + */
  14 +@Component
  15 +public class MyAuthenticationManager implements AuthenticationManager {
  16 + private final MyLoginAuthenticationProvider adminAuthenticationProvider;
  17 +
  18 + public MyAuthenticationManager(MyLoginAuthenticationProvider adminAuthenticationProvider) {
  19 + this.adminAuthenticationProvider = adminAuthenticationProvider;
  20 + }
  21 +
  22 + @Override
  23 + public Authentication authenticate(Authentication authentication) throws AuthenticationException {
  24 + Authentication result = adminAuthenticationProvider.authenticate(authentication);
  25 + if (Objects.nonNull(result)) {
  26 + return result;
  27 + }
  28 + throw new ProviderNotFoundException("Authentication failed!");
  29 + }
  30 +}
  1 +package com.tianbo.warehouse.security.handel.kakologin;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.fasterxml.jackson.databind.ObjectMapper;
  5 +import com.tianbo.warehouse.bean.AuthSuccessResponse;
  6 +import com.tianbo.warehouse.model.KakoUser;
  7 +import com.tianbo.warehouse.model.USERS;
  8 +import com.tianbo.warehouse.security.config.SecurityProperties;
  9 +import com.tianbo.warehouse.security.filter.JwtTokenUtil;
  10 +import com.tianbo.warehouse.security.model.LoginType;
  11 +import com.tianbo.warehouse.service.PermissionService;
  12 +import com.tianbo.warehouse.util.RedisUtils;
  13 +import org.apache.commons.logging.Log;
  14 +import org.apache.commons.logging.LogFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.beans.factory.annotation.Value;
  17 +import org.springframework.security.authentication.DisabledException;
  18 +import org.springframework.security.core.Authentication;
  19 +import org.springframework.security.core.userdetails.UserDetails;
  20 +import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
  21 +import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
  22 +import org.springframework.security.web.savedrequest.RequestCache;
  23 +import org.springframework.security.web.savedrequest.SavedRequest;
  24 +import org.springframework.stereotype.Component;
  25 +import org.springframework.util.StringUtils;
  26 +
  27 +import javax.servlet.ServletException;
  28 +import javax.servlet.http.HttpServletRequest;
  29 +import javax.servlet.http.HttpServletResponse;
  30 +import java.io.IOException;
  31 +import java.util.Map;
  32 +
  33 +/**
  34 + * 登录成功后的返回处理
  35 + */
  36 +@Component
  37 +public class MyKakoAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler{
  38 + protected final Log logger = LogFactory.getLog(this.getClass());
  39 +
  40 + @Value("${jwt.max-alive}")
  41 + protected Integer jwtMaxAlive;
  42 +
  43 + @Autowired
  44 + private ObjectMapper objectMapper;
  45 +
  46 + @Autowired
  47 + private PermissionService permissionService;
  48 +
  49 + private RequestCache requestCache = new HttpSessionRequestCache();
  50 +
  51 + @Autowired
  52 + private SecurityProperties securityProperties;
  53 +
  54 + @Autowired
  55 + RedisUtils redisUtils;
  56 + @Override
  57 + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
  58 + logger.info("登录成功");
  59 + if (LoginType.JSON.equals(securityProperties.getBrowser().getLoginType())){
  60 + //将 authention 信息打包成json格式返回
  61 + response.setContentType("application/json;charset=UTF-8");
  62 +// response.setHeader("Access-Control-Allow-Origin","*");
  63 +
  64 +
  65 + KakoUser user = (KakoUser) authentication.getPrincipal();
  66 +
  67 + //返回前端登陆成功后的用户信息
  68 + KakoUser loginedUser = new KakoUser();
  69 + loginedUser.setLoginName(user.getUsername());
  70 + loginedUser.setId(user.getId());
  71 + loginedUser.setName(user.getName());
  72 +
  73 +
  74 + //设置用户的TOKEN的有效时间,时间配置在配置文件中设置
  75 + String jwtToken = JwtTokenUtil.generateToken(loginedUser.getUsername(), jwtMaxAlive);
  76 + loginedUser.setToken(jwtToken);
  77 + //这里将登录成功的[user]对象数据写入redis缓存,KEY为token value为user的JSON对象
  78 + String json = JSON.toJSONString(user);
  79 + redisUtils.set(jwtToken, json,3600*24*7);
  80 + Map<String,Object> menuMap = permissionService.getUserMenusKako(user.getId());
  81 + //返回用户信息和用户可访问的目录列表
  82 + response.getWriter().write(objectMapper.writeValueAsString(new AuthSuccessResponse(loginedUser,menuMap)));
  83 + }else {
  84 + //走原来的处理流程
  85 + SavedRequest savedRequest = this.requestCache.getRequest(request, response);
  86 + if (savedRequest == null) {
  87 + super.onAuthenticationSuccess(request, response, authentication);
  88 + } else {
  89 + String targetUrlParameter = this.getTargetUrlParameter();
  90 + if (!this.isAlwaysUseDefaultTargetUrl() && (targetUrlParameter == null || !StringUtils.hasText(request.getParameter(targetUrlParameter)))) {
  91 + this.clearAuthenticationAttributes(request);
  92 + String targetUrl = savedRequest.getRedirectUrl();
  93 + this.logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
  94 + this.getRedirectStrategy().sendRedirect(request, response, targetUrl);
  95 + } else {
  96 + this.requestCache.removeRequest(request, response);
  97 + super.onAuthenticationSuccess(request, response, authentication);
  98 + }
  99 + }
  100 + }
  101 +
  102 + }
  103 +
  104 +
  105 +}
  1 +package com.tianbo.warehouse.security.handel.kakologin;
  2 +
  3 +
  4 +import com.tianbo.warehouse.security.handel.MyAuthenticationFailHandler;
  5 +import lombok.extern.slf4j.Slf4j;
  6 +import org.springframework.security.authentication.AuthenticationServiceException;
  7 +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
  8 +import org.springframework.security.core.Authentication;
  9 +import org.springframework.security.core.AuthenticationException;
  10 +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
  11 +import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import javax.servlet.http.HttpServletRequest;
  15 +import javax.servlet.http.HttpServletResponse;
  16 +
  17 +/**
  18 + * 用户登录自定义校验过滤器
  19 + */
  20 +@Slf4j
  21 +@Component
  22 +public class MyLoginAuthenticationProcessFilter extends AbstractAuthenticationProcessingFilter {
  23 + /**
  24 + * @param authenticationManager: 认证管理器
  25 + * @param adminAuthenticationSuccessHandler: 认证成功处理
  26 + * @param adminAuthenticationFailureHandler: 认证失败处理
  27 + */
  28 + public MyLoginAuthenticationProcessFilter(MyAuthenticationManager authenticationManager, MyKakoAuthenticationSuccessHandler adminAuthenticationSuccessHandler, MyAuthenticationFailHandler adminAuthenticationFailureHandler) {
  29 + super(new AntPathRequestMatcher("/login", "POST"));
  30 + this.setAuthenticationManager(authenticationManager);
  31 + this.setAuthenticationSuccessHandler(adminAuthenticationSuccessHandler);
  32 + this.setAuthenticationFailureHandler(adminAuthenticationFailureHandler);
  33 + }
  34 +
  35 + @Override
  36 + public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
  37 + if (request.getContentType() == null || !request.getContentType().contains("application/x-www-form-urlencoded")) {
  38 + throw new AuthenticationServiceException("请求头类型不支持: " + request.getContentType());
  39 + }
  40 +
  41 + UsernamePasswordAuthenticationToken authRequest;
  42 + try {
  43 + String loginUserName = request.getParameter("username");
  44 + String loginUserPass = request.getParameter("password");
  45 + authRequest = new UsernamePasswordAuthenticationToken(loginUserName,loginUserPass, null);
  46 + authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
  47 + } catch (Exception e) {
  48 + throw new AuthenticationServiceException(e.getMessage());
  49 + }
  50 + return this.getAuthenticationManager().authenticate(authRequest);
  51 + }
  52 +}
  1 +package com.tianbo.warehouse.security.handel.kakologin;
  2 +
  3 +import com.tianbo.warehouse.dao.KakoUserMapper;
  4 +import com.tianbo.warehouse.model.KakoUser;
  5 +import com.tianbo.warehouse.model.USERS;
  6 +import com.tianbo.warehouse.security.CustomUserDetailService;
  7 +import com.tianbo.warehouse.service.UserService;
  8 +import com.tianbo.warehouse.util.RedisUtils;
  9 +import org.apache.shiro.codec.CodecException;
  10 +import org.apache.shiro.crypto.hash.Hash;
  11 +import org.apache.shiro.crypto.hash.SimpleHash;
  12 +import org.apache.shiro.util.ByteSource;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.security.authentication.AuthenticationProvider;
  15 +import org.springframework.security.authentication.BadCredentialsException;
  16 +import org.springframework.security.authentication.DisabledException;
  17 +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
  18 +import org.springframework.security.core.Authentication;
  19 +import org.springframework.security.core.AuthenticationException;
  20 +import org.springframework.security.core.userdetails.UserDetails;
  21 +import org.springframework.stereotype.Component;
  22 +
  23 +import java.io.File;
  24 +import java.io.InputStream;
  25 +import java.util.Arrays;
  26 +
  27 +import org.apache.shiro.codec.CodecSupport;
  28 +
  29 +import javax.annotation.Resource;
  30 +
  31 +/**
  32 + * 自定义认证处理类
  33 + */
  34 +@Component
  35 +public class MyLoginAuthenticationProvider extends CodecSupport implements AuthenticationProvider {
  36 +
  37 + @Autowired
  38 + private KakoUserDetailService userDetailsService;
  39 +
  40 + @Resource
  41 + private KakoUserMapper userMapper;
  42 +
  43 + @Autowired
  44 + private RedisUtils redisUtils;
  45 +
  46 + @Override
  47 + public Authentication authenticate(Authentication authentication) throws AuthenticationException {
  48 + // 获取前端表单中输入后返回的用户名、密码
  49 + String userName = (String) authentication.getPrincipal();
  50 + String password = (String) authentication.getCredentials();
  51 +
  52 + UserDetails userInfo = userDetailsService.loadUserByUsername(userName);
  53 +
  54 +
  55 + //验证登录密码是否符合规则,如位数包含的字符等
  56 + boolean isValid = PasswordSaltUtils.isValidPassword(password, userInfo.getPassword(), "");
  57 + // 验证密码
  58 + if (!isValid) {
  59 + //todo: 登录次数超了 锁定账户
  60 + throw new BadCredentialsException("密码错误!");
  61 + }
  62 + if(!userInfo.isEnabled()){
  63 + throw new DisabledException("用户被禁用");
  64 + }
  65 +
  66 + //取盐规则
  67 + byte[] salt = PasswordSaltUtils.getSalt16(userInfo.getPassword());
  68 + //真实密码
  69 + String realPass = PasswordSaltUtils.getPassword16(userInfo.getPassword());
  70 + //用户登录密码与盐运算
  71 + Object tokenHashedCredentials = this.hashProvidedCredentials(password,salt,1024);
  72 +
  73 + try{
  74 + String loginUserLock = redisUtils.get(userName+"-lock");
  75 + Integer loginUserLockNO= 0;
  76 + if (loginUserLock!=null){
  77 + loginUserLockNO = Integer.valueOf(loginUserLock);
  78 + }
  79 + //判断密码是否正确
  80 + if(!equals(realPass,tokenHashedCredentials.toString())){
  81 + redisUtils.set(userName+"-lock", String.valueOf(++loginUserLockNO),120);
  82 +
  83 + //两分钟内错误登录次数超过5次锁定账户
  84 + if (loginUserLockNO>5){
  85 + KakoUser kakoUser = new KakoUser();
  86 + kakoUser.setLoginName(userName);
  87 + kakoUser.setLoginFlag("0");
  88 + userMapper.lockUser(kakoUser);
  89 + }
  90 + return null;
  91 + }
  92 + }catch (Exception e){
  93 + throw new BadCredentialsException("验证失败!");
  94 + }
  95 +
  96 +
  97 + // 前后端分离情况下 处理逻辑...
  98 + // 更新登录令牌 - 之后访问系统其它接口直接通过token认证用户权限...
  99 + return new UsernamePasswordAuthenticationToken(userInfo, password, userInfo.getAuthorities());
  100 + }
  101 +
  102 + @Override
  103 + public boolean supports(Class<?> aClass) {
  104 + return true;
  105 + }
  106 +
  107 + /**
  108 + * 根据用户密码生成秘文
  109 + * @param credentials 用户登录密码
  110 + * @param salt 盐
  111 + * @param hashIterations 1024
  112 + * @return
  113 + */
  114 + protected Hash hashProvidedCredentials(Object credentials, Object salt, int hashIterations) {
  115 + String hashAlgorithmName = "SHA-1";
  116 + hashIterations = 1024;
  117 + return new SimpleHash(hashAlgorithmName, credentials, salt, hashIterations);
  118 + }
  119 +
  120 + protected boolean equals(Object tokenCredentials, Object accountCredentials) {
  121 +
  122 + if (this.isByteSource(tokenCredentials) && this.isByteSource(accountCredentials)) {
  123 +
  124 + byte[] tokenBytes = this.toBytes(tokenCredentials);
  125 + byte[] accountBytes = this.toBytes(accountCredentials);
  126 + return Arrays.equals(tokenBytes, accountBytes);
  127 + } else {
  128 + return accountCredentials.equals(tokenCredentials);
  129 + }
  130 + }
  131 +}
  1 +package com.tianbo.warehouse.security.handel.kakologin;
  2 +
  3 +import org.springframework.stereotype.Component;
  4 +
  5 +@Component
  6 +public class PasswordSaltUtils {
  7 +
  8 + /**
  9 + * 密码校验
  10 + * @return true密码校验通过 false 失败
  11 + */
  12 + public static boolean isValidPassword(String LoginPassword, String UserPassword, String Salt){
  13 + return true;
  14 + }
  15 +
  16 + /**
  17 + * 加密前端传递过来的密码
  18 + * @param Salt 盐
  19 + * @param SaltFromDB 数据库中保存的盐
  20 + * @return
  21 + */
  22 + public static String encodePassword(String Salt,String SaltFromDB){
  23 + return null;
  24 + }
  25 +
  26 + /**
  27 + * 解码存储到数据库中密码密文的前16位
  28 + * @param userPasswordInDB 数据库中用户的密码
  29 + * @return
  30 + */
  31 + public static byte[] getSalt16(String userPasswordInDB){
  32 + byte[] salt = Encodes.decodeHex(userPasswordInDB.substring(0,16));
  33 + return salt;
  34 + }
  35 +
  36 + /**
  37 + * 取存储到数据库中密码密文的后16位
  38 + * @param userPasswordInDB 数据库中用户的密码
  39 + * @return
  40 + */
  41 + public static String getPassword16(String userPasswordInDB){
  42 +
  43 + return userPasswordInDB.substring(16);
  44 + }
  45 +}
@@ -23,6 +23,8 @@ public interface PermissionService { @@ -23,6 +23,8 @@ public interface PermissionService {
23 */ 23 */
24 Map<String,Object> getUserMenus(Integer userId); 24 Map<String,Object> getUserMenus(Integer userId);
25 25
  26 + Map<String,Object> getUserMenusKako(String userId);
  27 +
26 28
27 int updateByPrimaryKeySelective(PERMISSION permission); 29 int updateByPrimaryKeySelective(PERMISSION permission);
28 30
@@ -35,6 +37,8 @@ public interface PermissionService { @@ -35,6 +37,8 @@ public interface PermissionService {
35 */ 37 */
36 List<PERMISSION> findByUserIdWithLogin(Integer userId); 38 List<PERMISSION> findByUserIdWithLogin(Integer userId);
37 39
  40 + List<PERMISSION> findByUserIdWithLoginKako(String userId);
  41 +
38 /** 42 /**
39 * 清理跟permission相关的所有缓存 43 * 清理跟permission相关的所有缓存
40 */ 44 */
@@ -69,6 +69,10 @@ public class PermissionServiceImp implements PermissionService { @@ -69,6 +69,10 @@ public class PermissionServiceImp implements PermissionService {
69 return permissionMapper.findByUserIdWithLogin(userId); 69 return permissionMapper.findByUserIdWithLogin(userId);
70 } 70 }
71 71
  72 + @Override
  73 + public List<PERMISSION> findByUserIdWithLoginKako(String userId){
  74 + return permissionMapper.findByUserIdWithLoginKako(userId);
  75 + }
72 /** 76 /**
73 * 返回用户权限的树形列表 77 * 返回用户权限的树形列表
74 * @param userId 78 * @param userId
@@ -111,6 +115,43 @@ public class PermissionServiceImp implements PermissionService { @@ -111,6 +115,43 @@ public class PermissionServiceImp implements PermissionService {
111 } 115 }
112 } 116 }
113 117
  118 + @Override
  119 + public Map<String, Object> getUserMenusKako(String userId) {
  120 + Map<String, Object> data = new HashMap<String, Object>();
  121 + try {
  122 + //查询所有菜单
  123 + List<PERMISSION> allMenu = permissionMapper.findByUserIdKako(userId);
  124 +// //根节点
  125 +// List<PERMISSION> rootMenu = new ArrayList<PERMISSION>();
  126 +// for (PERMISSION nav : allMenu) {
  127 +// if (nav.getParentId() == 0) {//父节点是0的,为根节点。
  128 +// rootMenu.add(nav);
  129 +// }
  130 +// }
  131 +
  132 + /* 根据Menu类的order排序 */
  133 +// Collections.sort(rootMenu, order());
  134 + //为根菜单设置子菜单,getClild是递归调用的
  135 +// for (PERMISSION nav : rootMenu) {
  136 +// /* 获取根节点下的所有子节点 使用getChild方法*/
  137 +// List<PERMISSION> childList = getChild(nav.getPermissionId(), allMenu);
  138 +// nav.setChildren(childList);//给根节点设置子节点
  139 +// }
  140 + /**
  141 + * 输出构建好的菜单数据。
  142 + *
  143 + */
  144 + data.put("success", "true");
  145 + data.put("list", allMenu);
  146 + return data;
  147 + } catch (Exception e) {
  148 + data.put("success", "false");
  149 + data.put("list", new ArrayList());
  150 + return data;
  151 + }
  152 + }
  153 +
  154 +
114 /** 155 /**
115 * 获取子节点 156 * 获取子节点
116 * 157 *
  1 +package com.tianbo.warehouse.service.kakoImp;
  2 +
  3 +import com.tianbo.warehouse.model.KakoUser;
  4 +import org.springframework.stereotype.Service;
  5 +
  6 +import java.util.List;
  7 +
  8 +
  9 +public interface KakoUserService {
  10 +
  11 + KakoUser loadByUsername(String username);
  12 +}
  1 +package com.tianbo.warehouse.service.kakoImp;
  2 +
  3 +import com.github.pagehelper.PageInfo;
  4 +import com.tianbo.warehouse.dao.KakoUserMapper;
  5 +import com.tianbo.warehouse.dao.ROLEMapper;
  6 +import com.tianbo.warehouse.model.*;
  7 +import com.tianbo.warehouse.service.PermissionService;
  8 +import com.tianbo.warehouse.service.UserService;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +import javax.annotation.Resource;
  13 +import java.util.List;
  14 +
  15 +@Service
  16 +public class KakoUserServiceImpl implements KakoUserService{
  17 +
  18 + @Resource
  19 + private KakoUserMapper kakoUserMapper;
  20 +
  21 + @Autowired
  22 + private PermissionService permissionService;
  23 +
  24 + @Resource
  25 + private ROLEMapper roleMapper;
  26 +
  27 + @Override
  28 + public KakoUser loadByUsername(String username){
  29 + List<KakoUser> userList = kakoUserMapper.selectByUsername(username);
  30 + if (userList != null && userList.size() > 0) {
  31 + KakoUser user = userList.get(0);
  32 +
  33 + List<PERMISSION> permissionList = permissionService.findByUserIdWithLoginKako(user.getId());
  34 + if (permissionList!=null && permissionList.size()>0){
  35 + user.setPermissions(permissionList);
  36 + }
  37 +
  38 + List<ROLE> roleList = roleMapper.findRolesByUserIdKako(user.getId());
  39 + if (roleList!=null && roleList.size()>0){
  40 + user.setRoles(roleList);
  41 + }
  42 + return user;
  43 + }
  44 + return null;
  45 + }
  46 +
  47 +}
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 </commentGenerator> 14 </commentGenerator>
15 <!--数据库链接URL,用户名、密码 --> 15 <!--数据库链接URL,用户名、密码 -->
16 <jdbcConnection driverClass="com.mysql.jdbc.Driver" 16 <jdbcConnection driverClass="com.mysql.jdbc.Driver"
17 - connectionURL="jdbc:mysql://118.31.66.166:3306/statistics" 17 + connectionURL="jdbc:mysql://118.31.66.166:3306/station"
18 userId="110" 18 userId="110"
19 password="QAHqCJf2kFYCLirM"> 19 password="QAHqCJf2kFYCLirM">
20 </jdbcConnection> 20 </jdbcConnection>
@@ -45,6 +45,6 @@ @@ -45,6 +45,6 @@
45 <property name="enableSubPackages" value="true"/> 45 <property name="enableSubPackages" value="true"/>
46 </javaClientGenerator> 46 </javaClientGenerator>
47 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> 47 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
48 - <table tableName="role" domainObjectName="ROLE" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> 48 + <table tableName="sys_user" domainObjectName="KakoUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
49 </context> 49 </context>
50 </generatorConfiguration> 50 </generatorConfiguration>
@@ -140,6 +140,37 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order @@ -140,6 +140,37 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order
140 AND P.parent_id = 0 140 AND P.parent_id = 0
141 ORDER BY permission_order 141 ORDER BY permission_order
142 </select> 142 </select>
  143 + <select id="findByUserIdKako" parameterType="java.lang.String" resultMap="treeResultMap">
  144 + SELECT
  145 + P.*
  146 + FROM
  147 + permission P
  148 + WHERE
  149 + P.permission_id IN (
  150 + SELECT
  151 + RP.permission_id
  152 + FROM
  153 + role_permission RP
  154 + WHERE
  155 + RP.role_id IN (
  156 + SELECT
  157 + R.role_id
  158 + FROM
  159 + role R
  160 + WHERE
  161 + R.role_id IN (
  162 + SELECT
  163 + UR.role_id
  164 + FROM
  165 + user_role UR
  166 + WHERE
  167 + UR.user_id = #{userId,jdbcType=VARCHAR}
  168 + )
  169 + )
  170 + )
  171 + AND P.parent_id = 0
  172 + ORDER BY permission_order
  173 + </select>
143 <select id="findByUserIdWithLogin" parameterType="java.lang.Integer" resultMap="BaseResultMap"> 174 <select id="findByUserIdWithLogin" parameterType="java.lang.Integer" resultMap="BaseResultMap">
144 SELECT 175 SELECT
145 P.* 176 P.*
@@ -170,6 +201,36 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order @@ -170,6 +201,36 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order
170 ) 201 )
171 ORDER BY permission_order 202 ORDER BY permission_order
172 </select> 203 </select>
  204 + <select id="findByUserIdWithLoginKako" parameterType="java.lang.String" resultMap="BaseResultMap">
  205 + SELECT
  206 + P.*
  207 + FROM
  208 + permission P
  209 + WHERE
  210 + P.permission_id IN (
  211 + SELECT
  212 + RP.permission_id
  213 + FROM
  214 + role_permission RP
  215 + WHERE
  216 + RP.role_id IN (
  217 + SELECT
  218 + R.role_id
  219 + FROM
  220 + role R
  221 + WHERE
  222 + R.role_id IN (
  223 + SELECT
  224 + UR.role_id
  225 + FROM
  226 + user_role UR
  227 + WHERE
  228 + UR.user_id = #{userId,jdbcType=VARCHAR}
  229 + )
  230 + )
  231 + )
  232 + ORDER BY permission_order
  233 + </select>
173 <select id="findByRoleId" resultMap="BaseResultMap" parameterType="integer"> 234 <select id="findByRoleId" resultMap="BaseResultMap" parameterType="integer">
174 SELECT 235 SELECT
175 P.* 236 P.*
@@ -192,4 +192,14 @@ @@ -192,4 +192,14 @@
192 LEFT JOIN role R ON R.role_id= UR.role_id 192 LEFT JOIN role R ON R.role_id= UR.role_id
193 where U.user_id = #{userId,jdbcType=INTEGER} 193 where U.user_id = #{userId,jdbcType=INTEGER}
194 </select> 194 </select>
  195 +
  196 + <select id="findRolesByUserIdKako" parameterType="java.lang.String" resultMap="BaseResultMap">
  197 + SELECT
  198 + R.*
  199 + FROM
  200 + sys_user U
  201 + LEFT JOIN user_role UR ON U.id = UR.user_id
  202 + LEFT JOIN role R ON R.role_id= UR.role_id
  203 + where U.id = #{userId,jdbcType=VARCHAR}
  204 + </select>
195 </mapper> 205 </mapper>