作者 zhangFan

新增redis设置

@@ -55,10 +55,10 @@ @@ -55,10 +55,10 @@
55 <artifactId>spring-boot-configuration-processor</artifactId> 55 <artifactId>spring-boot-configuration-processor</artifactId>
56 <optional>true</optional> 56 <optional>true</optional>
57 </dependency> 57 </dependency>
58 - <dependency>  
59 - <groupId>org.springframework.boot</groupId>  
60 - <artifactId>spring-boot-starter-thymeleaf</artifactId>  
61 - </dependency> 58 + <!--<dependency>-->
  59 + <!--<groupId>org.springframework.boot</groupId>-->
  60 + <!--<artifactId>spring-boot-starter-thymeleaf</artifactId>-->
  61 + <!--</dependency>-->
62 <dependency> 62 <dependency>
63 <groupId>io.jsonwebtoken</groupId> 63 <groupId>io.jsonwebtoken</groupId>
64 <artifactId>jjwt</artifactId> 64 <artifactId>jjwt</artifactId>
@@ -196,282 +196,9 @@ @@ -196,282 +196,9 @@
196 <artifactId>commons-io</artifactId> 196 <artifactId>commons-io</artifactId>
197 <version>2.6</version> 197 <version>2.6</version>
198 </dependency> 198 </dependency>
199 -  
200 - <!--IMF需要的包-->  
201 - <!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->  
202 - <dependency>  
203 - <groupId>org.apache.xmlbeans</groupId>  
204 - <artifactId>xmlbeans</artifactId>  
205 - <version>2.4.0</version>  
206 - </dependency>  
207 - <!-- https://mvnrepository.com/artifact/org.apache.ws.commons.schema/XmlSchema -->  
208 - <dependency>  
209 - <groupId>org.apache.ws.commons.schema</groupId>  
210 - <artifactId>XmlSchema</artifactId>  
211 - <version>1.4.7</version>  
212 - </dependency>  
213 - <!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->  
214 - <dependency>  
215 - <groupId>wsdl4j</groupId>  
216 - <artifactId>wsdl4j</artifactId>  
217 - <version>1.6.2</version>  
218 - </dependency>  
219 - <!-- https://mvnrepository.com/artifact/org.apache.neethi/neethi -->  
220 - <dependency>  
221 - <groupId>org.apache.neethi</groupId>  
222 - <artifactId>neethi</artifactId>  
223 - <version>2.0.4</version>  
224 - </dependency>  
225 -  
226 -  
227 -  
228 - <!-- LOG -->  
229 - <dependency>  
230 - <groupId>log4j</groupId>  
231 - <artifactId>log4j</artifactId>  
232 - <version>1.2.16</version>  
233 - </dependency>  
234 - <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->  
235 - <dependency>  
236 - <groupId>org.slf4j</groupId>  
237 - <artifactId>slf4j-api</artifactId>  
238 - <version>1.6.1</version>  
239 - </dependency>  
240 - <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14 -->  
241 - <dependency>  
242 - <groupId>org.slf4j</groupId>  
243 - <artifactId>slf4j-jdk14</artifactId>  
244 - <version>1.6.1</version>  
245 - <scope>test</scope>  
246 - </dependency>  
247 - <!-- https://mvnrepository.com/artifact/org.apache.cxf.xjcplugins/cxf-xjc-boolean -->  
248 - <dependency>  
249 - <groupId>org.apache.cxf.xjcplugins</groupId>  
250 - <artifactId>cxf-xjc-boolean</artifactId>  
251 - <version>3.2.3</version>  
252 - </dependency>  
253 -  
254 -  
255 -  
256 - <!--添加本地IMF包-->  
257 - <dependency>  
258 - <groupId>com.caac</groupId>  
259 - <artifactId>imf</artifactId>  
260 - <version>1.0.0</version>  
261 - <scope>system</scope>  
262 - <systemPath>${project.basedir}/lib/IMFClient.1.0.0.jar</systemPath>  
263 - </dependency>  
264 - <dependency>  
265 - <groupId>com.caac.imf</groupId>  
266 - <artifactId>imfmessage</artifactId>  
267 - <version>1.0.0</version>  
268 - <scope>system</scope>  
269 - <systemPath>${project.basedir}/lib/imfmsg.jar</systemPath>  
270 - </dependency>  
271 - <dependency>  
272 - <groupId>com.caac.imf</groupId>  
273 - <artifactId>process</artifactId>  
274 - <version>1.0.0</version>  
275 - <scope>system</scope>  
276 - <systemPath>${project.basedir}/lib/ProcessService.jar</systemPath>  
277 - </dependency>  
278 - <dependency>  
279 - <groupId>com.caac.imf</groupId>  
280 - <artifactId>apiconfig</artifactId>  
281 - <version>1.0.0</version>  
282 - <scope>system</scope>  
283 - <systemPath>${project.basedir}/lib/apiConfig.jar</systemPath>  
284 - </dependency>  
285 - <dependency>  
286 - <groupId>com.caac.imf</groupId>  
287 - <artifactId>upload</artifactId>  
288 - <version>1.0.0</version>  
289 - <scope>system</scope>  
290 - <systemPath>${project.basedir}/lib/UploadService.jar</systemPath>  
291 - </dependency>  
292 - <dependency>  
293 - <groupId>com.caac.imf</groupId>  
294 - <artifactId>heartbeat</artifactId>  
295 - <version>1.0.0</version>  
296 - <scope>system</scope>  
297 - <systemPath>${project.basedir}/lib/HeartbeatService.jar</systemPath>  
298 - </dependency>  
299 - <dependency>  
300 - <groupId>com.caac.imf</groupId>  
301 - <artifactId>returnxml</artifactId>  
302 - <version>1.0.0</version>  
303 - <scope>system</scope>  
304 - <systemPath>${project.basedir}/lib/returnXml.jar</systemPath>  
305 - </dependency>  
306 - <!-- https://mvnrepository.com/artifact/org.hyperic/sigar -->  
307 - <dependency>  
308 - <groupId>org.hyperic</groupId>  
309 - <artifactId>sigar</artifactId>  
310 - <version>1.6.4</version>  
311 - <scope>system</scope>  
312 - <systemPath>${project.basedir}/lib/sigar.jar</systemPath>  
313 - </dependency>  
314 <dependency> 199 <dependency>
315 - <groupId>org.apache</groupId>  
316 - <artifactId>cxf</artifactId>  
317 - <version>2.3.2</version>  
318 - <scope>system</scope>  
319 - <systemPath>${project.basedir}/lib/cxf-2.3.2.jar</systemPath>  
320 - </dependency>  
321 - <dependency>  
322 - <groupId>org.apache.cxf</groupId>  
323 - <artifactId>xjc</artifactId>  
324 - <version>2.3.2</version>  
325 - <scope>system</scope>  
326 - <systemPath>${project.basedir}/lib/cxf-xjc-bug671-2.3.2.jar</systemPath>  
327 - </dependency>  
328 - <dependency>  
329 - <groupId>maven.org.apache</groupId>  
330 - <artifactId>cxf</artifactId>  
331 - <version>2.0</version>  
332 - <scope>system</scope>  
333 - <systemPath>${project.basedir}/lib/cxf-manifest.jar</systemPath>  
334 - </dependency>  
335 - <dependency>  
336 - <groupId>org.apache.cxf.xjc</groupId>  
337 - <artifactId>dv</artifactId>  
338 - <version>2.3.2</version>  
339 - <scope>system</scope>  
340 - <systemPath>${project.basedir}/lib/cxf-xjc-dv-2.3.2.jar</systemPath>  
341 - </dependency>  
342 - <dependency>  
343 - <groupId>org.apache.cxf.xjc</groupId>  
344 - <artifactId>ts</artifactId>  
345 - <version>2.3.2</version>  
346 - <scope>system</scope>  
347 - <systemPath>${project.basedir}/lib/cxf-xjc-ts-2.3.2.jar</systemPath>  
348 - </dependency>  
349 - <dependency>  
350 - <groupId>org.apache.xml</groupId>  
351 - <artifactId>xmlsec</artifactId>  
352 - <version>1.4.4</version>  
353 - <scope>system</scope>  
354 - <systemPath>${project.basedir}/lib/xmlsec-1.4.4.jar</systemPath>  
355 - </dependency>  
356 - <dependency>  
357 - <groupId>com.ibm.disthub2.impl</groupId>  
358 - <artifactId>cl3e</artifactId>  
359 - <version>1.0.0</version>  
360 - <scope>system</scope>  
361 - <systemPath>${project.basedir}/lib/CL3Export.jar</systemPath>  
362 - </dependency>  
363 - <dependency>  
364 - <groupId>com.ibm.disthub2.impl</groupId>  
365 - <artifactId>cl3ne</artifactId>  
366 - <version>1.0.0</version>  
367 - <scope>system</scope>  
368 - <systemPath>${project.basedir}/lib/CL3Nonexport.jar</systemPath>  
369 - </dependency>  
370 - <dependency>  
371 - <groupId>com.ibm.mq</groupId>  
372 - <artifactId>axis2</artifactId>  
373 - <version>1.0.0</version>  
374 - <scope>system</scope>  
375 - <systemPath>${project.basedir}/lib/com.ibm.mq.axis2.jar</systemPath>  
376 - </dependency>  
377 - <dependency>  
378 - <groupId>com.ibm.mq</groupId>  
379 - <artifactId>commonservices</artifactId>  
380 - <version>1.0.0</version>  
381 - <scope>system</scope>  
382 - <systemPath>${project.basedir}/lib/com.ibm.mq.commonservices.jar</systemPath>  
383 - </dependency>  
384 - <dependency>  
385 - <groupId>com.ibm.mq</groupId>  
386 - <artifactId>defaultconfig</artifactId>  
387 - <version>1.0.0</version>  
388 - <scope>system</scope>  
389 - <systemPath>${project.basedir}/lib/com.ibm.mq.defaultconfig.jar</systemPath>  
390 - </dependency>  
391 - <dependency>  
392 - <groupId>com.ibm.mq</groupId>  
393 - <artifactId>fta</artifactId>  
394 - <version>1.0.0</version>  
395 - <scope>system</scope>  
396 - <systemPath>${project.basedir}/lib/com.ibm.mq.fta.jar</systemPath>  
397 - </dependency>  
398 - <dependency>  
399 - <groupId>com.ibm.mq</groupId>  
400 - <artifactId>headers</artifactId>  
401 - <version>1.0.0</version>  
402 - <scope>system</scope>  
403 - <systemPath>${project.basedir}/lib/com.ibm.mq.headers.jar</systemPath>  
404 - </dependency>  
405 - <dependency>  
406 - <groupId>com.ibm</groupId>  
407 - <artifactId>mq</artifactId>  
408 - <version>1.0.0</version>  
409 - <scope>system</scope>  
410 - <systemPath>${project.basedir}/lib/com.ibm.mq.jar</systemPath>  
411 - </dependency>  
412 - <dependency>  
413 - <groupId>com.ibm</groupId>  
414 - <artifactId>jmqi</artifactId>  
415 - <version>1.0.0</version>  
416 - <scope>system</scope>  
417 - <systemPath>${project.basedir}/lib/com.ibm.mq.jmqi.jar</systemPath>  
418 - </dependency>  
419 - <dependency>  
420 - <groupId>com.ibm.mq</groupId>  
421 - <artifactId>jms.nojndi</artifactId>  
422 - <version>1.0.0</version>  
423 - <scope>system</scope>  
424 - <systemPath>${project.basedir}/lib/com.ibm.mq.jms.Nojndi.jar</systemPath>  
425 - </dependency>  
426 - <dependency>  
427 - <groupId>com.ibm.mq</groupId>  
428 - <artifactId>pcf</artifactId>  
429 - <version>1.0.0</version>  
430 - <scope>system</scope>  
431 - <systemPath>${project.basedir}/lib/com.ibm.mq.pcf.jar</systemPath>  
432 - </dependency>  
433 - <dependency>  
434 - <groupId>com.ibm.mq</groupId>  
435 - <artifactId>postcard</artifactId>  
436 - <version>1.0.0</version>  
437 - <scope>system</scope>  
438 - <systemPath>${project.basedir}/lib/com.ibm.mq.postcard.jar</systemPath>  
439 - </dependency>  
440 - <dependency>  
441 - <groupId>com.ibm.mq</groupId>  
442 - <artifactId>soap</artifactId>  
443 - <version>1.0.0</version>  
444 - <scope>system</scope>  
445 - <systemPath>${project.basedir}/lib/com.ibm.mq.soap.jar</systemPath>  
446 - </dependency>  
447 - <dependency>  
448 - <groupId>com.ibm.mq</groupId>  
449 - <artifactId>tools.ras</artifactId>  
450 - <version>1.0.0</version>  
451 - <scope>system</scope>  
452 - <systemPath>${project.basedir}/lib/com.ibm.mq.tools.ras.jar</systemPath>  
453 - </dependency>  
454 - <dependency>  
455 - <groupId>com.ibm.mq</groupId>  
456 - <artifactId>etclient</artifactId>  
457 - <version>1.0.0</version>  
458 - <scope>system</scope>  
459 - <systemPath>${project.basedir}/lib/com.ibm.mqetclient.jar</systemPath>  
460 - </dependency>  
461 - <dependency>  
462 - <groupId>com.ibm</groupId>  
463 - <artifactId>mqjms</artifactId>  
464 - <version>1.0.0</version>  
465 - <scope>system</scope>  
466 - <systemPath>${project.basedir}/lib/com.ibm.mqjms.jar</systemPath>  
467 - <!-- https://mvnrepository.com/artifact/javax.resource/connector -->  
468 - </dependency>  
469 - <dependency>  
470 - <groupId>javax.resource</groupId>  
471 - <artifactId>connector</artifactId>  
472 - <version>1.0</version>  
473 - <scope>system</scope>  
474 - <systemPath>${project.basedir}/lib/connector.jar</systemPath> 200 + <groupId>org.springframework.boot</groupId>
  201 + <artifactId>spring-boot-starter-data-redis</artifactId>
