调整 多角色 多部门 多岗位
This commit is contained in:
parent
af92e6209c
commit
2c5310ca21
|
|
@ -49,6 +49,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.6.4</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
// 用户写本地线里
|
// 用户写本地线里
|
||||||
LikeAdminThreadLocal.put("adminId", id);
|
LikeAdminThreadLocal.put("adminId", id);
|
||||||
LikeAdminThreadLocal.put("roleId", userMap.get("roleId"));
|
LikeAdminThreadLocal.put("roleIds", userMap.get("roleIds"));
|
||||||
LikeAdminThreadLocal.put("username", userMap.get("username"));
|
LikeAdminThreadLocal.put("username", userMap.get("username"));
|
||||||
LikeAdminThreadLocal.put("nickname", userMap.get("nickname"));
|
LikeAdminThreadLocal.put("nickname", userMap.get("nickname"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
package com.mdd.admin;
|
package com.mdd.admin;
|
||||||
|
|
||||||
|
import com.mdd.common.utils.ArrayUtil;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地线程
|
* 本地线程
|
||||||
|
|
@ -51,12 +57,12 @@ public class LikeAdminThreadLocal {
|
||||||
/**
|
/**
|
||||||
* 获取角色ID
|
* 获取角色ID
|
||||||
*/
|
*/
|
||||||
public static Integer getRoleId() {
|
public static List<Integer> getRoleId() {
|
||||||
String roleId = LikeAdminThreadLocal.get("roleId").toString();
|
String roleIds = LikeAdminThreadLocal.get("roleIds").toString();
|
||||||
if (roleId.equals("")) {
|
if (roleIds.equals("") || roleIds.equals("0")) {
|
||||||
return 0;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return Integer.parseInt(roleId);
|
return ArrayUtil.stringToListAsInt(roleIds, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@ package com.mdd.admin.config;
|
||||||
import cn.dev33.satoken.stp.StpInterface;
|
import cn.dev33.satoken.stp.StpInterface;
|
||||||
import com.mdd.admin.LikeAdminThreadLocal;
|
import com.mdd.admin.LikeAdminThreadLocal;
|
||||||
import com.mdd.admin.service.ISystemAuthPermService;
|
import com.mdd.admin.service.ISystemAuthPermService;
|
||||||
|
import com.mdd.common.utils.ArrayUtil;
|
||||||
import com.mdd.common.utils.RedisUtil;
|
import com.mdd.common.utils.RedisUtil;
|
||||||
import com.mdd.common.utils.StringUtil;
|
import com.mdd.common.utils.StringUtil;
|
||||||
|
import com.mdd.common.utils.ToolsUtil;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sa-Token自定义权限验证接口
|
* Sa-Token自定义权限验证接口
|
||||||
|
|
@ -29,20 +30,21 @@ public class StpInterConfig implements StpInterface {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||||
Integer roleId = LikeAdminThreadLocal.getRoleId();
|
List<Integer> roleIds = LikeAdminThreadLocal.getRoleId();
|
||||||
Object menusObj = RedisUtil.hGet(AdminConfig.backstageRolesKey, String.valueOf(roleId));
|
List<String> perms = new LinkedList<>();
|
||||||
if (StringUtil.isNull(menusObj)) {
|
|
||||||
iSystemAuthPermService.cacheRoleMenusByRoleId(roleId);
|
for (Integer roleId : roleIds) {
|
||||||
menusObj = RedisUtil.hGet(AdminConfig.backstageRolesKey, String.valueOf(roleId));
|
Object menusObj = RedisUtil.hGet(AdminConfig.backstageRolesKey, String.valueOf(roleId));
|
||||||
|
if (StringUtil.isNull(menusObj)) {
|
||||||
|
iSystemAuthPermService.cacheRoleMenusByRoleId(roleId);
|
||||||
|
menusObj = RedisUtil.hGet(AdminConfig.backstageRolesKey, String.valueOf(roleId));
|
||||||
|
}
|
||||||
|
if (StringUtil.isNotNull(menusObj)) {
|
||||||
|
perms.addAll(ArrayUtil.stringToListAsStr(menusObj.toString(), ","));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> list = new ArrayList<>();
|
return perms;
|
||||||
String[] menus = menusObj.toString().split(",");
|
|
||||||
for (String auth : menus) {
|
|
||||||
list.add(auth.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统菜单管理
|
* 系统菜单管理
|
||||||
|
|
@ -33,8 +34,8 @@ public class SystemAuthMenuController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/route")
|
@GetMapping("/route")
|
||||||
public AjaxResult<JSONArray> route() {
|
public AjaxResult<JSONArray> route() {
|
||||||
Integer roleId = LikeAdminThreadLocal.getRoleId();
|
List<Integer> roleIds = LikeAdminThreadLocal.getRoleId();
|
||||||
JSONArray lists = iSystemAuthMenuService.selectMenuByRoleId(roleId);
|
JSONArray lists = iSystemAuthMenuService.selectMenuByRoleId(roleIds);
|
||||||
return AjaxResult.success(lists);
|
return AjaxResult.success(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import com.mdd.admin.validate.system.SystemMenuCreateValidate;
|
||||||
import com.mdd.admin.validate.system.SystemMenuUpdateValidate;
|
import com.mdd.admin.validate.system.SystemMenuUpdateValidate;
|
||||||
import com.mdd.admin.vo.system.SystemAuthMenuVo;
|
import com.mdd.admin.vo.system.SystemAuthMenuVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统菜单服务接口类
|
* 系统菜单服务接口类
|
||||||
*/
|
*/
|
||||||
|
|
@ -16,7 +18,7 @@ public interface ISystemAuthMenuService {
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @return JSONArray
|
* @return JSONArray
|
||||||
*/
|
*/
|
||||||
JSONArray selectMenuByRoleId(Integer roleId);
|
JSONArray selectMenuByRoleId(List<Integer> roleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单列表
|
* 菜单列表
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ public interface ISystemAuthPermService {
|
||||||
/**
|
/**
|
||||||
* 根据角色ID获取菜单ID
|
* 根据角色ID获取菜单ID
|
||||||
*
|
*
|
||||||
* @param roleId 角色ID
|
* @param roleIds 角色ID
|
||||||
* @return List<Integer>
|
* @return List<Integer>
|
||||||
*/
|
*/
|
||||||
List<Integer> selectMenuIdsByRoleId(Integer roleId);
|
List<Integer> selectMenuIdsByRoleId(List<Integer> roleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量写入角色菜单
|
* 批量写入角色菜单
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,22 @@ import com.github.yulichang.query.MPJQueryWrapper;
|
||||||
import com.mdd.admin.config.AdminConfig;
|
import com.mdd.admin.config.AdminConfig;
|
||||||
import com.mdd.admin.service.ISystemAuthAdminService;
|
import com.mdd.admin.service.ISystemAuthAdminService;
|
||||||
import com.mdd.admin.service.ISystemAuthPermService;
|
import com.mdd.admin.service.ISystemAuthPermService;
|
||||||
import com.mdd.admin.service.ISystemAuthRoleService;
|
|
||||||
import com.mdd.admin.validate.commons.PageValidate;
|
import com.mdd.admin.validate.commons.PageValidate;
|
||||||
import com.mdd.admin.validate.system.SystemAdminCreateValidate;
|
import com.mdd.admin.validate.system.SystemAdminCreateValidate;
|
||||||
import com.mdd.admin.validate.system.SystemAdminSearchValidate;
|
import com.mdd.admin.validate.system.SystemAdminSearchValidate;
|
||||||
import com.mdd.admin.validate.system.SystemAdminUpInfoValidate;
|
import com.mdd.admin.validate.system.SystemAdminUpInfoValidate;
|
||||||
import com.mdd.admin.validate.system.SystemAdminUpdateValidate;
|
import com.mdd.admin.validate.system.SystemAdminUpdateValidate;
|
||||||
import com.mdd.admin.vo.system.*;
|
import com.mdd.admin.vo.system.*;
|
||||||
import com.mdd.common.config.GlobalConfig;
|
|
||||||
import com.mdd.common.core.PageResult;
|
import com.mdd.common.core.PageResult;
|
||||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||||
|
import com.mdd.common.entity.system.SystemAuthDept;
|
||||||
import com.mdd.common.entity.system.SystemAuthMenu;
|
import com.mdd.common.entity.system.SystemAuthMenu;
|
||||||
|
import com.mdd.common.entity.system.SystemAuthRole;
|
||||||
import com.mdd.common.exception.OperateException;
|
import com.mdd.common.exception.OperateException;
|
||||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||||
|
import com.mdd.common.mapper.system.SystemAuthDeptMapper;
|
||||||
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
|
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
|
||||||
|
import com.mdd.common.mapper.system.SystemAuthRoleMapper;
|
||||||
import com.mdd.common.utils.*;
|
import com.mdd.common.utils.*;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -44,7 +46,10 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
SystemAuthMenuMapper systemAuthMenuMapper;
|
SystemAuthMenuMapper systemAuthMenuMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ISystemAuthRoleService iSystemAuthRoleService;
|
SystemAuthDeptMapper systemAuthDeptMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SystemAuthRoleMapper systemAuthRoleMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ISystemAuthPermService iSystemAuthPermService;
|
ISystemAuthPermService iSystemAuthPermService;
|
||||||
|
|
@ -64,11 +69,9 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
|
|
||||||
MPJQueryWrapper<SystemAuthAdmin> mpjQueryWrapper = new MPJQueryWrapper<>();
|
MPJQueryWrapper<SystemAuthAdmin> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||||
mpjQueryWrapper.select("t.id,t.username,t.nickname,t.avatar," +
|
mpjQueryWrapper.select("t.id,t.username,t.nickname,t.avatar," +
|
||||||
"sd.name as dept,sr.name as role,t.is_multipoint,t.is_disable," +
|
"t.role_ids as role,t.dept_ids as dept,t.is_multipoint," +
|
||||||
"t.last_login_ip,t.last_login_time,t.create_time,t.update_time")
|
"t.is_disable,t.last_login_ip,t.last_login_time,t.create_time,t.update_time")
|
||||||
.eq("t.is_delete", 0)
|
.eq("t.is_delete", 0)
|
||||||
.leftJoin("?_system_auth_role sr ON sr.id=t.role".replace("?_", GlobalConfig.tablePrefix))
|
|
||||||
.leftJoin("?_system_auth_dept sd ON sd.id=t.dept_id".replace("?_", GlobalConfig.tablePrefix))
|
|
||||||
.orderByDesc(Arrays.asList("t.id", "t.sort"));
|
.orderByDesc(Arrays.asList("t.id", "t.sort"));
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,10 +89,31 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
for (SystemAuthAdminListedVo vo : iPage.getRecords()) {
|
for (SystemAuthAdminListedVo vo : iPage.getRecords()) {
|
||||||
if (vo.getId().equals(1)) {
|
if (vo.getId().equals(1)) {
|
||||||
vo.setRole("系统管理员");
|
vo.setRole("系统管理员");
|
||||||
|
} else {
|
||||||
|
List<String> role = new LinkedList<>();
|
||||||
|
List<Integer> roleIds = ArrayUtil.stringToListAsInt(vo.getRole(), ",");
|
||||||
|
List<SystemAuthRole> roleList = systemAuthRoleMapper.selectList(new QueryWrapper<SystemAuthRole>()
|
||||||
|
.select("id,name")
|
||||||
|
.in("id", roleIds));
|
||||||
|
for (SystemAuthRole d : roleList) {
|
||||||
|
role.add(d.getName());
|
||||||
|
}
|
||||||
|
vo.setRole(ArrayUtil.listToStringByStr(role, "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vo.getDept() == null) {
|
if (StringUtil.isNull(vo.getDept()) || vo.getDept().equals("")) {
|
||||||
vo.setDept("");
|
vo.setDept("");
|
||||||
|
} else {
|
||||||
|
List<String> dept = new LinkedList<>();
|
||||||
|
List<Integer> deptIds = ArrayUtil.stringToListAsInt(vo.getDept(), ",");
|
||||||
|
List<SystemAuthDept> deptList = systemAuthDeptMapper.selectList(new QueryWrapper<SystemAuthDept>()
|
||||||
|
.select("id,name")
|
||||||
|
.in("id", deptIds)
|
||||||
|
.eq("is_delete", 0));
|
||||||
|
for (SystemAuthDept d : deptList) {
|
||||||
|
dept.add(d.getName());
|
||||||
|
}
|
||||||
|
vo.setDept(ArrayUtil.listToStringByStr(dept, "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(vo.getAvatar()));
|
vo.setAvatar(UrlUtil.toAbsoluteUrl(vo.getAvatar()));
|
||||||
|
|
@ -131,7 +155,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
// 角色权限
|
// 角色权限
|
||||||
List<String> auths = new LinkedList<>();
|
List<String> auths = new LinkedList<>();
|
||||||
if (adminId > 1) {
|
if (adminId > 1) {
|
||||||
List<Integer> menuIds = iSystemAuthPermService.selectMenuIdsByRoleId(sysAdmin.getRole());
|
List<Integer> roleIds = ArrayUtil.stringToListAsInt(sysAdmin.getRoleIds(), ",");
|
||||||
|
List<Integer> menuIds = iSystemAuthPermService.selectMenuIdsByRoleId(roleIds);
|
||||||
if (menuIds.size() > 0) {
|
if (menuIds.size() > 0) {
|
||||||
List<SystemAuthMenu> systemAuthMenus = systemAuthMenuMapper.selectList(new QueryWrapper<SystemAuthMenu>()
|
List<SystemAuthMenu> systemAuthMenus = systemAuthMenuMapper.selectList(new QueryWrapper<SystemAuthMenu>()
|
||||||
.eq("is_disable", 0)
|
.eq("is_disable", 0)
|
||||||
|
|
@ -185,6 +210,9 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
|
|
||||||
SystemAuthAdminDetailVo vo = new SystemAuthAdminDetailVo();
|
SystemAuthAdminDetailVo vo = new SystemAuthAdminDetailVo();
|
||||||
BeanUtils.copyProperties(sysAdmin, vo);
|
BeanUtils.copyProperties(sysAdmin, vo);
|
||||||
|
vo.setRoleIds(ArrayUtil.stringToListAsInt(sysAdmin.getRoleIds(), ","));
|
||||||
|
vo.setDeptIds(ArrayUtil.stringToListAsInt(sysAdmin.getDeptIds(), ","));
|
||||||
|
vo.setPostIds(ArrayUtil.stringToListAsInt(sysAdmin.getPostIds(), ","));
|
||||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(sysAdmin.getAvatar()));
|
vo.setAvatar(UrlUtil.toAbsoluteUrl(sysAdmin.getAvatar()));
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(sysAdmin.getCreateTime()));
|
vo.setCreateTime(TimeUtil.timestampToDate(sysAdmin.getCreateTime()));
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(sysAdmin.getUpdateTime()));
|
vo.setUpdateTime(TimeUtil.timestampToDate(sysAdmin.getUpdateTime()));
|
||||||
|
|
@ -213,10 +241,6 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
.eq("nickname", createValidate.getNickname())
|
.eq("nickname", createValidate.getNickname())
|
||||||
.last("limit 1")), "昵称已存在换一个吧!");
|
.last("limit 1")), "昵称已存在换一个吧!");
|
||||||
|
|
||||||
SystemAuthRoleVo roleVo = iSystemAuthRoleService.detail(createValidate.getRole());
|
|
||||||
Assert.notNull(roleVo, "角色不存在!");
|
|
||||||
Assert.isTrue(roleVo.getIsDisable() <= 0, "当前角色已被禁用!");
|
|
||||||
|
|
||||||
String salt = ToolsUtil.randomString(5);
|
String salt = ToolsUtil.randomString(5);
|
||||||
String pwd = ToolsUtil.makeMd5(createValidate.getPassword().trim() + salt);
|
String pwd = ToolsUtil.makeMd5(createValidate.getPassword().trim() + salt);
|
||||||
|
|
||||||
|
|
@ -225,11 +249,11 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
String avatar = StringUtil.isNotEmpty(createValidate.getAvatar()) ? UrlUtil.toRelativeUrl(createAvatar) : defaultAvatar;
|
String avatar = StringUtil.isNotEmpty(createValidate.getAvatar()) ? UrlUtil.toRelativeUrl(createAvatar) : defaultAvatar;
|
||||||
|
|
||||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||||
model.setDeptId(createValidate.getDeptId());
|
model.setRoleIds(ArrayUtil.listToStringByInt(createValidate.getRoleIds(), ","));
|
||||||
model.setPostId(createValidate.getPostId());
|
model.setDeptIds(ArrayUtil.listToStringByInt(createValidate.getDeptIds(), ","));
|
||||||
|
model.setPostIds(ArrayUtil.listToStringByInt(createValidate.getPostIds(), ","));
|
||||||
model.setUsername(createValidate.getUsername());
|
model.setUsername(createValidate.getUsername());
|
||||||
model.setNickname(createValidate.getNickname());
|
model.setNickname(createValidate.getNickname());
|
||||||
model.setRole(createValidate.getRole());
|
|
||||||
model.setAvatar(avatar);
|
model.setAvatar(avatar);
|
||||||
model.setPassword(pwd);
|
model.setPassword(pwd);
|
||||||
model.setSalt(salt);
|
model.setSalt(salt);
|
||||||
|
|
@ -275,17 +299,13 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
.ne("id", updateValidate.getId())
|
.ne("id", updateValidate.getId())
|
||||||
.last("limit 1")), "昵称已存在换一个吧!");
|
.last("limit 1")), "昵称已存在换一个吧!");
|
||||||
|
|
||||||
if (updateValidate.getRole() > 0 && updateValidate.getId() != 1) {
|
|
||||||
Assert.notNull(iSystemAuthRoleService.detail(updateValidate.getRole()), "角色不存在!");
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||||
model.setId(updateValidate.getId());
|
model.setId(updateValidate.getId());
|
||||||
model.setDeptId(updateValidate.getDeptId());
|
model.setRoleIds(ArrayUtil.listToStringByInt(updateValidate.getRoleIds(), ","));
|
||||||
model.setPostId(updateValidate.getPostId());
|
model.setDeptIds(ArrayUtil.listToStringByInt(updateValidate.getDeptIds(), ","));
|
||||||
|
model.setPostIds(ArrayUtil.listToStringByInt(updateValidate.getPostIds(), ","));
|
||||||
model.setNickname(updateValidate.getNickname());
|
model.setNickname(updateValidate.getNickname());
|
||||||
model.setAvatar(UrlUtil.toRelativeUrl(updateValidate.getAvatar()));
|
model.setAvatar(UrlUtil.toRelativeUrl(updateValidate.getAvatar()));
|
||||||
model.setRole(updateValidate.getId() == 1 ? 0 : updateValidate.getRole());
|
|
||||||
model.setSort(updateValidate.getSort());
|
model.setSort(updateValidate.getSort());
|
||||||
model.setIsMultipoint(updateValidate.getIsMultipoint());
|
model.setIsMultipoint(updateValidate.getIsMultipoint());
|
||||||
model.setIsDisable(updateValidate.getIsDisable());
|
model.setIsDisable(updateValidate.getIsDisable());
|
||||||
|
|
@ -416,13 +436,13 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||||
public void cacheAdminUserByUid(Integer id) {
|
public void cacheAdminUserByUid(Integer id) {
|
||||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(
|
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(
|
||||||
new QueryWrapper<SystemAuthAdmin>()
|
new QueryWrapper<SystemAuthAdmin>()
|
||||||
.select("id,role,username,nickname,is_multipoint,is_disable,is_delete")
|
.select("id,role_ids,username,nickname,is_multipoint,is_disable,is_delete")
|
||||||
.eq("id", id)
|
.eq("id", id)
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
|
||||||
Map<String, Object> user = new LinkedHashMap<>();
|
Map<String, Object> user = new LinkedHashMap<>();
|
||||||
user.put("id", sysAdmin.getId());
|
user.put("id", sysAdmin.getId());
|
||||||
user.put("roleId", sysAdmin.getRole());
|
user.put("roleIds", sysAdmin.getRoleIds());
|
||||||
user.put("username", sysAdmin.getUsername());
|
user.put("username", sysAdmin.getUsername());
|
||||||
user.put("nickname", sysAdmin.getNickname());
|
user.put("nickname", sysAdmin.getNickname());
|
||||||
user.put("isMultipoint", sysAdmin.getIsMultipoint());
|
user.put("isMultipoint", sysAdmin.getIsMultipoint());
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ public class SystemAuthMenuServiceImpl implements ISystemAuthMenuService {
|
||||||
* 根据角色ID获取菜单
|
* 根据角色ID获取菜单
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param roleId 角色ID
|
* @param roleIds 角色ID
|
||||||
* @return JSONArray
|
* @return JSONArray
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JSONArray selectMenuByRoleId(Integer roleId) {
|
public JSONArray selectMenuByRoleId(List<Integer> roleIds) {
|
||||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||||
List<Integer> menuIds = iSystemAuthPermService.selectMenuIdsByRoleId(roleId);
|
List<Integer> menuIds = iSystemAuthPermService.selectMenuIdsByRoleId(roleIds);
|
||||||
|
|
||||||
QueryWrapper<SystemAuthMenu> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<SystemAuthMenu> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.in("menu_type", Arrays.asList("M", "C"));
|
queryWrapper.in("menu_type", Arrays.asList("M", "C"));
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,19 @@ public class SystemAuthPermServiceImpl implements ISystemAuthPermService {
|
||||||
/**
|
/**
|
||||||
* 根据角色ID获取菜单ID
|
* 根据角色ID获取菜单ID
|
||||||
*
|
*
|
||||||
* @param roleId 角色ID
|
* @param roleIds 角色ID
|
||||||
* @return List<Integer>
|
* @return List<Integer>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> selectMenuIdsByRoleId(Integer roleId) {
|
public List<Integer> selectMenuIdsByRoleId(List<Integer> roleIds) {
|
||||||
List<Integer> menus = new LinkedList<>();
|
List<Integer> menus = new LinkedList<>();
|
||||||
|
|
||||||
|
if (roleIds.isEmpty()) {
|
||||||
|
return menus;
|
||||||
|
}
|
||||||
|
|
||||||
SystemAuthRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
SystemAuthRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||||
.eq("id", roleId)
|
.in("id", roleIds)
|
||||||
.eq("is_disable", 0)
|
.eq("is_disable", 0)
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
|
||||||
|
|
@ -55,7 +59,9 @@ public class SystemAuthPermServiceImpl implements ISystemAuthPermService {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SystemAuthPerm> systemAuthPerms = systemAuthPermMapper.selectList(
|
List<SystemAuthPerm> systemAuthPerms = systemAuthPermMapper.selectList(
|
||||||
new QueryWrapper<SystemAuthPerm>().eq("role_id", roleId));
|
new QueryWrapper<SystemAuthPerm>()
|
||||||
|
.in("role_id", roleIds));
|
||||||
|
|
||||||
for (SystemAuthPerm systemAuthPerm : systemAuthPerms) {
|
for (SystemAuthPerm systemAuthPerm : systemAuthPerms) {
|
||||||
menus.add(systemAuthPerm.getMenuId());
|
menus.add(systemAuthPerm.getMenuId());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||||
vo.setIsDisable(systemAuthRole.getIsDisable());
|
vo.setIsDisable(systemAuthRole.getIsDisable());
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
|
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
|
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
|
||||||
vo.setMember(0L);
|
vo.setMember(0);
|
||||||
vo.setRemark("");
|
vo.setRemark("");
|
||||||
vo.setMenus(Collections.EMPTY_LIST);
|
vo.setMenus(Collections.EMPTY_LIST);
|
||||||
list.add(vo);
|
list.add(vo);
|
||||||
|
|
@ -95,9 +95,8 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||||
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
||||||
BeanUtils.copyProperties(systemAuthRole, vo);
|
BeanUtils.copyProperties(systemAuthRole, vo);
|
||||||
|
|
||||||
Long member = systemAuthAdminMapper.selectCount(new QueryWrapper<SystemAuthAdmin>()
|
List<Integer> ids = systemAuthAdminMapper.selectChildrenById(systemAuthRole.getId());
|
||||||
.eq("is_delete", 0)
|
Integer member = ids.size();
|
||||||
.eq("role", systemAuthRole.getId()));
|
|
||||||
|
|
||||||
vo.setMenus(new ArrayList<>());
|
vo.setMenus(new ArrayList<>());
|
||||||
vo.setMember(member);
|
vo.setMember(member);
|
||||||
|
|
@ -124,14 +123,13 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||||
|
|
||||||
Assert.notNull(systemAuthRole, "角色已不存在!");
|
Assert.notNull(systemAuthRole, "角色已不存在!");
|
||||||
|
|
||||||
Long member = systemAuthAdminMapper.selectCount(new QueryWrapper<SystemAuthAdmin>()
|
List<Integer> roleIds = new LinkedList<>();
|
||||||
.eq("is_delete", 0)
|
roleIds.add(systemAuthRole.getId());
|
||||||
.eq("role", systemAuthRole.getId()));
|
|
||||||
|
|
||||||
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
||||||
BeanUtils.copyProperties(systemAuthRole, vo);
|
BeanUtils.copyProperties(systemAuthRole, vo);
|
||||||
vo.setMember(member);
|
vo.setMember(0);
|
||||||
vo.setMenus(iSystemAuthPermService.selectMenuIdsByRoleId(systemAuthRole.getId()));
|
vo.setMenus(iSystemAuthPermService.selectMenuIdsByRoleId(roleIds));
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
|
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
|
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统管理员创建参数
|
* 系统管理员创建参数
|
||||||
|
|
@ -18,10 +19,6 @@ public class SystemAdminCreateValidate implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@NotNull(message = "请选择角色")
|
|
||||||
@Min(value = 0, message = "role参数异常")
|
|
||||||
private Integer role;
|
|
||||||
|
|
||||||
@NotEmpty(message = "账号不能为空")
|
@NotEmpty(message = "账号不能为空")
|
||||||
@Length(min = 2, max = 20, message = "账号必须在2~20个字符内")
|
@Length(min = 2, max = 20, message = "账号必须在2~20个字符内")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
@ -46,13 +43,14 @@ public class SystemAdminCreateValidate implements Serializable {
|
||||||
@DecimalMin(value = "0", message = "排序号值不能少于0")
|
@DecimalMin(value = "0", message = "排序号值不能少于0")
|
||||||
private Integer sort = 0;
|
private Integer sort = 0;
|
||||||
|
|
||||||
@DecimalMin(value = "0", message = "部门ID值不能少于0")
|
|
||||||
private Integer deptId = 0;
|
|
||||||
|
|
||||||
@DecimalMin(value = "0", message = "岗位ID值不能少于0")
|
|
||||||
private Integer postId = 0;
|
|
||||||
|
|
||||||
@Length(max = 200, message = "头像不能超出200个字符")
|
@Length(max = 200, message = "头像不能超出200个字符")
|
||||||
private String avatar = "";
|
private String avatar = "";
|
||||||
|
|
||||||
|
@NotNull(message = "请选择角色")
|
||||||
|
private List<Integer> roleIds;
|
||||||
|
|
||||||
|
private List<Integer> deptIds;
|
||||||
|
|
||||||
|
private List<Integer> postIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统管理员更新参数
|
* 系统管理员更新参数
|
||||||
|
|
@ -22,10 +23,6 @@ public class SystemAdminUpdateValidate implements Serializable {
|
||||||
@IDMust(message = "id参数必传且需大于0")
|
@IDMust(message = "id参数必传且需大于0")
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@NotNull(message = "请选择角色")
|
|
||||||
@Min(value = 0, message = "role参数异常")
|
|
||||||
private Integer role;
|
|
||||||
|
|
||||||
@NotEmpty(message = "账号不能为空")
|
@NotEmpty(message = "账号不能为空")
|
||||||
@Length(min = 2, max = 20, message = "账号必须在2~20个字符内")
|
@Length(min = 2, max = 20, message = "账号必须在2~20个字符内")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
@ -48,13 +45,15 @@ public class SystemAdminUpdateValidate implements Serializable {
|
||||||
@DecimalMin(value = "0", message = "排序号值不能少于0")
|
@DecimalMin(value = "0", message = "排序号值不能少于0")
|
||||||
private Integer sort = 0;
|
private Integer sort = 0;
|
||||||
|
|
||||||
@DecimalMin(value = "0", message = "部门ID值不能少于0")
|
|
||||||
private Integer deptId = 0;
|
|
||||||
|
|
||||||
@DecimalMin(value = "0", message = "岗位ID值不能少于0")
|
|
||||||
private Integer postId = 0;
|
|
||||||
|
|
||||||
@Length(max = 200, message = "头像不能超出200个字符")
|
@Length(max = 200, message = "头像不能超出200个字符")
|
||||||
private String avatar = "";
|
private String avatar = "";
|
||||||
|
|
||||||
|
@NotNull(message = "请选择角色")
|
||||||
|
|
||||||
|
private List<Integer> roleIds;
|
||||||
|
|
||||||
|
private List<Integer> deptIds;
|
||||||
|
|
||||||
|
private List<Integer> postIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.mdd.admin.vo.system;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员详情Vo
|
* 管理员详情Vo
|
||||||
|
|
@ -13,9 +14,9 @@ public class SystemAuthAdminDetailVo implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Integer id; // 主键
|
private Integer id; // 主键
|
||||||
private Integer deptId; // 部门ID
|
private List<Integer> roleIds; // 角色ID
|
||||||
private Integer postId; // 岗位ID
|
private List<Integer> deptIds; // 部门ID
|
||||||
private Integer role; // 角色ID
|
private List<Integer> postIds; // 岗位ID
|
||||||
private String username; // 账号
|
private String username; // 账号
|
||||||
private String nickname; // 昵称
|
private String nickname; // 昵称
|
||||||
private String avatar; // 头像
|
private String avatar; // 头像
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class SystemAuthRoleVo implements Serializable {
|
||||||
private String name; // 角色名称
|
private String name; // 角色名称
|
||||||
private String remark; // 角色备注
|
private String remark; // 角色备注
|
||||||
private Object menus; // 关联菜单
|
private Object menus; // 关联菜单
|
||||||
private Long member; // 成员数量
|
private Integer member; // 成员数量
|
||||||
private Integer sort; // 角色排序
|
private Integer sort; // 角色排序
|
||||||
private Integer isDisable; // 是否禁用: [0=否, 1=是]
|
private Integer isDisable; // 是否禁用: [0=否, 1=是]
|
||||||
private String createTime; // 创建时间
|
private String createTime; // 创建时间
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.10.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ public class SystemAuthAdmin implements Serializable {
|
||||||
|
|
||||||
@TableId(value="id", type=IdType.AUTO)
|
@TableId(value="id", type=IdType.AUTO)
|
||||||
private Integer id; // 主键
|
private Integer id; // 主键
|
||||||
private Integer deptId; // 部门ID
|
|
||||||
private Integer postId; // 岗位ID
|
|
||||||
private String nickname; // 用户账号
|
private String nickname; // 用户账号
|
||||||
private String username; // 用户昵称
|
private String username; // 用户昵称
|
||||||
private String password; // 用户密码
|
private String password; // 用户密码
|
||||||
private String avatar; // 用户头像
|
private String avatar; // 用户头像
|
||||||
private String salt; // 加密盐巴
|
private String salt; // 加密盐巴
|
||||||
private Integer role; // 角色主键
|
private String roleIds; // 角色主键
|
||||||
|
private String deptIds; // 部门主键
|
||||||
|
private String postIds; // 岗位主键
|
||||||
private Integer sort; // 排序编号
|
private Integer sort; // 排序编号
|
||||||
private Integer isMultipoint; // 多端登录: [0=否, 1=是]
|
private Integer isMultipoint; // 多端登录: [0=否, 1=是]
|
||||||
private Integer isDisable; // 是否禁用: [0=否, 1=是]
|
private Integer isDisable; // 是否禁用: [0=否, 1=是]
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,24 @@ package com.mdd.common.mapper.system;
|
||||||
import com.mdd.common.core.basics.IBaseMapper;
|
import com.mdd.common.core.basics.IBaseMapper;
|
||||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统管理员Mapper
|
* 系统管理员Mapper
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SystemAuthAdminMapper extends IBaseMapper<SystemAuthAdmin> {
|
public interface SystemAuthAdminMapper extends IBaseMapper<SystemAuthAdmin> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色管理员
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param id 文件夹ID
|
||||||
|
* @return List<Integer>
|
||||||
|
*/
|
||||||
|
@Select("SELECT id FROM ${prefix}system_auth_admin WHERE is_delete=0 AND FIND_IN_SET(#{id}, role_ids)")
|
||||||
|
List<Integer> selectChildrenById(Integer id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue