feat(新增加班申请功能): 新增申请功能,可在工作台进行审核。
fix(dict_data): 字典数据的颜色类型字段不允许null更新。
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.util.collection.CollectionUtils;
|
||||
import com.njcn.rdms.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.njcn.rdms.module.system.api.user.dto.UserManagementRelationRespDTO;
|
||||
import com.njcn.rdms.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -33,6 +34,11 @@ public interface UserManagementRelationApi {
|
||||
@Parameter(name = "subordinateUserId", description = "被管理者用户ID", example = "2", required = true)
|
||||
CommonResult<List<UserManagementRelationRespDTO>> getRelationListBySubordinateUserId(@RequestParam("subordinateUserId") Long subordinateUserId);
|
||||
|
||||
@GetMapping(PREFIX + "/direct-manager")
|
||||
@Operation(summary = "根据用户ID获得当前生效的直属上级")
|
||||
@Parameter(name = "userId", description = "用户ID", example = "2", required = true)
|
||||
CommonResult<AdminUserRespDTO> getDirectManager(@RequestParam("userId") Long userId);
|
||||
|
||||
@GetMapping(PREFIX + "/list")
|
||||
@Operation(summary = "获得管理链路列表")
|
||||
@Parameter(name = "ids", description = "关系编号数组", example = "1,2", required = true)
|
||||
|
||||
@@ -32,4 +32,14 @@ public interface DictTypeConstants {
|
||||
*/
|
||||
String RDMS_TASK_ITEM_TYPE="rdms_task_item_type";
|
||||
|
||||
/**
|
||||
* 加班申请审批状态字典。
|
||||
*/
|
||||
String RDMS_OVERTIME_APPLICATION_STATUS = "rdms_overtime_application_status";
|
||||
|
||||
/**
|
||||
* 加班申请时长快捷选项字典。
|
||||
*/
|
||||
String RDMS_OVERTIME_DURATION = "rdms_overtime_duration";
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.njcn.rdms.module.system.api.user;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.njcn.rdms.module.system.api.user.dto.UserManagementRelationRespDTO;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.user.UserManagementRelationDO;
|
||||
import com.njcn.rdms.module.system.service.user.UserManagementRelationService;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
@@ -36,6 +38,15 @@ public class UserManagementRelationApiImpl implements UserManagementRelationApi
|
||||
return success(BeanUtils.toBean(list, UserManagementRelationRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<AdminUserRespDTO> getDirectManager(Long userId) {
|
||||
AdminUserDO manager = userManagementRelationService.getDirectManager(userId);
|
||||
if (manager == null) {
|
||||
return success(null);
|
||||
}
|
||||
return success(BeanUtils.toBean(manager, AdminUserRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<UserManagementRelationRespDTO>> getRelationList(Collection<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -157,6 +158,26 @@ public class UserManagementRelationController {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得某用户当前生效的直属上级
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 直属上级用户,不存在则返回 null
|
||||
*/
|
||||
@GetMapping("/direct-manager")
|
||||
@Operation(summary = "获得某用户当前生效的直属上级")
|
||||
@Parameter(name = "userId", description = "用户ID", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:user-management-relation:query')")
|
||||
public CommonResult<UserSimpleRespVO> getDirectManager(@RequestParam("userId") Long userId) {
|
||||
AdminUserDO manager = userManagementRelationService.getDirectManager(userId);
|
||||
if (manager == null) {
|
||||
return success(null);
|
||||
}
|
||||
List<Long> deptIds = manager.getDeptId() == null ? Collections.emptyList() : List.of(manager.getDeptId());
|
||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(deptIds);
|
||||
return success(UserConvert.INSTANCE.convertSimpleList(List.of(manager), deptMap).get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未绑定直属上级的候选下级用户列表
|
||||
* @return 候选下级用户列表
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.rdms.framework.encrypt.core.annotation.ApiEncrypt;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.profile.UserProfileRespVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.user.UserSimpleRespVO;
|
||||
import com.njcn.rdms.module.system.convert.user.UserConvert;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.dept.DeptDO;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.dept.PostDO;
|
||||
@@ -17,6 +18,7 @@ import com.njcn.rdms.module.system.service.dept.PostService;
|
||||
import com.njcn.rdms.module.system.service.permission.PermissionService;
|
||||
import com.njcn.rdms.module.system.service.permission.RoleService;
|
||||
import com.njcn.rdms.module.system.service.user.AdminUserService;
|
||||
import com.njcn.rdms.module.system.service.user.UserManagementRelationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -26,7 +28,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
|
||||
import static com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@@ -48,6 +52,8 @@ public class UserProfileController {
|
||||
private PermissionService permissionService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private UserManagementRelationService userManagementRelationService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得登录用户信息")
|
||||
@@ -67,6 +73,18 @@ public class UserProfileController {
|
||||
return success(UserConvert.INSTANCE.convert(user, userRoles, dept, position));
|
||||
}
|
||||
|
||||
@GetMapping("/direct-manager")
|
||||
@Operation(summary = "获得当前登录用户的直属上级")
|
||||
public CommonResult<UserSimpleRespVO> getLoginUserDirectManager() {
|
||||
AdminUserDO manager = userManagementRelationService.getDirectManager(getLoginUserId());
|
||||
if (manager == null) {
|
||||
return success(null);
|
||||
}
|
||||
List<Long> deptIds = manager.getDeptId() == null ? Collections.emptyList() : List.of(manager.getDeptId());
|
||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(deptIds);
|
||||
return success(UserConvert.INSTANCE.convertSimpleList(List.of(manager), deptMap).get(0));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改用户个人信息")
|
||||
public CommonResult<Boolean> updateUserProfile(@Valid @RequestBody UserProfileUpdateReqVO reqVO) {
|
||||
|
||||
@@ -51,6 +51,7 @@ public class DictDataDO extends BaseDO {
|
||||
*
|
||||
* 对应到 element-ui 为 default、primary、success、info、warning、danger
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String colorType;
|
||||
/**
|
||||
* css 样式
|
||||
|
||||
@@ -73,4 +73,23 @@ public interface UserManagementRelationMapper extends BaseMapperX<UserManagement
|
||||
return selectList(UserManagementRelationDO::getSubordinateUserId, subordinateUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据被管理者用户ID查询当前生效的上级关系列表
|
||||
*
|
||||
* @param subordinateUserId 被管理者用户ID
|
||||
* @return 当前生效的用户管理链路DO列表
|
||||
*/
|
||||
default List<UserManagementRelationDO> selectValidListBySubordinateUserId(Long subordinateUserId) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return selectList(new LambdaQueryWrapperX<UserManagementRelationDO>()
|
||||
.eq(UserManagementRelationDO::getSubordinateUserId, subordinateUserId)
|
||||
// (from IS NULL OR from <= now)
|
||||
.and(w -> w.isNull(UserManagementRelationDO::getEffectiveFrom)
|
||||
.or().le(UserManagementRelationDO::getEffectiveFrom, now))
|
||||
// (until IS NULL OR until >= now)
|
||||
.and(w -> w.isNull(UserManagementRelationDO::getEffectiveUntil)
|
||||
.or().ge(UserManagementRelationDO::getEffectiveUntil, now))
|
||||
.orderByDesc(UserManagementRelationDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,6 +89,14 @@ public interface UserManagementRelationService {
|
||||
*/
|
||||
List<UserManagementRelationDO> getRelationListBySubordinateUserId(Long subordinateUserId);
|
||||
|
||||
/**
|
||||
* 获得某用户当前生效的直属上级
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 直属上级用户,不存在则返回 null
|
||||
*/
|
||||
AdminUserDO getDirectManager(Long userId);
|
||||
|
||||
/**
|
||||
* 获得用户管理链路树形结构
|
||||
*
|
||||
|
||||
@@ -270,7 +270,33 @@ public class UserManagementRelationServiceImpl implements UserManagementRelation
|
||||
*/
|
||||
@Override
|
||||
public List<UserManagementRelationDO> getRelationListBySubordinateUserId(Long subordinateUserId) {
|
||||
return userManagementRelationMapper.selectListBySubordinateUserId(subordinateUserId);
|
||||
if (subordinateUserId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return userManagementRelationMapper.selectValidListBySubordinateUserId(subordinateUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得某用户当前生效的直属上级
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 直属上级用户,不存在则返回 null
|
||||
*/
|
||||
@Override
|
||||
public AdminUserDO getDirectManager(Long userId) {
|
||||
List<UserManagementRelationDO> relations = getRelationListBySubordinateUserId(userId);
|
||||
if (CollUtil.isEmpty(relations)) {
|
||||
return null;
|
||||
}
|
||||
Long managerUserId = relations.get(0).getManagerUserId();
|
||||
if (managerUserId == null) {
|
||||
return null;
|
||||
}
|
||||
AdminUserDO manager = adminUserService.getUser(managerUserId);
|
||||
if (!adminUserService.isUserAvailable(manager)) {
|
||||
return null;
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user