更新权限模块代码

master
星期八 5 years ago
parent cad975fa31
commit d205413527
  1. 41
      src/main/java/com/lq/cms/emun/BasicsPermissionKeyEnum.java
  2. 1
      src/main/java/com/lq/cms/mode/Ztree.java
  3. 20
      src/main/java/com/lq/cms/mode/ZtreeComposite.java
  4. 10
      src/main/java/com/lq/cms/mode/ZtreeItem.java
  5. 2
      src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java
  6. 12
      src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java
  7. 1
      src/main/java/com/lq/cms/web/sys/PermissionController.java
  8. 19
      src/main/java/com/lq/dao/SysPermissionDao.java
  9. 9
      src/main/resources/mybatis/mapping/SysPermissionDao.xml
  10. 2
      src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/edit.jsp
  11. 16
      src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/index.jsp

@ -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;
}
}

@ -5,5 +5,4 @@ package com.lq.cms.mode;
*/
public class Ztree extends ZtreeComposite {
}

@ -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<String,Object> attributes;
public Long getId() {

@ -7,9 +7,17 @@ import java.util.List;
* Created by qi_liang on 2018/2/3.
*/
public class ZtreeItem extends ZtreeComposite{
/**
* 子节点集合
*/
public List<ZtreeComposite> children=new ArrayList<>();
/**
* 节点图标
*/
private String iconCls;
/**
* 节点状态("open","closed")
*/
private String state;
public String getIconCls() {

@ -52,7 +52,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResource> impleme
@Override
public List<MenusComposite> findMenusListBySysUserId(Long sysUserId, String contextPath) {
Map<String,Object> map=new HashMap();
Map<String,Object> map=new HashMap(3);
map.put("userId",sysUserId);
map.put("parentId", Constant.TOP_PARENT_ID);
map.put("permissionId", PermissionTyepEnum.SELECT.getValue());

@ -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<SysRol
@Override
public List<ZtreeComposite> findZtree(Long roleId) {
Long startTime = System.currentTimeMillis();
List<ZtreeComposite> ztreeList=new ArrayList<>();
List<SysResource> resourceList=sysResourceDao.findByParentId(0L);
List<SysPermission> permissionList=sysPermissionDao.findAll();
for (SysResource sysResource:resourceList){
ZtreeItem ztreeItem=new ZtreeItem();
ztreeItem.setId(sysResource.getId());
@ -59,8 +59,6 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl<SysRol
ztreeItem.setText(sysResource.getMenuName());
ztreeItem.setChecked(isCheck(sysResource.getId(), PermissionTyepEnum.SELECT.getValue(),roleId));
ztreeItem.setState("close");
Map<String,Object> map=new HashMap<String,Object>();
map.put(PERMISSIONID_KEY,sysResource.getId()+RESOURCE_SYMBOL+PermissionTyepEnum.SELECT.getValue());
ztreeItem.setAttributes(getAttributes(sysResource.getId(), Long.valueOf(PermissionTyepEnum.SELECT.getValue())));
List<SysResource> menuItmeList=sysResourceDao.findByParentId(sysResource.getId());
for (SysResource resource:menuItmeList){
@ -70,8 +68,9 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl<SysRol
ztreeItme1.setIconCls(resource.getMenuIco());
ztreeItme1.setChecked(isCheck(resource.getId(), PermissionTyepEnum.SELECT.getValue(),roleId));
ztreeItme1.setAttributes(getAttributes(resource.getId(),PermissionTyepEnum.SELECT.getValue()));
List<SysPermission> 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<SysRol
ztreeList.add(ztreeItem);
}
System.out.println("耗时:"+(System.currentTimeMillis()-startTime)+"(毫秒)");
return ztreeList;
}
@ -95,7 +93,7 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl<SysRol
public boolean updateRolePermission(List<SysRoleResourcePermissionVo> list) {
//角色id
Long roleId=list.get(0).getRoleId();
Map<String,Object> map=new HashMap<>();
Map<String,Object> map=new HashMap<>(2);
map.put("roleId",roleId);
map.put("state", StatusTypeEnum.STATUS_ACTIVITY_NO.getValue());
sysRoleResourcePermissionDao.updateByRoleIdAndStatus(map);

@ -89,6 +89,7 @@ public class PermissionController extends BaseController{
@RequestMapping("/delete")
@ResponseBody
public Object delete(SysPermissionVo vo){
sysPermissionService.delete(vo.getId());
return new AjaxResult();
}

@ -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<SysPermission>{
/**
* 分页查询
* @param vo
* @return
*/
List<SysPermissionVo> findListPage(SysPermissionVo vo);
/**
* 统计数据条数
* @param vo
* @return
*/
int count(SysPermissionVo vo);
/**
* 通过菜单ID查询相关权限
* @param sysResourceId菜单ID
* @return
*/
List<SysPermission> findBySysResourceId(@Param("sysResourceId") Long sysResourceId);
}

@ -24,6 +24,7 @@
SELECT <include refid="column_list"/>
FROM sys_permission
WHERE status = 1
ORDER BY create_time DESC,update_time DESC
</select>
<select id="count" resultType="int" parameterType="SysPermissionVo">
@ -32,6 +33,14 @@
WHERE status = 1
</select>
<select id="findBySysResourceId" resultType="com.lq.entity.SysPermission" parameterType="long">
SELECT <include refid="column_list"/>
FROM sys_permission
WHERE status = 1
AND sys_resource_id = #{sysResourceId}
ORDER BY create_time DESC,update_time DESC
</select>
<insert id="save" parameterType="com.lq.entity.SysPermission" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" order="AFTER" resultType="Long">

@ -28,7 +28,7 @@
<td>
<select class="easyui-combobox" id="sysResourceId" >
<c:forEach var="menu" items="${menuList}">
<option value="${menu.id}" <c:if test="${menu.id==sysResource.parentId}">selected</c:if> onclick="showUrlPath()" >${menu.menuName}</option>
<option value="${menu.id}" <c:if test="${menu.id==sysPermission.sysResourceId}">selected</c:if> >${menu.menuName}</option>
</c:forEach>
</select>
</td>

@ -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="<a href='#' onclick='openEdit(\"编辑\","+row.id+")'>编辑</a>&nbsp&nbsp";
@ -51,6 +52,7 @@
</script>
</head>
<body>
<table id="dataList"></table>
<div id="editDate"></div>
</body>

Loading…
Cancel
Save