✨ Introducing new features. 增加部门负责人岗位,方便工作流审批使用
This commit is contained in:
1 parent
9d0ddc4cd9
commit
2342e227ed
4 files changed
+62
-6
No files matched your search
+9
@@ -24,6 +24,7 @@ import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,4 +42,12 @@ public interface RemoteDeptService {
|
||||
@GetMapping("/dept/list")
|
||||
R<List<SysDept>> getAllDept();
|
||||
|
||||
/**
|
||||
* 通过部门ID获取负责人列表
|
||||
* @param deptId 部门ID
|
||||
* @return 负责人ID列表
|
||||
*/
|
||||
@GetMapping("/dept/leader/{deptId}")
|
||||
R<List<Long>> getAllDeptLeader(@PathVariable("deptId") Long deptId);
|
||||
|
||||
}
|
||||
+5
-2
@@ -28,13 +28,13 @@ import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -129,6 +129,10 @@ public class SysDeptController {
|
||||
return R.ok(sysDeptService.listDescendant(deptId));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/leader/{deptId}")
|
||||
public R getAllDeptLeader(@PathVariable Long deptId){
|
||||
return R.ok(sysDeptService.listDeptLeader(deptId));
|
||||
}
|
||||
/**
|
||||
* 导出部门
|
||||
* @return
|
||||
@@ -147,7 +151,6 @@ public class SysDeptController {
|
||||
*/
|
||||
@PostMapping("import")
|
||||
public R importDept(@RequestExcel List<DeptExcelVo> excelVOList, BindingResult bindingResult) {
|
||||
|
||||
return sysDeptService.importDept(excelVOList, bindingResult);
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -41,7 +41,6 @@ public interface SysDeptService extends IService<SysDept> {
|
||||
/**
|
||||
* 查询部门树菜单
|
||||
* @param deptName 部门名称
|
||||
* @param parentId
|
||||
* @return 树
|
||||
*/
|
||||
List<Tree<Long>> selectTree(String deptName, Long parentId);
|
||||
@@ -64,4 +63,10 @@ public interface SysDeptService extends IService<SysDept> {
|
||||
*/
|
||||
List<SysDept> listDescendant(Long deptId);
|
||||
|
||||
/**
|
||||
* 获取部门负责人
|
||||
* @param deptId deptId
|
||||
* @return user id list
|
||||
*/
|
||||
List<Long> listDeptLeader(Long deptId);
|
||||
}
|
||||
+42
-3
@@ -27,8 +27,14 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysDept;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysPost;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUserPost;
|
||||
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVo;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysDeptMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysPostMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysUserPostMapper;
|
||||
import com.pig4cloud.pigx.admin.service.SysDeptService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.data.datascope.DataScope;
|
||||
@@ -54,8 +60,14 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
|
||||
|
||||
private final SysUserMapper userMapper;
|
||||
|
||||
private final SysDeptMapper deptMapper;
|
||||
|
||||
private final SysPostMapper postMapper;
|
||||
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* @param id 部门 ID
|
||||
@@ -198,12 +210,39 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
recursiveDept(allDeptList, deptId, resDeptList);
|
||||
|
||||
// 添加当前节点
|
||||
resDeptList.addAll(allDeptList.stream()
|
||||
.filter(sysDept -> deptId.equals(sysDept.getDeptId()))
|
||||
.collect(Collectors.toList()));
|
||||
resDeptList.addAll(allDeptList.stream().filter(sysDept -> deptId.equals(sysDept.getDeptId())).toList());
|
||||
return resDeptList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门负责人
|
||||
*
|
||||
* 1. 根据dept 查询用户 2. 筛选用户列表中 post
|
||||
* @param deptId deptId
|
||||
* @return user id list
|
||||
*/
|
||||
@Override
|
||||
public List<Long> listDeptLeader(Long deptId) {
|
||||
List<SysUser> sysUserList = userMapper
|
||||
.selectList(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getDeptId, deptId));
|
||||
if (CollUtil.isEmpty(sysUserList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SysPost deptLeader = postMapper
|
||||
.selectOne(Wrappers.<SysPost>lambdaQuery().eq(SysPost::getPostCode, "DEPT_LEADER"));
|
||||
if (deptLeader == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).toList();
|
||||
return userPostMapper.selectList(Wrappers.<SysUserPost>lambdaQuery().in(SysUserPost::getUserId, userIdList))
|
||||
.stream()
|
||||
.filter(post -> Objects.equals(post.getPostId(), deptLeader.getPostId()))
|
||||
.map(SysUserPost::getUserId)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询所有子节点。
|
||||
* @param allDeptList 所有部门列表
|
||||
|
||||
Reference in new issue
Block a user