审核角色自动添加审核菜单;
审核角色禁止修改角色名称
This commit is contained in:
@@ -28,4 +28,6 @@ public interface SysMenuDao extends CrudDao<SysMenu>{
|
||||
|
||||
String getMenuCodeByFunctionId(@Param("functionId")Integer functionId, @Param("parentId")String id);
|
||||
|
||||
List<SysMenu> findSysMenuByCode(@Param("code") String code);
|
||||
|
||||
}
|
||||
@@ -103,6 +103,13 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="findSysMenuByCode" resultType="sysMenu">
|
||||
SELECT *
|
||||
FROM sys_menu a
|
||||
WHERE a.del_flag = 1
|
||||
and a.code=#{code}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.SysMenu;
|
||||
import com.nis.domain.SysRole;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.SysMenuDao;
|
||||
import com.nis.web.dao.SysRoleDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@@ -16,6 +19,8 @@ import com.nis.web.security.UserUtils;
|
||||
public class RoleService extends BaseService {
|
||||
@Autowired
|
||||
private SysRoleDao roleDao;
|
||||
@Autowired
|
||||
private SysMenuDao menuDao;
|
||||
|
||||
public List<SysRole> findAllRole() {
|
||||
return UserUtils.getRoleList();
|
||||
@@ -52,6 +57,19 @@ public class RoleService extends BaseService {
|
||||
// 更新角色与菜单关联
|
||||
roleDao.deleteRoleMenu(role);
|
||||
}
|
||||
//针对audit菜单特殊处理[判断是否存在audit权限,如果存在则不新增,如果不存在则新增]
|
||||
List<SysMenu> auditMenuList=menuDao.findSysMenuByCode("save_and_audit");
|
||||
if(!StringUtil.isEmpty(auditMenuList) //库中存在“保存并下发”权限菜单
|
||||
&& "saveAndAudit".equals(role.getName())//此角色为“保存并下发”角色
|
||||
&& !checkAuditAuth(role.getMenuList(),auditMenuList.get(0))){//此角色没有分配“保存并下发”菜单
|
||||
if(!StringUtil.isEmpty(role.getMenuList())){
|
||||
role.getMenuList().add(auditMenuList.get(0));
|
||||
}else{
|
||||
List<SysMenu> auditList=new ArrayList<>();
|
||||
auditList.add(auditMenuList.get(0));
|
||||
role.setMenuList(auditList);
|
||||
}
|
||||
}
|
||||
|
||||
if (role.getMenuList().size() > 0){
|
||||
roleDao.insertRoleMenu(role);
|
||||
@@ -80,7 +98,23 @@ public class RoleService extends BaseService {
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断角色是否为审核角色
|
||||
* true存在此角色
|
||||
* false不存在此角色
|
||||
*/
|
||||
public boolean checkAuditAuth(List<SysMenu> menuList,SysMenu menu){
|
||||
boolean flag=false;
|
||||
if(StringUtil.isEmpty(menuList)){
|
||||
return flag;
|
||||
}
|
||||
for (SysMenu sysMenu : menuList) {
|
||||
if(sysMenu.getId().equals(menu.getId())){
|
||||
flag=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,7 +103,12 @@
|
||||
<label class="col-md-3 control-label"><spring:message code="role_name"/>:</label>
|
||||
<div class="col-md-4">
|
||||
<input id="oldName" name="oldName" type="hidden" value="${role.name}">
|
||||
<c:if test="${role.name eq 'saveAndAudit'}">
|
||||
<form:input path="name" htmlEscape="false" readonly="true" maxlength="50" class="required form-control" />
|
||||
</c:if>
|
||||
<c:if test="${role.name ne 'saveAndAudit'}">
|
||||
<form:input path="name" htmlEscape="false" maxlength="50" class="required form-control" />
|
||||
</c:if>
|
||||
</div>
|
||||
<span class="help-inline"><font color="red">*</font> </span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user