From d20541352709a4adbc20c16cedd7e925f8be0334 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Fri, 9 Aug 2019 01:57:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9D=83=E9=99=90=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lq/cms/emun/BasicsPermissionKeyEnum.java | 41 +++++++++++++++++++ src/main/java/com/lq/cms/mode/Ztree.java | 1 - .../java/com/lq/cms/mode/ZtreeComposite.java | 20 ++++++--- src/main/java/com/lq/cms/mode/ZtreeItem.java | 10 ++++- .../service/impl/SysResourceServiceImpl.java | 2 +- .../SysRoleResourcePermissionServiceImpl.java | 12 +++--- .../lq/cms/web/sys/PermissionController.java | 1 + .../java/com/lq/dao/SysPermissionDao.java | 19 ++++++++- .../mybatis/mapping/SysPermissionDao.xml | 9 ++++ .../views/jsp/cms/sys/permission/edit.jsp | 2 +- .../views/jsp/cms/sys/permission/index.jsp | 16 ++++---- 11 files changed, 109 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/lq/cms/emun/BasicsPermissionKeyEnum.java diff --git a/src/main/java/com/lq/cms/emun/BasicsPermissionKeyEnum.java b/src/main/java/com/lq/cms/emun/BasicsPermissionKeyEnum.java new file mode 100644 index 0000000..0da4d33 --- /dev/null +++ b/src/main/java/com/lq/cms/emun/BasicsPermissionKeyEnum.java @@ -0,0 +1,41 @@ +package com.lq.cms.emun; + +/** + * @Author: qi + * @Description: + * @Date: Create in 1:25 PM 2019/8/8 + */ +public enum BasicsPermissionKeyEnum { + + SELECT_MENU_KEY("SELECT_MENU_KEY","查看菜单"), + SELECT_DATA_KEY("SELECT_DATA_KEY","查询全部数据"), + INSERT_KEY("INSERT_KEY","新增数据权限"), + UPDATE_key("UPDATE_key","更新数据权限"), + DELETE_KEY("DELETE_KEY","删除数据权限") + ; + + BasicsPermissionKeyEnum(String value, String desc) { + this.value = value; + this.desc = desc; + } + + private String value; + + private String desc; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/src/main/java/com/lq/cms/mode/Ztree.java b/src/main/java/com/lq/cms/mode/Ztree.java index 3705e2d..f1dc566 100755 --- a/src/main/java/com/lq/cms/mode/Ztree.java +++ b/src/main/java/com/lq/cms/mode/Ztree.java @@ -5,5 +5,4 @@ package com.lq.cms.mode; */ public class Ztree extends ZtreeComposite { - } diff --git a/src/main/java/com/lq/cms/mode/ZtreeComposite.java b/src/main/java/com/lq/cms/mode/ZtreeComposite.java index 5dfae48..210f992 100755 --- a/src/main/java/com/lq/cms/mode/ZtreeComposite.java +++ b/src/main/java/com/lq/cms/mode/ZtreeComposite.java @@ -3,16 +3,26 @@ package com.lq.cms.mode; import java.util.Map; /** - * Created by qi_liang on 2018/2/3. + * @author qi + * easyUI tree菜单 数据 + * 抽象对象:节点 */ public abstract class ZtreeComposite { - + /** + * 资源ID + */ private Long id; - + /** + * 节点名称 + */ private String text; - + /** + * 是否勾选 + */ private boolean checked; - + /** + * 自定义属性(数据) + */ private Map attributes; public Long getId() { diff --git a/src/main/java/com/lq/cms/mode/ZtreeItem.java b/src/main/java/com/lq/cms/mode/ZtreeItem.java index 3aef82d..2c85fc5 100755 --- a/src/main/java/com/lq/cms/mode/ZtreeItem.java +++ b/src/main/java/com/lq/cms/mode/ZtreeItem.java @@ -7,9 +7,17 @@ import java.util.List; * Created by qi_liang on 2018/2/3. */ public class ZtreeItem extends ZtreeComposite{ - + /** + * 子节点集合 + */ public List children=new ArrayList<>(); + /** + * 节点图标 + */ private String iconCls; + /** + * 节点状态("open","closed") + */ private String state; public String getIconCls() { diff --git a/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java index 1f385e6..2770678 100755 --- a/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java @@ -52,7 +52,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl impleme @Override public List findMenusListBySysUserId(Long sysUserId, String contextPath) { - Map map=new HashMap(); + Map map=new HashMap(3); map.put("userId",sysUserId); map.put("parentId", Constant.TOP_PARENT_ID); map.put("permissionId", PermissionTyepEnum.SELECT.getValue()); diff --git a/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java index 492a26d..744544b 100755 --- a/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java @@ -1,5 +1,6 @@ package com.lq.cms.service.impl; +import com.lq.cms.emun.BasicsPermissionKeyEnum; import com.lq.cms.emun.PermissionTyepEnum; import com.lq.cms.emun.StatusTypeEnum; import com.lq.cms.mode.Ztree; @@ -48,10 +49,9 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl findZtree(Long roleId) { - Long startTime = System.currentTimeMillis(); List ztreeList=new ArrayList<>(); List resourceList=sysResourceDao.findByParentId(0L); - List permissionList=sysPermissionDao.findAll(); + for (SysResource sysResource:resourceList){ ZtreeItem ztreeItem=new ZtreeItem(); ztreeItem.setId(sysResource.getId()); @@ -59,8 +59,6 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl map=new HashMap(); - map.put(PERMISSIONID_KEY,sysResource.getId()+RESOURCE_SYMBOL+PermissionTyepEnum.SELECT.getValue()); ztreeItem.setAttributes(getAttributes(sysResource.getId(), Long.valueOf(PermissionTyepEnum.SELECT.getValue()))); List menuItmeList=sysResourceDao.findByParentId(sysResource.getId()); for (SysResource resource:menuItmeList){ @@ -70,8 +68,9 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl permissionList = sysPermissionDao.findBySysResourceId(resource.getId()); for (SysPermission sysPermission:permissionList){ - if (PermissionTyepEnum.SELECT.getValue().equals(sysPermission.getId())){ + if (BasicsPermissionKeyEnum.SELECT_MENU_KEY.getValue().equals(sysPermission.getPermissionKey())){ continue; } Ztree ztree=new Ztree(); @@ -86,7 +85,6 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl list) { //角色id Long roleId=list.get(0).getRoleId(); - Map map=new HashMap<>(); + Map map=new HashMap<>(2); map.put("roleId",roleId); map.put("state", StatusTypeEnum.STATUS_ACTIVITY_NO.getValue()); sysRoleResourcePermissionDao.updateByRoleIdAndStatus(map); diff --git a/src/main/java/com/lq/cms/web/sys/PermissionController.java b/src/main/java/com/lq/cms/web/sys/PermissionController.java index bfc0bb8..75d602c 100644 --- a/src/main/java/com/lq/cms/web/sys/PermissionController.java +++ b/src/main/java/com/lq/cms/web/sys/PermissionController.java @@ -89,6 +89,7 @@ public class PermissionController extends BaseController{ @RequestMapping("/delete") @ResponseBody public Object delete(SysPermissionVo vo){ + sysPermissionService.delete(vo.getId()); return new AjaxResult(); } diff --git a/src/main/java/com/lq/dao/SysPermissionDao.java b/src/main/java/com/lq/dao/SysPermissionDao.java index 1383fb0..d4c70d4 100755 --- a/src/main/java/com/lq/dao/SysPermissionDao.java +++ b/src/main/java/com/lq/dao/SysPermissionDao.java @@ -3,6 +3,7 @@ package com.lq.dao; import com.lq.cms.vo.SysPermissionVo; import com.lq.code.dao.BaseDao; import com.lq.entity.SysPermission; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -10,9 +11,25 @@ import java.util.List; * Created by qi on 2017-11-29. */ public interface SysPermissionDao extends BaseDao{ - + /** + * 分页查询 + * @param vo + * @return + */ List findListPage(SysPermissionVo vo); + /** + * 统计数据条数 + * @param vo + * @return + */ int count(SysPermissionVo vo); + /** + * 通过菜单ID查询相关权限 + * @param sysResourceId(菜单ID) + * @return + */ + List findBySysResourceId(@Param("sysResourceId") Long sysResourceId); + } diff --git a/src/main/resources/mybatis/mapping/SysPermissionDao.xml b/src/main/resources/mybatis/mapping/SysPermissionDao.xml index 18e6e54..7923095 100644 --- a/src/main/resources/mybatis/mapping/SysPermissionDao.xml +++ b/src/main/resources/mybatis/mapping/SysPermissionDao.xml @@ -24,6 +24,7 @@ SELECT FROM sys_permission WHERE status = 1 + ORDER BY create_time DESC,update_time DESC + + diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/edit.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/edit.jsp index 4d9ff4d..b465b69 100755 --- a/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/edit.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/edit.jsp @@ -28,7 +28,7 @@ diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/index.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/index.jsp index 21472a9..12a51ec 100755 --- a/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/index.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/index.jsp @@ -25,13 +25,14 @@ pagination :"true", columns:[[ {field:'id',title:'编号',width:50}, - {field:'name',title:'权限名称',width:200}, - {field:'permissionType',title:'权限类型',width:45}, - {field:'permissionKey',title:'权限键值',width:120}, - {field:'sysResourceName',title:'目录名称',editor:'text',width:120}, - {field:'userName',title:'创建用户',width:100}, - {field:'createTimeStr',title:'创建时间',width:150}, - {field:'updateTimeStr',title:'更新时间',width:150}, + {field:'sysResourceName',title:'目录名称',width:60}, + {field:'name',title:'权限名称',width:120}, + {field:'permissionType',title:'权限类型',width:60}, + {field:'permissionKey',title:'权限键值',width:150}, + {field:'createTimeStr',title:'创建时间',width:110}, + {field:'createUserName',title:'创建用户',width:50}, + {field:'updateTimeStr',title:'更新时间',width:110}, + {field:'updateUserName',title:'更新用户',width:50}, /* formatter 不能重复field,否则会失效**/ {field:'editId',title:'编辑',width:100,formatter:function (value,row,index) { var html="编辑  "; @@ -51,6 +52,7 @@ +