475 </dependency> 202 </dependency>
476 203
477 </dependencies> 204 </dependencies>
@@ -6,16 +6,14 @@ package com.tianbo.warehouse; @@ -6,16 +6,14 @@ package com.tianbo.warehouse;
6 6
7 import org.mybatis.spring.annotation.MapperScan; 7 import org.mybatis.spring.annotation.MapperScan;
8 import org.springframework.boot.SpringApplication; 8 import org.springframework.boot.SpringApplication;
9 -import org.springframework.boot.autoconfigure.EnableAutoConfiguration;  
10 import org.springframework.boot.autoconfigure.SpringBootApplication; 9 import org.springframework.boot.autoconfigure.SpringBootApplication;
11 -import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;  
12 import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 10 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
13 import org.springframework.scheduling.annotation.EnableScheduling; 11 import org.springframework.scheduling.annotation.EnableScheduling;
14 import org.springframework.transaction.annotation.EnableTransactionManagement; 12 import org.springframework.transaction.annotation.EnableTransactionManagement;
15 13
16 @SpringBootApplication 14 @SpringBootApplication
17 @EnableScheduling 15 @EnableScheduling
18 -//@EnableEurekaClient 16 +@EnableEurekaClient
19 @EnableTransactionManagement 17 @EnableTransactionManagement
20 @MapperScan("com.tianbo.warehouse.dao") 18 @MapperScan("com.tianbo.warehouse.dao")
21 public class WarehouseApplication { 19 public class WarehouseApplication {
  1 +package com.tianbo.warehouse.controller;
  2 +
  3 +import com.tianbo.warehouse.controller.response.ResultJson;
  4 +import com.tianbo.warehouse.model.SysDept;
  5 +import com.tianbo.warehouse.service.SysDeptService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.*;
  8 +
  9 +/**
  10 + * @author
  11 + * @time 2019-12-18 11:39
  12 + */
  13 +@RestController
  14 +@RequestMapping("/dept")
  15 +public class DeptController {
  16 +
  17 + @Autowired
  18 + SysDeptService sysDeptService;
  19 +
  20 + @GetMapping("/list")
  21 + public ResultJson findAllDept(){
  22 + ResultJson resultJson = new ResultJson();
  23 + resultJson.setData(sysDeptService.findAllDept());
  24 + resultJson.setMsg("success");
  25 + resultJson.setCode("1");
  26 + return resultJson;
  27 + }
  28 +
  29 + @PostMapping("/add")
  30 + public ResultJson addDept(@RequestBody SysDept sysDept){
  31 + ResultJson resultJson = new ResultJson();
  32 + int count = sysDeptService.insertSelective(sysDept);
  33 + if(count >0){
  34 + resultJson.setMsg("新增成功");
  35 + resultJson.setCode("1");
  36 + }else {
  37 + resultJson.setMsg("新增失败,请稍后重试");
  38 + resultJson.setCode("0");
  39 + }
  40 + return resultJson;
  41 + }
  42 +
  43 + @PutMapping("/edit")
  44 + public ResultJson updateDept(@RequestBody SysDept sysDept){
  45 + ResultJson resultJson = new ResultJson();
  46 + int count = sysDeptService.updateByPrimaryKeySelective(sysDept);
  47 + if(count >0){
  48 + resultJson.setMsg("更新成功");
  49 + resultJson.setCode("1");
  50 + }else {
  51 + resultJson.setMsg("更新失败,请稍后重试");
  52 + resultJson.setCode("0");
  53 + }
  54 + return resultJson;
  55 + }
  56 +
  57 + @DeleteMapping("/del")
  58 + public ResultJson updateDept(@RequestParam Integer id){
  59 + ResultJson resultJson = new ResultJson();
  60 + int count = sysDeptService.deleteByPrimaryKey(id);
  61 + if(count >0){
  62 + resultJson.setMsg("删除成功");
  63 + resultJson.setCode("1");
  64 + }else {
  65 + resultJson.setMsg("删除失败,请稍后重试");
  66 + resultJson.setCode("0");
  67 + }
  68 + return resultJson;
  69 + }
  70 +}
@@ -3,20 +3,15 @@ package com.tianbo.warehouse.controller; @@ -3,20 +3,15 @@ package com.tianbo.warehouse.controller;
3 import com.github.pagehelper.PageInfo; 3 import com.github.pagehelper.PageInfo;
4 import com.tianbo.warehouse.annotation.LogAnnotation; 4 import com.tianbo.warehouse.annotation.LogAnnotation;
5 import com.tianbo.warehouse.controller.response.ResultJson; 5 import com.tianbo.warehouse.controller.response.ResultJson;
6 -import com.tianbo.warehouse.dao.PERMISSIONMapper;  
7 import com.tianbo.warehouse.model.PERMISSION; 6 import com.tianbo.warehouse.model.PERMISSION;
8 -import com.tianbo.warehouse.model.ROLE;  
9 import com.tianbo.warehouse.service.PermissionService; 7 import com.tianbo.warehouse.service.PermissionService;
10 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
11 -import org.springframework.security.core.context.SecurityContextHolder;  
12 -import org.springframework.security.core.userdetails.UserDetails;  
13 import org.springframework.web.bind.annotation.*; 9 import org.springframework.web.bind.annotation.*;
14 10
15 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletRequest;
16 import javax.servlet.http.HttpServletResponse; 12 import javax.servlet.http.HttpServletResponse;
17 import javax.validation.Valid; 13 import javax.validation.Valid;
18 import java.util.List; 14 import java.util.List;
19 -import java.util.Map;  
20 15
21 16
22 @RestController() 17 @RestController()
@@ -94,4 +89,16 @@ public class PermssionController { @@ -94,4 +89,16 @@ public class PermssionController {
94 } 89 }
95 return resultJson; 90 return resultJson;
96 } 91 }
  92 + @LogAnnotation(moduleName = "权限管理",operate = "权限批量删除")
  93 + @GetMapping("/findByRoleId")
  94 + public ResultJson findByRoleId(@RequestParam Integer roleId){
  95 +
  96 + ResultJson resultJson = new ResultJson();
  97 +
  98 + List<PERMISSION> list = permissionService.findByRoleId(roleId);
  99 + resultJson.setData(list);
  100 + resultJson.setCode("1");
  101 + resultJson.setMsg("SUCCESS");
  102 + return resultJson;
  103 + }
