bc_zhang 4 роки тому
батько
коміт
79ca75b811

+ 6 - 6
src/main/java/com/zglc/fm/aop/GlobalLog.java

@@ -43,12 +43,12 @@ public class GlobalLog {
         this.rightsService = rightsService;
     }
 
-    @Pointcut(value = "execution(public * com.zglc.tr.controller.*.get*(..)) || " +
-            "execution(public * com.zglc.tr.controller.*.add*(..)) || " +
-            "execution(public * com.zglc.tr.controller.*.edit*(..)) || " +
-            "execution(public * com.zglc.tr.controller.*.listpage*(..)) || " +
-            "execution(public * com.zglc.tr.controller.*.log*(..)) || " +
-            "execution(public * com.zglc.tr.controller.*.delete(..)) "  )
+    @Pointcut(value = "execution(public * com.zglc.fm.controller.*.get*(..)) || " +
+            "execution(public * com.zglc.fm.controller.*.add*(..)) || " +
+            "execution(public * com.zglc.fm.controller.*.edit*(..)) || " +
+            "execution(public * com.zglc.fm.controller.*.listpage*(..)) || " +
+            "execution(public * com.zglc.fm.controller.*.log*(..)) || " +
+            "execution(public * com.zglc.fm.controller.*.delete(..)) "  )
     //@Pointcut(value = "execution(public * *(..))")
     public void globalLog() {
     }

+ 1 - 1
src/main/java/com/zglc/fm/controller/RightsController.java

@@ -87,7 +87,7 @@ public class RightsController {
 	        return Result.fail();
 	}
 
-    @ApiOperation("按名称列出所有")
+    @ApiOperation("按角色列出权限")
     @ApiResponses({
             @ApiResponse(code = 0, message = "成功")
     })

+ 1 - 0
src/main/java/com/zglc/fm/entity/RightsEntity.java

@@ -49,4 +49,5 @@ public class RightsEntity implements Serializable {
 
 	@Column(name = "is_hide")
 	private Integer isHide;
+
 }

+ 47 - 40
src/main/java/com/zglc/fm/service/RightsService.java

@@ -20,23 +20,23 @@ import java.util.List;
  * @description Refactoring 1st
  *
  */
- @Service
+@Service
 public class RightsService{
 
-	private RightsDao rightsDao;
+    private RightsDao rightsDao;
 
-	private RoleDao roleDao;
+    private RoleDao roleDao;
 
     public RightsService(RightsDao rightsDao,RoleDao roleDao){
         this.roleDao = roleDao;
         this.rightsDao = rightsDao;
     }
 
-	public  List<RightsEntity> getAllRights(){return rightsDao.selectAll();}
-	
-	public RightsEntity getRights(Integer id){return rightsDao.selectByPrimaryKey(id);}
+    public  List<RightsEntity> getAllRights(){return rightsDao.selectAll();}
 
-	public RightsEntity getRightsByPath(String path)
+    public RightsEntity getRights(Integer id){return rightsDao.selectByPrimaryKey(id);}
+
+    public RightsEntity getRightsByPath(String path)
     {
         Example example = new Example(RightsEntity.class);
         example.createCriteria().andEqualTo("rightsPath", path);
@@ -55,48 +55,55 @@ public class RightsService{
             }
         }else
             flag = false;
-       return flag;
+        return flag;
     }
 
-	public Result<String> add(RightsEntity data){
+    public Result<String> add(RightsEntity data){
         data.setId(null);
         boolean flag = true;
         String msg = "";
-		int index = rightsDao.insertSelective(data);
-		if (index == 0) {
-			flag = false;
-			msg = "添加权限失败!";
-		} else {
-			msg = "添加权限成功!";
-		}
-		      
+        int index = rightsDao.insertSelective(data);
+        if (index == 0) {
+            flag = false;
+            msg = "添加权限失败!";
+        } else {
+            msg = "添加权限成功!";
+        }
+
         return Result.result(flag, msg, msg);
     }
-	
-	public Result<String> addAndCheck(RightsEntity data){
+
+    public Result<String> addAndCheck(RightsEntity data){
         boolean flag = true;
         String msg = "";
-        RightsEntity tmpData = null;
-		Example example = new Example(RightsEntity.class);
-		example.createCriteria().andEqualTo("id", data.getId());
-		tmpData = rightsDao.selectOneByExample(example);
-		if (tmpData != null) {
-			flag = false;
-			msg = "权限已存在!";
-		} else {
-			int index = rightsDao.insertSelective(data);
-			if (index == 0) {
-				flag = false;
-				msg = "添加权限失败!";
-			} else {
-				msg = "添加权限成功!";
-			}
-		}
-	
+        Example example = new Example(RightsEntity.class);
+        example.createCriteria().andEqualTo("rightsName", data.getRightsName());
+        Example example1 = new Example(RightsEntity.class);
+        example1.createCriteria().andEqualTo("rightsPath", data.getRightsPath());
+        List<RightsEntity> lst = rightsDao.selectByExample(example);
+        List<RightsEntity> lst1 = rightsDao.selectByExample(example1);
+        if (lst.size() > 0 || lst1.size() > 0 ) {
+            if (lst.size() > 0){
+                flag = false;
+                msg = "权限已存在!";
+            }else {
+                flag = false;
+                msg = "路径已存在!";
+            }
+        } else {
+            int index = rightsDao.insertSelective(data);
+            if (index == 0) {
+                flag = false;
+                msg = "添加权限失败!";
+            } else {
+                msg = "添加权限成功!";
+            }
+        }
+
         return Result.result(flag, msg, msg);
     }
-	
-	public Result<String> edit(RightsEntity data) {
+
+    public Result<String> edit(RightsEntity data) {
         boolean flag = true;
         String msg = "";
         RightsEntity tmpData = rightsDao.selectByPrimaryKey(data.getId());
@@ -114,8 +121,8 @@ public class RightsService{
         }
         return Result.result(flag, msg, msg);
     }
-	
-	public Result<String> delete(List<Integer> ids) {
+
+    public Result<String> delete(List<Integer> ids) {
         boolean flag = true;
         String msg = "";
         Iterator iter = ids.iterator();

+ 1 - 1
src/main/resources/application-dev.yml

@@ -99,7 +99,7 @@ mybatis:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     map-underscore-to-camel-case: false
   mapper-locations: classpath:mapping/*Dao.xml
-  type-aliases-package: com.zglc.tr.entity
+  type-aliases-package: com.zglc.fm.entity
 pagehelper:
   support-methods-arguments: true
   params: count=countSql

+ 1 - 1
src/main/resources/mapping/DepartmentDao.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
-<mapper namespace="com.zglc.tr.dao.DepartmentDao">
+<mapper namespace="com.zglc.fm.dao.DepartmentDao">
 
 	<!-- 可根据自己的需求,是否要使用 -->
     <resultMap type="com.zglc.fm.entity.DepartmentEntity" id="departmentMap">