!713 update 优化StreamUtils使用以及岗位删除优化
* update 优化命名含义 * update 优化StreamUtils使用以及岗位删除优化
This commit is contained in:
parent
d501e82541
commit
debc73d7d4
@ -3,6 +3,7 @@ package org.dromara.common.core.service;
|
|||||||
import org.dromara.common.core.domain.dto.DeptDTO;
|
import org.dromara.common.core.domain.dto.DeptDTO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用 部门服务
|
* 通用 部门服务
|
||||||
@ -34,4 +35,12 @@ public interface DeptService {
|
|||||||
*/
|
*/
|
||||||
List<DeptDTO> selectDeptsByList();
|
List<DeptDTO> selectDeptsByList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门 ID 列表查询部门名称映射关系
|
||||||
|
*
|
||||||
|
* @param deptIds 部门 ID 列表
|
||||||
|
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||||
|
*/
|
||||||
|
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package org.dromara.common.core.service;
|
package org.dromara.common.core.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用 岗位服务
|
* 通用 岗位服务
|
||||||
*
|
*
|
||||||
@ -7,4 +10,12 @@ package org.dromara.common.core.service;
|
|||||||
*/
|
*/
|
||||||
public interface PostService {
|
public interface PostService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||||
|
*
|
||||||
|
* @param postIds 岗位 ID 列表
|
||||||
|
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||||
|
*/
|
||||||
|
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package org.dromara.common.core.service;
|
package org.dromara.common.core.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用 角色服务
|
* 通用 角色服务
|
||||||
*
|
*
|
||||||
@ -7,4 +10,12 @@ package org.dromara.common.core.service;
|
|||||||
*/
|
*/
|
||||||
public interface RoleService {
|
public interface RoleService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色 ID 列表查询角色名称映射关系
|
||||||
|
*
|
||||||
|
* @param roleIds 角色 ID 列表
|
||||||
|
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||||
|
*/
|
||||||
|
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,28 +100,4 @@ public interface UserService {
|
|||||||
*/
|
*/
|
||||||
Map<Long, String> selectUserNamesByIds(List<Long> userIds);
|
Map<Long, String> selectUserNamesByIds(List<Long> userIds);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据角色 ID 列表查询角色名称映射关系
|
|
||||||
*
|
|
||||||
* @param roleIds 角色 ID 列表
|
|
||||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
|
||||||
*/
|
|
||||||
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据部门 ID 列表查询部门名称映射关系
|
|
||||||
*
|
|
||||||
* @param deptIds 部门 ID 列表
|
|
||||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
|
||||||
*/
|
|
||||||
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
|
||||||
*
|
|
||||||
* @param postIds 岗位 ID 列表
|
|
||||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
|
||||||
*/
|
|
||||||
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +108,7 @@ public class SysPostController extends BaseController {
|
|||||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{postIds}")
|
@DeleteMapping("/{postIds}")
|
||||||
public R<Void> remove(@PathVariable Long[] postIds) {
|
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
return toAjax(postService.deletePostByIds(Arrays.asList(postIds)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
@ -72,6 +73,19 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
|||||||
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
|
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询某个部门及其所有子部门ID(含自身)
|
||||||
|
*
|
||||||
|
* @param parentId 父部门ID
|
||||||
|
* @return 部门ID集合
|
||||||
|
*/
|
||||||
|
default List<Long> selectDeptAndChildById(Long parentId) {
|
||||||
|
List<SysDept> deptList = this.selectListByParentId(parentId);
|
||||||
|
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||||
|
deptIds.add(parentId);
|
||||||
|
return deptIds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID查询部门树信息
|
* 根据角色ID查询部门树信息
|
||||||
*
|
*
|
||||||
|
@ -110,7 +110,7 @@ public interface ISysPostService {
|
|||||||
* @param postIds 需要删除的岗位ID
|
* @param postIds 需要删除的岗位ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deletePostByIds(Long[] postIds);
|
int deletePostByIds(List<Long> postIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存岗位信息
|
* 新增保存岗位信息
|
||||||
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.dromara.common.core.constant.CacheNames;
|
import org.dromara.common.core.constant.CacheNames;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.system.domain.SysDept;
|
|
||||||
import org.dromara.system.domain.SysRoleDept;
|
import org.dromara.system.domain.SysRoleDept;
|
||||||
import org.dromara.system.mapper.SysDeptMapper;
|
import org.dromara.system.mapper.SysDeptMapper;
|
||||||
import org.dromara.system.mapper.SysRoleDeptMapper;
|
import org.dromara.system.mapper.SysRoleDeptMapper;
|
||||||
@ -66,13 +65,8 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
|||||||
if (ObjectUtil.isNull(deptId)) {
|
if (ObjectUtil.isNull(deptId)) {
|
||||||
return "-1";
|
return "-1";
|
||||||
}
|
}
|
||||||
List<SysDept> deptList = deptMapper.selectListByParentId(deptId);
|
List<Long> deptIds = deptMapper.selectDeptAndChildById(deptId);
|
||||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
return CollUtil.isNotEmpty(deptIds) ? StreamUtils.join(deptIds, Convert::toStr) : "-1";
|
||||||
ids.add(deptId);
|
|
||||||
if (CollUtil.isNotEmpty(ids)) {
|
|
||||||
return StreamUtils.join(ids, Convert::toStr);
|
|
||||||
}
|
|
||||||
return "-1";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,7 @@ import org.springframework.cache.annotation.Caching;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门管理 服务实现
|
* 部门管理 服务实现
|
||||||
@ -110,10 +107,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||||
//部门树搜索
|
//部门树搜索
|
||||||
lqw.and(x -> {
|
lqw.and(x -> {
|
||||||
Long parentId = bo.getBelongDeptId();
|
List<Long> deptIds = baseMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||||
List<SysDept> deptList = baseMapper.selectListByParentId(parentId);
|
|
||||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
|
||||||
deptIds.add(parentId);
|
|
||||||
x.in(SysDept::getDeptId, deptIds);
|
x.in(SysDept::getDeptId, deptIds);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -409,4 +403,24 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
return baseMapper.deleteById(deptId);
|
return baseMapper.deleteById(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门 ID 列表查询部门名称映射关系
|
||||||
|
*
|
||||||
|
* @param deptIds 部门 ID 列表
|
||||||
|
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<Long, String> selectDeptNamesByIds(List<Long> deptIds) {
|
||||||
|
if (CollUtil.isEmpty(deptIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<SysDept> list = baseMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<SysDept>()
|
||||||
|
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||||
|
.in(SysDept::getDeptId, deptIds)
|
||||||
|
);
|
||||||
|
return StreamUtils.toMap(list, SysDept::getDeptId, SysDept::getDeptName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import org.dromara.common.core.utils.StreamUtils;
|
|||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.system.domain.SysDept;
|
|
||||||
import org.dromara.system.domain.SysPost;
|
import org.dromara.system.domain.SysPost;
|
||||||
import org.dromara.system.domain.SysUserPost;
|
import org.dromara.system.domain.SysUserPost;
|
||||||
import org.dromara.system.domain.bo.SysPostBo;
|
import org.dromara.system.domain.bo.SysPostBo;
|
||||||
@ -25,7 +24,7 @@ import org.dromara.system.mapper.SysUserPostMapper;
|
|||||||
import org.dromara.system.service.ISysPostService;
|
import org.dromara.system.service.ISysPostService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -92,9 +91,7 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
|||||||
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||||
//部门树搜索
|
//部门树搜索
|
||||||
wrapper.and(x -> {
|
wrapper.and(x -> {
|
||||||
List<SysDept> deptList = deptMapper.selectListByParentId(bo.getBelongDeptId());
|
List<Long> deptIds = deptMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
|
||||||
deptIds.add(bo.getBelongDeptId());
|
|
||||||
x.in(SysPost::getDeptId, deptIds);
|
x.in(SysPost::getDeptId, deptIds);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -217,14 +214,14 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deletePostByIds(Long[] postIds) {
|
public int deletePostByIds(List<Long> postIds) {
|
||||||
for (Long postId : postIds) {
|
List<SysPost> list = baseMapper.selectByIds(postIds);
|
||||||
SysPost post = baseMapper.selectById(postId);
|
for (SysPost post : list) {
|
||||||
if (countUserPostById(postId) > 0) {
|
if (this.countUserPostById(post.getPostId()) > 0) {
|
||||||
throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName()));
|
throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return baseMapper.deleteByIds(Arrays.asList(postIds));
|
return baseMapper.deleteByIds(postIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,4 +248,23 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
|||||||
return baseMapper.updateById(post);
|
return baseMapper.updateById(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||||
|
*
|
||||||
|
* @param postIds 岗位 ID 列表
|
||||||
|
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<Long, String> selectPostNamesByIds(List<Long> postIds) {
|
||||||
|
if (CollUtil.isEmpty(postIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<SysPost> list = baseMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<SysPost>()
|
||||||
|
.select(SysPost::getPostId, SysPost::getPostName)
|
||||||
|
.in(SysPost::getPostId, postIds)
|
||||||
|
);
|
||||||
|
return StreamUtils.toMap(list, SysPost::getPostId, SysPost::getPostName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -549,4 +549,23 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色 ID 列表查询角色名称映射关系
|
||||||
|
*
|
||||||
|
* @param roleIds 角色 ID 列表
|
||||||
|
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<Long, String> selectRoleNamesByIds(List<Long> roleIds) {
|
||||||
|
if (CollUtil.isEmpty(roleIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<SysRole> list = baseMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<SysRole>()
|
||||||
|
.select(SysRole::getRoleId, SysRole::getRoleName)
|
||||||
|
.in(SysRole::getRoleId, roleIds)
|
||||||
|
);
|
||||||
|
return StreamUtils.toMap(list, SysRole::getRoleId, SysRole::getRoleName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,10 @@ import org.dromara.common.core.utils.*;
|
|||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.system.domain.*;
|
import org.dromara.system.domain.SysRole;
|
||||||
|
import org.dromara.system.domain.SysUser;
|
||||||
|
import org.dromara.system.domain.SysUserPost;
|
||||||
|
import org.dromara.system.domain.SysUserRole;
|
||||||
import org.dromara.system.domain.bo.SysUserBo;
|
import org.dromara.system.domain.bo.SysUserBo;
|
||||||
import org.dromara.system.domain.vo.SysPostVo;
|
import org.dromara.system.domain.vo.SysPostVo;
|
||||||
import org.dromara.system.domain.vo.SysRoleVo;
|
import org.dromara.system.domain.vo.SysRoleVo;
|
||||||
@ -36,7 +39,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户 业务层处理
|
* 用户 业务层处理
|
||||||
@ -79,10 +81,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|||||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||||
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
||||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
List<Long> deptIds = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
w.in("u.dept_id", deptIds);
|
||||||
ids.add(user.getDeptId());
|
|
||||||
w.in("u.dept_id", ids);
|
|
||||||
}).orderByAsc("u.user_id");
|
}).orderByAsc("u.user_id");
|
||||||
return baseMapper.selectUserExportList(wrapper);
|
return baseMapper.selectUserExportList(wrapper);
|
||||||
}
|
}
|
||||||
@ -100,9 +100,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|||||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||||
SysUser::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
SysUser::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
List<Long> ids = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
|
||||||
ids.add(user.getDeptId());
|
|
||||||
w.in(SysUser::getDeptId, ids);
|
w.in(SysUser::getDeptId, ids);
|
||||||
}).orderByAsc(SysUser::getUserId);
|
}).orderByAsc(SysUser::getUserId);
|
||||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||||
@ -748,69 +746,12 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|||||||
if (CollUtil.isEmpty(userIds)) {
|
if (CollUtil.isEmpty(userIds)) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
return baseMapper.selectList(
|
List<SysUser> list = baseMapper.selectList(
|
||||||
new LambdaQueryWrapper<SysUser>()
|
new LambdaQueryWrapper<SysUser>()
|
||||||
.select(SysUser::getUserId, SysUser::getNickName)
|
.select(SysUser::getUserId, SysUser::getNickName)
|
||||||
.in(SysUser::getUserId, userIds)
|
.in(SysUser::getUserId, userIds)
|
||||||
).stream()
|
);
|
||||||
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName));
|
return StreamUtils.toMap(list, SysUser::getUserId, SysUser::getNickName);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据角色 ID 列表查询角色名称映射关系
|
|
||||||
*
|
|
||||||
* @param roleIds 角色 ID 列表
|
|
||||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Map<Long, String> selectRoleNamesByIds(List<Long> roleIds) {
|
|
||||||
if (CollUtil.isEmpty(roleIds)) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
return roleMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<SysRole>()
|
|
||||||
.select(SysRole::getRoleId, SysRole::getRoleName)
|
|
||||||
.in(SysRole::getRoleId, roleIds)
|
|
||||||
).stream()
|
|
||||||
.collect(Collectors.toMap(SysRole::getRoleId, SysRole::getRoleName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据部门 ID 列表查询部门名称映射关系
|
|
||||||
*
|
|
||||||
* @param deptIds 部门 ID 列表
|
|
||||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Map<Long, String> selectDeptNamesByIds(List<Long> deptIds) {
|
|
||||||
if (CollUtil.isEmpty(deptIds)) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
return deptMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<SysDept>()
|
|
||||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
|
||||||
.in(SysDept::getDeptId, deptIds)
|
|
||||||
).stream()
|
|
||||||
.collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
|
||||||
*
|
|
||||||
* @param postIds 岗位 ID 列表
|
|
||||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Map<Long, String> selectPostNamesByIds(List<Long> postIds) {
|
|
||||||
if (CollUtil.isEmpty(postIds)) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
return postMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<SysPost>()
|
|
||||||
.select(SysPost::getPostId, SysPost::getPostName)
|
|
||||||
.in(SysPost::getPostId, postIds)
|
|
||||||
).stream()
|
|
||||||
.collect(Collectors.toMap(SysPost::getPostId, SysPost::getPostName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程实例 服务层实现
|
* 流程实例 服务层实现
|
||||||
@ -203,9 +203,11 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 获取定义信息
|
// 获取定义信息
|
||||||
Map<Long, Definition> definitionMap = defService.getByIds(
|
Map<Long, Definition> definitionMap = StreamUtils.toMap(
|
||||||
StreamUtils.toList(instances, Instance::getDefinitionId)
|
defService.getByIds(StreamUtils.toList(instances, Instance::getDefinitionId)),
|
||||||
).stream().collect(Collectors.toMap(Definition::getId, definition -> definition));
|
Definition::getId,
|
||||||
|
Function.identity()
|
||||||
|
);
|
||||||
|
|
||||||
// 逐一触发删除事件
|
// 逐一触发删除事件
|
||||||
instances.forEach(instance -> {
|
instances.forEach(instance -> {
|
||||||
|
@ -12,9 +12,7 @@ import org.dromara.common.core.domain.dto.TaskAssigneeDTO;
|
|||||||
import org.dromara.common.core.domain.dto.UserDTO;
|
import org.dromara.common.core.domain.dto.UserDTO;
|
||||||
import org.dromara.common.core.domain.model.TaskAssigneeBody;
|
import org.dromara.common.core.domain.model.TaskAssigneeBody;
|
||||||
import org.dromara.common.core.enums.FormatsType;
|
import org.dromara.common.core.enums.FormatsType;
|
||||||
import org.dromara.common.core.service.DeptService;
|
import org.dromara.common.core.service.*;
|
||||||
import org.dromara.common.core.service.TaskAssigneeService;
|
|
||||||
import org.dromara.common.core.service.UserService;
|
|
||||||
import org.dromara.common.core.utils.DateUtils;
|
import org.dromara.common.core.utils.DateUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.warm.flow.ui.dto.HandlerFunDto;
|
import org.dromara.warm.flow.ui.dto.HandlerFunDto;
|
||||||
@ -45,6 +43,8 @@ public class FlwTaskAssigneeServiceImpl implements IFlwTaskAssigneeService, Hand
|
|||||||
private final TaskAssigneeService taskAssigneeService;
|
private final TaskAssigneeService taskAssigneeService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final DeptService deptService;
|
private final DeptService deptService;
|
||||||
|
private final RoleService roleService;
|
||||||
|
private final PostService postService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取办理人权限设置列表tabs页签
|
* 获取办理人权限设置列表tabs页签
|
||||||
@ -216,9 +216,9 @@ public class FlwTaskAssigneeServiceImpl implements IFlwTaskAssigneeService, Hand
|
|||||||
private Map<Long, String> getNamesByType(TaskAssigneeEnum type, List<Long> ids) {
|
private Map<Long, String> getNamesByType(TaskAssigneeEnum type, List<Long> ids) {
|
||||||
return switch (type) {
|
return switch (type) {
|
||||||
case USER -> userService.selectUserNamesByIds(ids);
|
case USER -> userService.selectUserNamesByIds(ids);
|
||||||
case ROLE -> userService.selectRoleNamesByIds(ids);
|
case ROLE -> roleService.selectRoleNamesByIds(ids);
|
||||||
case DEPT -> userService.selectDeptNamesByIds(ids);
|
case DEPT -> deptService.selectDeptNamesByIds(ids);
|
||||||
case POST -> userService.selectPostNamesByIds(ids);
|
case POST -> postService.selectPostNamesByIds(ids);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user