97 } 104 }
@@ -20,6 +20,7 @@ public class RoleController { @@ -20,6 +20,7 @@ public class RoleController {
20 @Autowired 20 @Autowired
21 RoleService roleService; 21 RoleService roleService;
22 22
  23 +
23 @GetMapping("/list") 24 @GetMapping("/list")
24 public PageInfo<ROLE> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1") 25 public PageInfo<ROLE> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
25 int pageNum, 26 int pageNum,
@@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.*; @@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.*;
21 import javax.servlet.http.HttpServletRequest; 21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse; 22 import javax.servlet.http.HttpServletResponse;
23 import javax.validation.Valid; 23 import javax.validation.Valid;
  24 +import java.util.List;
  25 +import java.util.Map;
24 26
25 @RestController 27 @RestController
26 @RequestMapping("/user") 28 @RequestMapping("/user")
@@ -97,8 +99,12 @@ public class UserController { @@ -97,8 +99,12 @@ public class UserController {
97 } 99 }
98 100
99 @PutMapping("/roleset") 101 @PutMapping("/roleset")
100 - public ResultJson roleSet(@RequestBody UserRole userRole){  
101 - 102 + public ResultJson roleSet(@RequestBody Map<String,Object> map){
  103 + Integer id = (Integer) map.get("id");
  104 + List<Integer> roles = (List<Integer>) map.get("setRole");
  105 + UserRole userRole = new UserRole();
  106 + userRole.setUserId(id);
  107 + userRole.setRoleIds(roles);
102 int i = userService.setUserRole(userRole); 108 int i = userService.setUserRole(userRole);
103 109
104 return i==1 ? new ResultJson("200","设置角色成功") :new ResultJson("500","设置角色失败"); 110 return i==1 ? new ResultJson("200","设置角色成功") :new ResultJson("500","设置角色失败");
@@ -3,7 +3,6 @@ package com.tianbo.warehouse.dao; @@ -3,7 +3,6 @@ package com.tianbo.warehouse.dao;
3 import com.tianbo.warehouse.model.PERMISSION; 3 import com.tianbo.warehouse.model.PERMISSION;
4 import org.apache.ibatis.annotations.Param; 4 import org.apache.ibatis.annotations.Param;
5 5
6 -import java.math.BigDecimal;  
7 import java.util.List; 6 import java.util.List;
8 7
9 public interface PERMISSIONMapper { 8 public interface PERMISSIONMapper {
@@ -25,7 +24,9 @@ public interface PERMISSIONMapper { @@ -25,7 +24,9 @@ public interface PERMISSIONMapper {
25 24
26 List<PERMISSION> findByUserId(Integer userId); 25 List<PERMISSION> findByUserId(Integer userId);
27 26
  27 + List<PERMISSION> findByRoleId(Integer roleId);
  28 +
28 List<String> findRoleListByUrl(String permissionUrl); 29 List<String> findRoleListByUrl(String permissionUrl);
29 30
30 List<PERMISSION> getRolePermisson(Integer roleId); 31 List<PERMISSION> getRolePermisson(Integer roleId);
31 -}  
  32 +}
  1 +package com.tianbo.warehouse.dao;
  2 +
  3 +import com.tianbo.warehouse.model.SysDept;
  4 +import org.springframework.stereotype.Component;
  5 +
  6 +import java.util.List;
  7 +
  8 +@Component
  9 +public interface SysDeptMapper {
  10 + int deleteByPrimaryKey(Integer id);
  11 +
  12 + int insert(SysDept record);
  13 +
  14 + int insertSelective(SysDept record);
  15 +
  16 + SysDept selectByPrimaryKey(Integer id);
  17 +
  18 + int updateByPrimaryKeySelective(SysDept record);
  19 +
  20 + int updateByPrimaryKey(SysDept record);
  21 +
  22 + List<SysDept> findAllDept();
  23 +}
  1 +package com.tianbo.warehouse.model;
  2 +
  3 +import java.util.Date;
  4 +import java.util.List;
  5 +
  6 +public class SysDept {
  7 + private Integer id;
  8 +
  9 + private Integer pid;
  10 +
  11 + private String deptname;
  12 +
  13 + private String deptdesc;
  14 +
  15 + private String depttype;
  16 +
  17 + private Boolean isroot;
  18 +
  19 + private String createby;
  20 +
  21 + private Date createtime;
  22 +
  23 + private String updateby;
  24 +
  25 + private Date updatetme;
  26 +
  27 + private Boolean isdelete;
  28 +
  29 + private String remark;
  30 +
  31 + private String remark1;
  32 +
  33 + private List<SysDept> children;
  34 +
  35 + public Integer getId() {
  36 + return id;
  37 + }
  38 +
  39 + public void setId(Integer id) {
  40 + this.id = id;
  41 + }
  42 +
  43 + public Integer getPid() {
  44 + return pid;
  45 + }
  46 +
  47 + public void setPid(Integer pid) {
  48 + this.pid = pid;
  49 + }
  50 +
  51 + public String getDeptname() {
  52 + return deptname;
  53 + }
  54 +
  55 + public void setDeptname(String deptname) {
  56 + this.deptname = deptname == null ? null : deptname.trim();
  57 + }
  58 +
  59 + public String getDeptdesc() {
  60 + return deptdesc;
  61 + }
  62 +
  63 + public void setDeptdesc(String deptdesc) {
  64 + this.deptdesc = deptdesc == null ? null : deptdesc.trim();
  65 + }
  66 +
  67 + public String getDepttype() {
  68 + return depttype;
  69 + }
  70 +
  71 + public void setDepttype(String depttype) {
  72 + this.depttype = depttype == null ? null : depttype.trim();
  73 + }
  74 +
  75 + public Boolean getIsroot() {
  76 + return isroot;
  77 + }
  78 +
  79 + public void setIsroot(Boolean isroot) {
  80 + this.isroot = isroot;
  81 + }
  82 +
  83 + public String getCreateby() {
  84 + return createby;
  85 + }
  86 +
  87 + public void setCreateby(String createby) {
  88 + this.createby = createby == null ? null : createby.trim();
  89 + }
  90 +
  91 + public Date getCreatetime() {
  92 + return createtime;
  93 + }
  94 +
  95 + public void setCreatetime(Date createtime) {
  96 + this.createtime = createtime;
  97 + }
  98 +
  99 + public String getUpdateby() {
  100 + return updateby;
  101 + }
  102 +
  103 + public void setUpdateby(String updateby) {
  104 + this.updateby = updateby == null ? null : updateby.trim();
  105 + }
  106 +
  107 + public Date getUpdatetme() {
  108 + return updatetme;
  109 + }
  110 +
  111 + public void setUpdatetme(Date updatetme) {
  112 + this.updatetme = updatetme;
  113 + }
  114 +
  115 + public Boolean getIsdelete() {
  116 + return isdelete;
  117 + }
  118 +
  119 + public void setIsdelete(Boolean isdelete) {
  120 + this.isdelete = isdelete;
  121 + }
  122 +
  123 + public String getRemark() {
  124 + return remark;
  125 + }
  126 +
  127 + public void setRemark(String remark) {
  128 + this.remark = remark == null ? null : remark.trim();
  129 + }
  130 +
  131 + public String getRemark1() {
  132 + return remark1;
  133 + }
  134 +
  135 + public void setRemark1(String remark1) {
  136 + this.remark1 = remark1 == null ? null : remark1.trim();
  137 + }
  138 +
  139 + public List<SysDept> getChildren() {
  140 + return children;
  141 + }
  142 +
  143 + public void setChildren(List<SysDept> children) {
  144 + this.children = children;
  145 + }
  146 +}
@@ -21,7 +21,8 @@ public class UserRole { @@ -21,7 +21,8 @@ public class UserRole {
21 21
22 public UserRole(){ 22 public UserRole(){
23 } 23 }
24 - public UserRole(Integer userId,Integer roleId){ 24 + public UserRole(Integer id,Integer userId,Integer roleId){
  25 + this.id = id;
25 this.roleId=roleId; 26 this.roleId=roleId;
26 this.userId = userId; 27 this.userId = userId;
27 } 28 }
  1 +package com.tianbo.warehouse.security;
  2 +
  3 +import org.springframework.security.authentication.AnonymousAuthenticationToken;
  4 +import org.springframework.security.core.Authentication;
  5 +import org.springframework.security.core.context.SecurityContextHolder;
  6 +
  7 +/**
  8 + * @author
  9 + * @time 2019-12-18 15:25
  10 + */
  11 +public class getUserNameForSecurity {
  12 +
  13 + public static String getUserName(){
  14 + Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
  15 + if (!(authentication instanceof AnonymousAuthenticationToken)) {
  16 + String currentUserName = authentication.getName();
  17 + return currentUserName;
  18 + }
  19 + return null;
  20 + }
  21 +
  22 +}
@@ -10,6 +10,10 @@ public interface PermissionService { @@ -10,6 +10,10 @@ public interface PermissionService {
10 10
11 PageInfo<PERMISSION> findAll(int pageNum, int pageSize, String name); 11 PageInfo<PERMISSION> findAll(int pageNum, int pageSize, String name);
12 12
  13 + List<PERMISSION> findByRoleId(Integer roleId);
  14 +
  15 + List<PERMISSION> getPermissionList(List<PERMISSION> permissions, Integer pid);
  16 +
13 int insertSelective(PERMISSION record); 17 int insertSelective(PERMISSION record);
14 18
15 /** 19 /**
  1 +package com.tianbo.warehouse.service;
  2 +
  3 +import com.tianbo.warehouse.model.SysDept;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * @author
  9 + * @time 2019-12-18 11:22
  10 + */
  11 +public interface SysDeptService {
  12 +
  13 + int deleteByPrimaryKey(Integer id);
  14 +
  15 + int insertSelective(SysDept sysDept);
  16 +
  17 + SysDept selectByPrimaryKey(Integer id);
  18 +
  19 + int updateByPrimaryKeySelective(SysDept sysDept);
  20 +
  21 + List<SysDept> findAllDept();
  22 +}
@@ -5,51 +5,70 @@ import com.github.pagehelper.PageHelper; @@ -5,51 +5,70 @@ import com.github.pagehelper.PageHelper;
5 import com.github.pagehelper.PageInfo; 5 import com.github.pagehelper.PageInfo;
6 import com.tianbo.warehouse.dao.PERMISSIONMapper; 6 import com.tianbo.warehouse.dao.PERMISSIONMapper;
7 import com.tianbo.warehouse.model.PERMISSION; 7 import com.tianbo.warehouse.model.PERMISSION;
8 -import com.tianbo.warehouse.model.ROLE;  
9 import com.tianbo.warehouse.service.PermissionService; 8 import com.tianbo.warehouse.service.PermissionService;
10 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
12 11
13 -import java.util.*; 12 +import java.util.ArrayList;
  13 +import java.util.HashMap;
  14 +import java.util.List;
  15 +import java.util.Map;
14 16
15 @Service("PermissionService") 17 @Service("PermissionService")
16 -public class PermissionServiceImp implements PermissionService{ 18 +public class PermissionServiceImp implements PermissionService {
17 19
18 @Autowired 20 @Autowired
19 PERMISSIONMapper permissionMapper; 21 PERMISSIONMapper permissionMapper;
20 22
21 @Override 23 @Override
22 - public PageInfo<PERMISSION> findAll(int pageNum, int pageSize, String name){  
23 - Page<PERMISSION> page = PageHelper.startPage(pageNum,pageSize); 24 + public PageInfo<PERMISSION> findAll(int pageNum, int pageSize, String name) {
  25 + Page<PERMISSION> page = PageHelper.startPage(pageNum, pageSize);
24 List<PERMISSION> list = permissionMapper.findAll(name); 26 List<PERMISSION> list = permissionMapper.findAll(name);
25 - PageInfo<PERMISSION> result = new PageInfo<>(list); 27 + PageInfo<PERMISSION> result = new PageInfo<>(getPermissionList(list, 0));
26 return result; 28 return result;
27 } 29 }
28 30
  31 + public List<PERMISSION> findByRoleId(Integer roleId) {
  32 + List<PERMISSION> list = getPermissionList(permissionMapper.findByRoleId(roleId), 0);
  33 + return list;
  34 + }
  35 +
29 @Override 36 @Override
30 - public int insertSelective(PERMISSION record){ 37 + public int insertSelective(PERMISSION record) {
31 return permissionMapper.insertSelective(record); 38 return permissionMapper.insertSelective(record);
32 } 39 }
33 40
  41 +
  42 + public List<PERMISSION> getPermissionList(List<PERMISSION> permissions, Integer pid) {
  43 + List<PERMISSION> permissionList = new ArrayList<>();
  44 + for (PERMISSION permission : permissions) {
  45 + if (permission.getParentId().equals(pid)) {
  46 + permission.setChildren(getPermissionList(permissions, permission.getPermissionId()));
  47 + permissionList.add(permission);
  48 + }
  49 + }
  50 + return permissionList;
  51 + }
  52 +
34 @Override 53 @Override
35 - public Map<String,Object> getUserMenus(Integer userId){  
36 - Map<String,Object> data = new HashMap<String,Object>(); 54 + public Map<String, Object> getUserMenus(Integer userId) {
  55 + Map<String, Object> data = new HashMap<String, Object>();
37 try { 56 try {
38 //查询所有菜单 57 //查询所有菜单
39 List<PERMISSION> allMenu = permissionMapper.findByUserId(userId); 58 List<PERMISSION> allMenu = permissionMapper.findByUserId(userId);
40 //根节点 59 //根节点
41 List<PERMISSION> rootMenu = new ArrayList<PERMISSION>(); 60 List<PERMISSION> rootMenu = new ArrayList<PERMISSION>();
42 for (PERMISSION nav : allMenu) { 61 for (PERMISSION nav : allMenu) {
43 - if(nav.getParentId()==0){//父节点是0的,为根节点。 62 + if (nav.getParentId() == 0) {//父节点是0的,为根节点。
44 rootMenu.add(nav); 63 rootMenu.add(nav);
45 } 64 }
46 } 65 }
47 66
48 - /* 根据Menu类的order排序 */ 67 + /* 根据Menu类的order排序 */
49 // Collections.sort(rootMenu, order()); 68 // Collections.sort(rootMenu, order());
50 //为根菜单设置子菜单,getClild是递归调用的 69 //为根菜单设置子菜单,getClild是递归调用的
51 for (PERMISSION nav : rootMenu) { 70 for (PERMISSION nav : rootMenu) {
52 - /* 获取根节点下的所有子节点 使用getChild方法*/ 71 + /* 获取根节点下的所有子节点 使用getChild方法*/
53 List<PERMISSION> childList = getChild(nav.getPermissionId(), allMenu); 72 List<PERMISSION> childList = getChild(nav.getPermissionId(), allMenu);
54 nav.setChildren(childList);//给根节点设置子节点 73 nav.setChildren(childList);//给根节点设置子节点
55 } 74 }
@@ -69,17 +88,18 @@ public class PermissionServiceImp implements PermissionService{ @@ -69,17 +88,18 @@ public class PermissionServiceImp implements PermissionService{
69 88
70 /** 89 /**
71 * 获取子节点 90 * 获取子节点
72 - * @param id 父节点id 91 + *
  92 + * @param id 父节点id
73 * @param allMenu 所有菜单列表 93 * @param allMenu 所有菜单列表
74 * @return 每个根节点下,所有子菜单列表 94 * @return 每个根节点下,所有子菜单列表
75 */ 95 */
76 - public List<PERMISSION> getChild(Integer id,List<PERMISSION> allMenu){ 96 + public List<PERMISSION> getChild(Integer id, List<PERMISSION> allMenu) {
77 //子菜单 97 //子菜单
78 List<PERMISSION> childList = new ArrayList<PERMISSION>(); 98 List<PERMISSION> childList = new ArrayList<PERMISSION>();
79 for (PERMISSION nav : allMenu) { 99 for (PERMISSION nav : allMenu) {
80 // 遍历所有节点,将所有菜单的父id与传过来的根节点的id比较 100 // 遍历所有节点,将所有菜单的父id与传过来的根节点的id比较
81 //相等说明:为该根节点的子节点。 101 //相等说明:为该根节点的子节点。
82 - if(nav.getParentId().equals(id)){ 102 + if (nav.getParentId().equals(id)) {
83 childList.add(nav); 103 childList.add(nav);
84 } 104 }
85 } 105 }
@@ -89,7 +109,7 @@ public class PermissionServiceImp implements PermissionService{ @@ -89,7 +109,7 @@ public class PermissionServiceImp implements PermissionService{
89 } 109 }
90 // Collections.sort(childList,order());//排序 110 // Collections.sort(childList,order());//排序
91 //如果节点下没有子节点,返回一个空List(递归退出) 111 //如果节点下没有子节点,返回一个空List(递归退出)
92 - if(childList.size() == 0){ 112 + if (childList.size() == 0) {
93 return new ArrayList<PERMISSION>(); 113 return new ArrayList<PERMISSION>();
94 } 114 }
95 return childList; 115 return childList;
@@ -103,20 +123,19 @@ public class PermissionServiceImp implements PermissionService{ @@ -103,20 +123,19 @@ public class PermissionServiceImp implements PermissionService{
103 123
104 @Override 124 @Override
105 public int deleteByPrimaryKey(String permissionId) { 125 public int deleteByPrimaryKey(String permissionId) {
106 - if (permissionId.contains(",")){ 126 + if (permissionId.contains(",")) {
107 try { 127 try {
108 String[] split = permissionId.split(","); 128 String[] split = permissionId.split(",");
109 - for (int i=0; i<split.length; i++){ 129 + for (int i = 0; i < split.length; i++) {
110 permissionMapper.deleteByPrimaryKey(Integer.valueOf(split[i])); 130 permissionMapper.deleteByPrimaryKey(Integer.valueOf(split[i]));
111 } 131 }
112 System.out.println(); 132 System.out.println();
113 return 1; 133 return 1;
114 - }catch (Exception e){ 134 + } catch (Exception e) {
115 e.printStackTrace(); 135 e.printStackTrace();
116 return 0; 136 return 0;
117 } 137 }
118 - }else {  
119 - 138 + } else {
120 return permissionMapper.deleteByPrimaryKey(Integer.valueOf(permissionId)); 139 return permissionMapper.deleteByPrimaryKey(Integer.valueOf(permissionId));
121 } 140 }
122 } 141 }
@@ -9,14 +9,12 @@ import com.tianbo.warehouse.dao.RolePermissionMapper; @@ -9,14 +9,12 @@ import com.tianbo.warehouse.dao.RolePermissionMapper;
9 import com.tianbo.warehouse.model.Department; 9 import com.tianbo.warehouse.model.Department;
10 import com.tianbo.warehouse.model.ROLE; 10 import com.tianbo.warehouse.model.ROLE;
11 import com.tianbo.warehouse.model.RolePermission; 11 import com.tianbo.warehouse.model.RolePermission;
12 -import com.tianbo.warehouse.service.DepartmentService; 12 +import com.tianbo.warehouse.service.PermissionService;
13 import com.tianbo.warehouse.service.RoleService; 13 import com.tianbo.warehouse.service.RoleService;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
16 import org.springframework.transaction.annotation.Transactional; 16 import org.springframework.transaction.annotation.Transactional;
17 -import org.springframework.util.StringUtils;  
18 17
19 -import java.util.ArrayList;  
20 import java.util.List; 18 import java.util.List;
21 19
22 @Service(value = "roleService") 20 @Service(value = "roleService")
@@ -31,12 +29,17 @@ public class RoleServiceImp implements RoleService{ @@ -31,12 +29,17 @@ public class RoleServiceImp implements RoleService{
31 @Autowired 29 @Autowired
32 DepartmentMapper departmentMapper; 30 DepartmentMapper departmentMapper;
33 31
  32 + @Autowired
  33 + PermissionService permissionService;
  34 +
34 @Override 35 @Override
35 public PageInfo<ROLE> findAll(int pageNum, int pageSize, String roleName){ 36 public PageInfo<ROLE> findAll(int pageNum, int pageSize, String roleName){
36 Page<ROLE> page = PageHelper.startPage(pageNum,pageSize); 37 Page<ROLE> page = PageHelper.startPage(pageNum,pageSize);
37 List<ROLE> list = roleMapper.findAll(roleName); 38 List<ROLE> list = roleMapper.findAll(roleName);
38 -  
39 for (ROLE role: list){ 39 for (ROLE role: list){
  40 + if(role.getPermissions().size()>1){
  41 + role.setPermissions(permissionService.getPermissionList(role.getPermissions(),0));
  42 + }
40 Department department = departmentMapper.selectByPrimaryKey(role.getDepartmentId()); 43 Department department = departmentMapper.selectByPrimaryKey(role.getDepartmentId());
41 if (department == null){ 44 if (department == null){
42 role.setDepartmentName("无"); 45 role.setDepartmentName("无");
  1 +package com.tianbo.warehouse.service.imp;
  2 +
  3 +import com.tianbo.warehouse.dao.SysDeptMapper;
  4 +import com.tianbo.warehouse.model.SysDept;
  5 +import com.tianbo.warehouse.security.getUserNameForSecurity;
  6 +import com.tianbo.warehouse.service.SysDeptService;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +import org.springframework.transaction.annotation.Transactional;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.Date;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * @author
  17 + * @time 2019-12-18 11:41
  18 + */
  19 +@Service
  20 +public class SysDeptServiceImpl implements SysDeptService {
  21 +
  22 + @Autowired
  23 + SysDeptMapper sysDeptMapper;
  24 +
  25 +
  26 + @Override
  27 + @Transactional
  28 + public int deleteByPrimaryKey(Integer id) {
  29 + return sysDeptMapper.deleteByPrimaryKey(id);
  30 + }
  31 +
  32 + @Override
  33 + @Transactional
  34 + public int insertSelective(SysDept sysDept) {
  35 + sysDept.setUpdatetme(new Date());
  36 + sysDept.setUpdateby(getUserNameForSecurity.getUserName());
  37 + sysDept.setCreatetime(new Date());
  38 + sysDept.setCreateby(getUserNameForSecurity.getUserName());
  39 + return sysDeptMapper.insertSelective(sysDept);
  40 + }
  41 +
  42 + @Override
  43 + public SysDept selectByPrimaryKey(Integer id) {
  44 + return sysDeptMapper.selectByPrimaryKey(id);
  45 + }
  46 +
  47 + @Override
  48 + @Transactional
  49 + public int updateByPrimaryKeySelective(SysDept sysDept) {
  50 + sysDept.setUpdatetme(new Date());
  51 + sysDept.setCreateby(getUserNameForSecurity.getUserName());
  52 + return sysDeptMapper.updateByPrimaryKeySelective(sysDept);
  53 + }
  54 +
  55 + @Override
  56 + public List<SysDept> findAllDept() {
  57 + return childrenDept(sysDeptMapper.findAllDept(),0);
  58 + }
  59 +
  60 + /**
  61 + * 获取组织机构树形结构列表
  62 + * @param list
  63 + * @param pid
  64 + * @return
  65 + */
  66 + public List<SysDept> childrenDept(List<SysDept> list,Integer pid){
  67 + List<SysDept> childrenList = new ArrayList<>();
  68 + if (list !=null && !list.isEmpty()){
  69 + for (SysDept dept: list) {
  70 + if(dept.getPid().equals(pid)){
  71 + dept.setChildren(childrenDept(list,dept.getId()));
  72 + childrenList.add(dept);
  73 + }
  74 + }
  75 + }
  76 + return childrenList;
  77 + }
  78 +}
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service; @@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
17 import org.springframework.transaction.annotation.Transactional; 17 import org.springframework.transaction.annotation.Transactional;
18 18
19 import java.util.List; 19 import java.util.List;
  20 +import java.util.Random;
20 21
21 @Service(value = "userService") 22 @Service(value = "userService")
22 public class UserServiceImpl implements UserService{ 23 public class UserServiceImpl implements UserService{
@@ -63,10 +64,13 @@ public class UserServiceImpl implements UserService{ @@ -63,10 +64,13 @@ public class UserServiceImpl implements UserService{
63 users.setRealname(realName); 64 users.setRealname(realName);
64 List<USERS> list = usersMapper.selectAllUser(users); 65 List<USERS> list = usersMapper.selectAllUser(users);
65 for (USERS user: list) { 66 for (USERS user: list) {
66 - List<PERMISSION> permissionList = permissionMapper.findByUserId(user.getUserId());  
67 - user.setPermissions(permissionList); 67 +// List<PERMISSION> permissionList = permissionMapper.findByUserId(user.getUserId());
  68 +// user.setPermissions(permissionList);
68 List<ROLE> roleList = roleMapper.findRolesByUserId(user.getUserId()); 69 List<ROLE> roleList = roleMapper.findRolesByUserId(user.getUserId());
69 user.setRoles(roleList); 70 user.setRoles(roleList);
  71 + if(user.getUserId() == 27){
  72 + System.out.println(users.getRoles());
  73 + }
70 } 74 }
71 PageInfo<USERS> result = new PageInfo<USERS>(list); 75 PageInfo<USERS> result = new PageInfo<USERS>(list);
72 return result; 76 return result;
@@ -115,7 +119,7 @@ public class UserServiceImpl implements UserService{ @@ -115,7 +119,7 @@ public class UserServiceImpl implements UserService{
115 userRoleMapper.deleteByUserId(userId); 119 userRoleMapper.deleteByUserId(userId);
116 if (null!=ids && !ids.isEmpty()){ 120 if (null!=ids && !ids.isEmpty()){
117 for (Integer id:ids) { 121 for (Integer id:ids) {
118 - UserRole ur = new UserRole(userId,id); 122 + UserRole ur = new UserRole(new Random().nextInt(10000000)+1,userId,id);
119 userRoleMapper.insertSelective(ur); 123 userRoleMapper.insertSelective(ur);
120 } 124 }
121 } 125 }
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 path, url, method, iconCls, component 20 path, url, method, iconCls, component
21 </sql> 21 </sql>
22 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 22 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
23 - select 23 + select
24 <include refid="Base_Column_List" /> 24 <include refid="Base_Column_List" />
25 from permission 25 from permission
26 where permission_id = #{permissionId,jdbcType=INTEGER} ORDER BY permission_order 26 where permission_id = #{permissionId,jdbcType=INTEGER} ORDER BY permission_order
@@ -35,12 +35,12 @@ @@ -35,12 +35,12 @@
35 ORDER BY permission_order 35 ORDER BY permission_order
36 </select> 36 </select>
37 <select id="getRolePermisson" resultMap="BaseResultMap" parameterType="java.lang.Integer"> 37 <select id="getRolePermisson" resultMap="BaseResultMap" parameterType="java.lang.Integer">
38 - SELECT P.*  
39 - FROM role R  
40 - LEFT JOIN role_permission RP ON R.role_id = RP.role_id  
41 - LEFT JOIN permission P ON RP.permission_id = P.permission_id  
42 - WHERE R.role_id=#{roleId,jdbcType=INTEGER}  
43 - ORDER BY P.ismenu,P.name,P.permission_order DESC 38 + select p.*
  39 + from permission p
  40 + left join role_permission rp on rp.permission_id = p.permission_id
  41 + left join role r on r.role_id = rp.role_id
  42 + where r.role_id=#{roleId,jdbcType=INTEGER} and r.role_id is not null
  43 + ORDER BY p.ismenu,p.name,p.permission_order DESC
44 </select> 44 </select>
45 <select id="getAllMenus" resultMap="BaseResultMap" > 45 <select id="getAllMenus" resultMap="BaseResultMap" >
46 SELECT 46 SELECT
@@ -112,6 +112,21 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order @@ -112,6 +112,21 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order
112 ) 112 )
113 ) ORDER BY permission_order 113 ) ORDER BY permission_order
114 </select> 114 </select>
  115 + <select id="findByRoleId" resultMap="BaseResultMap" parameterType="integer">
  116 + SELECT
  117 + P.*
  118 + FROM
  119 + permission P
  120 + WHERE
  121 + P.permission_id IN (
  122 + SELECT
  123 + RP.permission_id
  124 + FROM
  125 + role_permission RP
  126 + WHERE
  127 + RP.role_id= #{roleId,jdbcType=INTEGER})
  128 + ORDER BY permission_order
  129 + </select>
115 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > 130 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
116 delete from permission 131 delete from permission
117 where permission_id = #{permissionId,jdbcType=INTEGER} 132 where permission_id = #{permissionId,jdbcType=INTEGER}
@@ -121,7 +136,7 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order @@ -121,7 +136,7 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order
121 description, ismenu,hidden, parent_id, 136 description, ismenu,hidden, parent_id,
122 path, url, method, iconCls, 137 path, url, method, iconCls,
123 component) 138 component)
124 - values (#{permissionId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{permissionOrder,jdbcType=VARCHAR}, 139 + values (#{permissionId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{permissionOrder,jdbcType=VARCHAR},
125 #{description,jdbcType=VARCHAR}, #{ismenu,jdbcType=BOOLEAN},#{hidden,jdbcType=BOOLEAN},#{parentId,jdbcType=INTEGER}, 140 #{description,jdbcType=VARCHAR}, #{ismenu,jdbcType=BOOLEAN},#{hidden,jdbcType=BOOLEAN},#{parentId,jdbcType=INTEGER},
126 #{path,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{iconCls,jdbcType=VARCHAR}, 141 #{path,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{iconCls,jdbcType=VARCHAR},
127 #{component,jdbcType=VARCHAR}) 142 #{component,jdbcType=VARCHAR})
@@ -259,4 +274,4 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order @@ -259,4 +274,4 @@ where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order
259 component = #{component,jdbcType=VARCHAR} 274 component = #{component,jdbcType=VARCHAR}
260 where permission_id = #{permissionId,jdbcType=INTEGER} 275 where permission_id = #{permissionId,jdbcType=INTEGER}
261 </update> 276 </update>
262 -</mapper>  
  277 +</mapper>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.tianbo.warehouse.dao.SysDeptMapper">
  4 + <resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.SysDept">
  5 + <id column="ID" jdbcType="INTEGER" property="id" />
  6 + <result column="PID" jdbcType="INTEGER" property="pid" />
  7 + <result column="DEPTNAME" jdbcType="VARCHAR" property="deptname" />
  8 + <result column="DEPTDESC" jdbcType="VARCHAR" property="deptdesc" />
  9 + <result column="DEPTTYPE" jdbcType="VARCHAR" property="depttype" />
  10 + <result column="ISROOT" jdbcType="BIT" property="isroot" />
  11 + <result column="CREATEBY" jdbcType="VARCHAR" property="createby" />
  12 + <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
  13 + <result column="UPDATEBY" jdbcType="VARCHAR" property="updateby" />
  14 + <result column="UPDATETME" jdbcType="TIMESTAMP" property="updatetme" />
  15 + <result column="ISDELETE" jdbcType="BIT" property="isdelete" />
  16 + <result column="REMARK" jdbcType="VARCHAR" property="remark" />
  17 + <result column="REMARK1" jdbcType="VARCHAR" property="remark1" />
  18 + </resultMap>
  19 + <sql id="Base_Column_List">
  20 + ID, PID, DEPTNAME, DEPTDESC, DEPTTYPE, ISROOT, CREATEBY, CREATETIME, UPDATEBY, UPDATETME,
  21 + ISDELETE, REMARK, REMARK1
  22 + </sql>
  23 + <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  24 + select
  25 + <include refid="Base_Column_List" />
  26 + from sys_dept
  27 + where ID = #{id,jdbcType=INTEGER}
  28 + </select>
  29 + <select id="findAllDept" resultMap="BaseResultMap">
  30 + select <include refid="Base_Column_List"></include>
  31 + from sys_dept where ISDELETE = 0
  32 + </select>
  33 + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  34 + delete from sys_dept
  35 + where ID = #{id,jdbcType=INTEGER}
  36 + </delete>
  37 + <insert id="insert" parameterType="com.tianbo.warehouse.model.SysDept">
  38 + insert into sys_dept (ID, PID, DEPTNAME,
  39 + DEPTDESC, DEPTTYPE, ISROOT,
  40 + CREATEBY, CREATETIME, UPDATEBY,
  41 + UPDATETME, ISDELETE, REMARK,
  42 + REMARK1)
  43 + values (#{id,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, #{deptname,jdbcType=VARCHAR},
  44 + #{deptdesc,jdbcType=VARCHAR}, #{depttype,jdbcType=VARCHAR}, #{isroot,jdbcType=BIT},
  45 + #{createby,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, #{updateby,jdbcType=VARCHAR},
  46 + #{updatetme,jdbcType=TIMESTAMP}, #{isdelete,jdbcType=BIT}, #{remark,jdbcType=VARCHAR},
  47 + #{remark1,jdbcType=VARCHAR})
  48 + </insert>
  49 + <insert id="insertSelective" parameterType="com.tianbo.warehouse.model.SysDept">
  50 + insert into sys_dept
  51 + <trim prefix="(" suffix=")" suffixOverrides=",">
  52 + <if test="id != null">
  53 + ID,
  54 + </if>
  55 + <if test="pid != null">
  56 + PID,
  57 + </if>
  58 + <if test="deptname != null">
  59 + DEPTNAME,
  60 + </if>
  61 + <if test="deptdesc != null">
  62 + DEPTDESC,
  63 + </if>
  64 + <if test="depttype != null">
  65 + DEPTTYPE,
  66 + </if>
  67 + <if test="isroot != null">
  68 + ISROOT,
  69 + </if>
  70 + <if test="createby != null">
  71 + CREATEBY,
  72 + </if>
  73 + <if test="createtime != null">
  74 + CREATETIME,
  75 + </if>
  76 + <if test="updateby != null">
  77 + UPDATEBY,
  78 + </if>
  79 + <if test="updatetme != null">
  80 + UPDATETME,
  81 + </if>
  82 + <if test="isdelete != null">
  83 + ISDELETE,
  84 + </if>
  85 + <if test="remark != null">
  86 + REMARK,
  87 + </if>
  88 + <if test="remark1 != null">
  89 + REMARK1,
  90 + </if>
  91 + </trim>
  92 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  93 + <if test="id != null">
  94 + #{id,jdbcType=INTEGER},
  95 + </if>
  96 + <if test="pid != null">
  97 + #{pid,jdbcType=INTEGER},
  98 + </if>
  99 + <if test="deptname != null">
  100 + #{deptname,jdbcType=VARCHAR},
  101 + </if>
  102 + <if test="deptdesc != null">
  103 + #{deptdesc,jdbcType=VARCHAR},
  104 + </if>
  105 + <if test="depttype != null">
  106 + #{depttype,jdbcType=VARCHAR},
  107 + </if>
  108 + <if test="isroot != null">
  109 + #{isroot,jdbcType=BIT},
  110 + </if>
  111 + <if test="createby != null">
  112 + #{createby,jdbcType=VARCHAR},
  113 + </if>
  114 + <if test="createtime != null">
  115 + #{createtime,jdbcType=TIMESTAMP},
  116 + </if>
  117 + <if test="updateby != null">
  118 + #{updateby,jdbcType=VARCHAR},
  119 + </if>
  120 + <if test="updatetme != null">
  121 + #{updatetme,jdbcType=TIMESTAMP},
  122 + </if>
  123 + <if test="isdelete != null">
  124 + #{isdelete,jdbcType=BIT},
  125 + </if>
  126 + <if test="remark != null">
  127 + #{remark,jdbcType=VARCHAR},
  128 + </if>
  129 + <if test="remark1 != null">
  130 + #{remark1,jdbcType=VARCHAR},
  131 + </if>
  132 + </trim>
  133 + </insert>
  134 + <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.SysDept">
  135 + update sys_dept
  136 + <set>
  137 + <if test="pid != null">
  138 + PID = #{pid,jdbcType=INTEGER},
  139 + </if>
  140 + <if test="deptname != null">
  141 + DEPTNAME = #{deptname,jdbcType=VARCHAR},
  142 + </if>
  143 + <if test="deptdesc != null">
  144 + DEPTDESC = #{deptdesc,jdbcType=VARCHAR},
  145 + </if>
  146 + <if test="depttype != null">
  147 + DEPTTYPE = #{depttype,jdbcType=VARCHAR},
  148 + </if>
  149 + <if test="isroot != null">
  150 + ISROOT = #{isroot,jdbcType=BIT},
  151 + </if>
  152 + <if test="createby != null">
  153 + CREATEBY = #{createby,jdbcType=VARCHAR},
  154 + </if>
  155 + <if test="createtime != null">
  156 + CREATETIME = #{createtime,jdbcType=TIMESTAMP},
  157 + </if>
  158 + <if test="updateby != null">
  159 + UPDATEBY = #{updateby,jdbcType=VARCHAR},
  160 + </if>
  161 + <if test="updatetme != null">
  162 + UPDATETME = #{updatetme,jdbcType=TIMESTAMP},
  163 + </if>
  164 + <if test="isdelete != null">
  165 + ISDELETE = #{isdelete,jdbcType=BIT},
  166 + </if>
  167 + <if test="remark != null">
  168 + REMARK = #{remark,jdbcType=VARCHAR},
  169 + </if>
  170 + <if test="remark1 != null">
  171 + REMARK1 = #{remark1,jdbcType=VARCHAR},
  172 + </if>
  173 + </set>
  174 + where ID = #{id,jdbcType=INTEGER}
  175 + </update>
  176 + <update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.SysDept">
  177 + update sys_dept
  178 + set PID = #{pid,jdbcType=INTEGER},
  179 + DEPTNAME = #{deptname,jdbcType=VARCHAR},
  180 + DEPTDESC = #{deptdesc,jdbcType=VARCHAR},
  181 + DEPTTYPE = #{depttype,jdbcType=VARCHAR},
  182 + ISROOT = #{isroot,jdbcType=BIT},
  183 + CREATEBY = #{createby,jdbcType=VARCHAR},
  184 + CREATETIME = #{createtime,jdbcType=TIMESTAMP},
  185 + UPDATEBY = #{updateby,jdbcType=VARCHAR},
  186 + UPDATETME = #{updatetme,jdbcType=TIMESTAMP},
  187 + ISDELETE = #{isdelete,jdbcType=BIT},
  188 + REMARK = #{remark,jdbcType=VARCHAR},
  189 + REMARK1 = #{remark1,jdbcType=VARCHAR}
  190 + where ID = #{id,jdbcType=INTEGER}
  191 + </update>
  192 +</mapper>
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 id, user_id, role_id 10 id, user_id, role_id
11 </sql> 11 </sql>
12 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 12 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
13 - select 13 + select
14 <include refid="Base_Column_List" /> 14 <include refid="Base_Column_List" />
15 from user_role 15 from user_role
16 where id = #{id,jdbcType=INTEGER} 16 where id = #{id,jdbcType=INTEGER}
@@ -24,15 +24,18 @@ @@ -24,15 +24,18 @@
24 where user_id = #{userId,jdbcType=INTEGER} 24 where user_id = #{userId,jdbcType=INTEGER}
25 </delete> 25 </delete>
26 <insert id="insert" parameterType="com.tianbo.warehouse.model.UserRole" > 26 <insert id="insert" parameterType="com.tianbo.warehouse.model.UserRole" >
27 - insert into user_role (user_id, role_id 27 + insert into user_role (id,user_id, role_id
28 ) 28 )
29 - values (#{userId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER} 29 + values (#{id,jdbcType=INTEGER},#{userId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}
30 ) 30 )
31 </insert> 31 </insert>
32 <insert id="insertSelective" parameterType="com.tianbo.warehouse.model.UserRole" > 32 <insert id="insertSelective" parameterType="com.tianbo.warehouse.model.UserRole" >
33 insert into user_role 33 insert into user_role
34 <trim prefix="(" suffix=")" suffixOverrides="," > 34 <trim prefix="(" suffix=")" suffixOverrides="," >
35 - <if test="userId != null" > 35 + <if test="id != null" >
  36 + id,
  37 + </if>
  38 + <if test="userId != null" >
36 user_id, 39 user_id,
37 </if> 40 </if>
38 <if test="roleId != null" > 41 <if test="roleId != null" >
@@ -40,6 +43,9 @@ @@ -40,6 +43,9 @@
40 </if> 43 </if>
41 </trim> 44 </trim>
42 <trim prefix="values (" suffix=")" suffixOverrides="," > 45 <trim prefix="values (" suffix=")" suffixOverrides="," >
  46 + <if test="id != null" >
  47 + #{id,jdbcType=INTEGER},
  48 + </if>
43 <if test="userId != null" > 49 <if test="userId != null" >
44 #{userId,jdbcType=INTEGER}, 50 #{userId,jdbcType=INTEGER},
45 </if> 51 </if>
@@ -66,4 +72,4 @@ @@ -66,4 +72,4 @@
66 role_id = #{roleId,jdbcType=INTEGER} 72 role_id = #{roleId,jdbcType=INTEGER}
67 where id = #{id,jdbcType=INTEGER} 73 where id = #{id,jdbcType=INTEGER}
68 </update> 74 </update>
69 -</mapper>  
  75 +</mapper>