mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge branch 'main' of http://192.168.1.205:9980/cf_devdept2/cf_imes_server
This commit is contained in:
+1
@@ -39,6 +39,7 @@ public class ErrorCodeConstants {
|
|||||||
public static final ErrorCode ROLE_NOT_SUPERADMIN_NO_ORGAN_ID_OPER_ERROR = new ErrorCode(1_002_002_007, "非超管分配权限");
|
public static final ErrorCode ROLE_NOT_SUPERADMIN_NO_ORGAN_ID_OPER_ERROR = new ErrorCode(1_002_002_007, "非超管分配权限");
|
||||||
public static final ErrorCode BUILDIN_ROLE_MODIFY_PERMISSION_ERROR = new ErrorCode(1_002_002_008, "修改内置角色下菜单权限的权限不足");
|
public static final ErrorCode BUILDIN_ROLE_MODIFY_PERMISSION_ERROR = new ErrorCode(1_002_002_008, "修改内置角色下菜单权限的权限不足");
|
||||||
public static final ErrorCode SELF_ROLE_MODIFY_PERMISSION_ERROR = new ErrorCode(1_002_002_009, "无法修改自身的角色菜单权限");
|
public static final ErrorCode SELF_ROLE_MODIFY_PERMISSION_ERROR = new ErrorCode(1_002_002_009, "无法修改自身的角色菜单权限");
|
||||||
|
public static final ErrorCode SELF_ROLE_MODIFY_ERROR = new ErrorCode(1_002_002_010, "无法修改自身的角色");
|
||||||
|
|
||||||
// ========== 用户模块 1-002-003-000 ==========
|
// ========== 用户模块 1-002-003-000 ==========
|
||||||
public static final ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1_002_003_000, "手机号已经存在");
|
public static final ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1_002_003_000, "手机号已经存在");
|
||||||
|
|||||||
+8
-3
@@ -12,6 +12,7 @@ import com.cf.imes.module.system.service.dept.DeptService;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -69,9 +70,13 @@ public class DeptController {
|
|||||||
|
|
||||||
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
||||||
@Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
@Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
||||||
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
|
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList(@Valid DeptListReqVO reqVO) {
|
||||||
List<DeptDO> list = deptService.getDeptList(
|
// 有效部门的请求,传入organid就查对应的,没有就查登录人下的
|
||||||
new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
DeptListReqVO efficDeptReqVO = new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
if (ObjectUtils.allNotNull(reqVO, reqVO.getOrganId())) {
|
||||||
|
efficDeptReqVO.setOrganId(reqVO.getOrganId());
|
||||||
|
}
|
||||||
|
List<DeptDO> list = deptService.getDeptList(efficDeptReqVO);
|
||||||
return success(BeanUtils.toBean(deptService.removeUnowndDept(list), DeptSimpleRespVO.class));
|
return success(BeanUtils.toBean(deptService.removeUnowndDept(list), DeptSimpleRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -604,7 +604,13 @@ public class PermissionServiceImpl implements PermissionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> getUserRoleIdListByUserId(Long userId) {
|
public Set<Long> getUserRoleIdListByUserId(Long userId) {
|
||||||
return convertSet(userRoleMapper.selectListByUserId(userId), UserRoleDO::getRoleId);
|
List<UserRoleDO> userRoleDOS = userRoleMapper.selectListByUserId(userId);
|
||||||
|
userRoleDOS.removeIf(ur -> {
|
||||||
|
Long roleId = ur.getRoleId();
|
||||||
|
RoleDO role = roleService.getRoleFromCache(roleId);
|
||||||
|
return ObjectUtil.isNotNull(role) && CommonStatusEnum.DISABLE.getStatus().equals(role.getStatus());
|
||||||
|
});
|
||||||
|
return convertSet(userRoleDOS, UserRoleDO::getRoleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+24
-1
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||||
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
|
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.framework.common.util.collection.CollectionUtils;
|
import com.cf.imes.framework.common.util.collection.CollectionUtils;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
@@ -18,6 +20,7 @@ import com.cf.imes.module.system.dal.dataobject.permission.RoleDO;
|
|||||||
import com.cf.imes.module.system.dal.mysql.permission.RoleMapper;
|
import com.cf.imes.module.system.dal.mysql.permission.RoleMapper;
|
||||||
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
||||||
import com.cf.imes.module.system.dal.redis.RedisRefreshChannelTopicConstants;
|
import com.cf.imes.module.system.dal.redis.RedisRefreshChannelTopicConstants;
|
||||||
|
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
||||||
import com.cf.imes.module.system.enums.permission.DataScopeEnum;
|
import com.cf.imes.module.system.enums.permission.DataScopeEnum;
|
||||||
import com.cf.imes.module.system.enums.permission.RoleCodeEnum;
|
import com.cf.imes.module.system.enums.permission.RoleCodeEnum;
|
||||||
import com.cf.imes.module.system.enums.permission.RoleTypeEnum;
|
import com.cf.imes.module.system.enums.permission.RoleTypeEnum;
|
||||||
@@ -86,6 +89,8 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
validateRoleForUpdate(updateReqVO.getId());
|
validateRoleForUpdate(updateReqVO.getId());
|
||||||
// 校验角色的唯一字段是否重复
|
// 校验角色的唯一字段是否重复
|
||||||
validateRoleDuplicate(updateReqVO.getName(), updateReqVO.getCode(), updateReqVO.getId(), updateReqVO.getOrganId());
|
validateRoleDuplicate(updateReqVO.getName(), updateReqVO.getCode(), updateReqVO.getId(), updateReqVO.getOrganId());
|
||||||
|
// 校验自身角色
|
||||||
|
validateModifySelfRole(updateReqVO.getId());
|
||||||
|
|
||||||
// 更新到数据库
|
// 更新到数据库
|
||||||
RoleDO updateObj = BeanUtils.toBean(updateReqVO, RoleDO.class);
|
RoleDO updateObj = BeanUtils.toBean(updateReqVO, RoleDO.class);
|
||||||
@@ -99,7 +104,8 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
public void updateRoleStatus(Long id, Integer status) {
|
public void updateRoleStatus(Long id, Integer status) {
|
||||||
// 校验是否可以更新
|
// 校验是否可以更新
|
||||||
validateRoleForUpdate(id);
|
validateRoleForUpdate(id);
|
||||||
|
// 校验自身角色
|
||||||
|
validateModifySelfRole(id);
|
||||||
// 更新状态
|
// 更新状态
|
||||||
RoleDO updateObj = new RoleDO().setId(id).setStatus(status);
|
RoleDO updateObj = new RoleDO().setId(id).setStatus(status);
|
||||||
roleMapper.updateById(updateObj);
|
roleMapper.updateById(updateObj);
|
||||||
@@ -107,6 +113,23 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
scanAndDelKeys(String.format(REDIS_ROLE_KEY_PATTERN, updateObj.getId()));
|
scanAndDelKeys(String.format(REDIS_ROLE_KEY_PATTERN, updateObj.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验自身角色
|
||||||
|
*
|
||||||
|
* @param roleId
|
||||||
|
*/
|
||||||
|
private void validateModifySelfRole(Long roleId) {
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(loginUser.getId());
|
||||||
|
if (roleIds.contains(roleId)) {
|
||||||
|
throw new ServiceException(ErrorCodeConstants.SELF_ROLE_MODIFY_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = RedisKeyConstants.ROLE, key = "#id")
|
@CacheEvict(value = RedisKeyConstants.ROLE, key = "#id")
|
||||||
public void updateRoleDataScope(Long id, Integer dataScope, Set<Long> dataScopeDeptIds) {
|
public void updateRoleDataScope(Long id, Integer dataScope, Set<Long> dataScopeDeptIds) {
|
||||||
|
|||||||
-2
@@ -257,10 +257,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateUserProfile(Long id, UserProfileUpdateReqVO reqVO) {
|
public void updateUserProfile(Long id, UserProfileUpdateReqVO reqVO) {
|
||||||
Long organId = reqVO.getOrganId() == null ? OrganContextHolder.getOrganId() : reqVO.getOrganId();
|
|
||||||
// 校验正确性
|
// 校验正确性
|
||||||
validateUserExists(id);
|
validateUserExists(id);
|
||||||
validateEmailUnique(id, reqVO.getEmail(), organId);
|
|
||||||
// 执行更新
|
// 执行更新
|
||||||
userMapper.updateById(BeanUtils.toBean(reqVO, AdminUserDO.class).setId(id));
|
userMapper.updateById(BeanUtils.toBean(reqVO, AdminUserDO.class).setId(id));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user