update 优化 重构代码逻辑 封装简化方法

This commit is contained in:
疯狂的狮子Li
2025-07-02 13:45:53 +08:00
parent c519815fd4
commit 06b145cb83
18 changed files with 236 additions and 157 deletions

View File

@@ -3,6 +3,7 @@ package org.dromara.system.api;
import org.dromara.system.api.domain.vo.RemoteDeptVo; import org.dromara.system.api.domain.vo.RemoteDeptVo;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 部门服务 * 部门服务
@@ -34,4 +35,12 @@ public interface RemoteDeptService {
*/ */
List<RemoteDeptVo> selectDeptsByList(); List<RemoteDeptVo> selectDeptsByList();
/**
* 根据部门 ID 列表查询部门名称映射关系
*
* @param deptIds 部门 ID 列表
* @return Map其中 key 为部门 IDvalue 为对应的部门名称
*/
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
} }

View File

@@ -0,0 +1,21 @@
package org.dromara.system.api;
import java.util.List;
import java.util.Map;
/**
* 岗位服务
*
* @author Lion Li
*/
public interface RemotePostService {
/**
* 根据岗位 ID 列表查询岗位名称映射关系
*
* @param postIds 岗位 ID 列表
* @return Map其中 key 为岗位 IDvalue 为对应的岗位名称
*/
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
}

View File

@@ -0,0 +1,21 @@
package org.dromara.system.api;
import java.util.List;
import java.util.Map;
/**
* 角色服务
*
* @author Lion Li
*/
public interface RemoteRoleService {
/**
* 根据角色 ID 列表查询角色名称映射关系
*
* @param roleIds 角色 ID 列表
* @return Map其中 key 为角色 IDvalue 为对应的角色名称
*/
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
}

View File

@@ -165,28 +165,4 @@ public interface RemoteUserService {
*/ */
Map<Long, String> selectUserNamesByIds(List<Long> userIds); Map<Long, String> selectUserNamesByIds(List<Long> userIds);
/**
* 根据角色 ID 列表查询角色名称映射关系
*
* @param roleIds 角色 ID 列表
* @return Map其中 key 为角色 IDvalue 为对应的角色名称
*/
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
/**
* 根据部门 ID 列表查询部门名称映射关系
*
* @param deptIds 部门 ID 列表
* @return Map其中 key 为部门 IDvalue 为对应的部门名称
*/
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
/**
* 根据岗位 ID 列表查询岗位名称映射关系
*
* @param postIds 岗位 ID 列表
* @return Map其中 key 为岗位 IDvalue 为对应的岗位名称
*/
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
} }

View File

@@ -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)));
} }
/** /**

View File

@@ -9,7 +9,6 @@ import org.apache.dubbo.config.annotation.DubboService;
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.api.RemoteDataScopeService; import org.dromara.system.api.RemoteDataScopeService;
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;
@@ -68,13 +67,8 @@ public class RemoteDataScopeServiceImpl implements RemoteDataScopeService {
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";
} }
} }

View File

@@ -1,15 +1,23 @@
package org.dromara.system.dubbo; package org.dromara.system.dubbo;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.constant.SystemConstants;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.system.api.RemoteDeptService; import org.dromara.system.api.RemoteDeptService;
import org.dromara.system.api.domain.vo.RemoteDeptVo; import org.dromara.system.api.domain.vo.RemoteDeptVo;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.vo.SysDeptVo; import org.dromara.system.domain.vo.SysDeptVo;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.service.ISysDeptService; import org.dromara.system.service.ISysDeptService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 部门服务 * 部门服务
@@ -21,7 +29,8 @@ import java.util.List;
@DubboService @DubboService
public class RemoteDeptServiceImpl implements RemoteDeptService { public class RemoteDeptServiceImpl implements RemoteDeptService {
private final ISysDeptService sysDeptService; private final ISysDeptService deptService;
private final SysDeptMapper deptMapper;
/** /**
* 通过部门ID查询部门名称 * 通过部门ID查询部门名称
@@ -31,7 +40,7 @@ public class RemoteDeptServiceImpl implements RemoteDeptService {
*/ */
@Override @Override
public String selectDeptNameByIds(String deptIds) { public String selectDeptNameByIds(String deptIds) {
return sysDeptService.selectDeptNameByIds(deptIds); return deptService.selectDeptNameByIds(deptIds);
} }
/** /**
@@ -42,7 +51,7 @@ public class RemoteDeptServiceImpl implements RemoteDeptService {
*/ */
@Override @Override
public Long selectDeptLeaderById(Long deptId) { public Long selectDeptLeaderById(Long deptId) {
SysDeptVo vo = sysDeptService.selectDeptById(deptId); SysDeptVo vo = deptService.selectDeptById(deptId);
return vo.getLeader(); return vo.getLeader();
} }
@@ -53,8 +62,29 @@ public class RemoteDeptServiceImpl implements RemoteDeptService {
*/ */
@Override @Override
public List<RemoteDeptVo> selectDeptsByList() { public List<RemoteDeptVo> selectDeptsByList() {
List<SysDeptVo> list = sysDeptService.selectDeptsSimple(); List<SysDeptVo> list = deptMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)
.eq(SysDept::getStatus, SystemConstants.NORMAL));
return BeanUtil.copyToList(list, RemoteDeptVo.class); return BeanUtil.copyToList(list, RemoteDeptVo.class);
} }
/**
* 根据部门 ID 列表查询部门名称映射关系
*
* @param deptIds 部门 ID 列表
* @return Map其中 key 为部门 IDvalue 为对应的部门名称
*/
@Override
public Map<Long, String> selectDeptNamesByIds(List<Long> deptIds) {
if (CollUtil.isEmpty(deptIds)) {
return Collections.emptyMap();
}
List<SysDept> list = deptMapper.selectList(
new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId, SysDept::getDeptName)
.in(SysDept::getDeptId, deptIds)
);
return StreamUtils.toMap(list, SysDept::getDeptId, SysDept::getDeptName);
}
} }

View File

@@ -0,0 +1,48 @@
package org.dromara.system.dubbo;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.system.api.RemotePostService;
import org.dromara.system.domain.SysPost;
import org.dromara.system.mapper.SysPostMapper;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 岗位服务
*
* @author Lion Li
*/
@RequiredArgsConstructor
@Service
@DubboService
public class RemotePostServiceImpl implements RemotePostService {
private final SysPostMapper postMapper;
/**
* 根据岗位 ID 列表查询岗位名称映射关系
*
* @param postIds 岗位 ID 列表
* @return Map其中 key 为岗位 IDvalue 为对应的岗位名称
*/
@Override
public Map<Long, String> selectPostNamesByIds(List<Long> postIds) {
if (CollUtil.isEmpty(postIds)) {
return Collections.emptyMap();
}
List<SysPost> list = postMapper.selectList(
new LambdaQueryWrapper<SysPost>()
.select(SysPost::getPostId, SysPost::getPostName)
.in(SysPost::getPostId, postIds)
);
return StreamUtils.toMap(list, SysPost::getPostId, SysPost::getPostName);
}
}

View File

@@ -0,0 +1,48 @@
package org.dromara.system.dubbo;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.system.api.RemoteRoleService;
import org.dromara.system.domain.SysRole;
import org.dromara.system.mapper.SysRoleMapper;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 角色服务
*
* @author Lion Li
*/
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteRoleServiceImpl implements RemoteRoleService {
private final SysRoleMapper roleMapper;
/**
* 根据角色 ID 列表查询角色名称映射关系
*
* @param roleIds 角色 ID 列表
* @return Map其中 key 为角色 IDvalue 为对应的角色名称
*/
@Override
public Map<Long, String> selectRoleNamesByIds(List<Long> roleIds) {
if (CollUtil.isEmpty(roleIds)) {
return Collections.emptyMap();
}
List<SysRole> list = roleMapper.selectList(
new LambdaQueryWrapper<SysRole>()
.select(SysRole::getRoleId, SysRole::getRoleName)
.in(SysRole::getRoleId, roleIds)
);
return StreamUtils.toMap(list, SysRole::getRoleId, SysRole::getRoleName);
}
}

View File

@@ -24,18 +24,21 @@ import org.dromara.system.api.model.LoginUser;
import org.dromara.system.api.model.PostDTO; import org.dromara.system.api.model.PostDTO;
import org.dromara.system.api.model.RoleDTO; import org.dromara.system.api.model.RoleDTO;
import org.dromara.system.api.model.XcxLoginUser; import org.dromara.system.api.model.XcxLoginUser;
import org.dromara.system.domain.*; 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.SysDeptVo; import org.dromara.system.domain.vo.SysDeptVo;
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;
import org.dromara.system.domain.vo.SysUserVo; import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.mapper.*; import org.dromara.system.mapper.SysUserMapper;
import org.dromara.system.mapper.SysUserPostMapper;
import org.dromara.system.mapper.SysUserRoleMapper;
import org.dromara.system.service.*; import org.dromara.system.service.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 用户服务 * 用户服务
@@ -54,9 +57,6 @@ public class RemoteUserServiceImpl implements RemoteUserService {
private final ISysDeptService deptService; private final ISysDeptService deptService;
private final ISysPostService postService; private final ISysPostService postService;
private final SysUserMapper userMapper; private final SysUserMapper userMapper;
private final SysRoleMapper roleMapper;
private final SysDeptMapper deptMapper;
private final SysPostMapper postMapper;
private final SysUserRoleMapper userRoleMapper; private final SysUserRoleMapper userRoleMapper;
private final SysUserPostMapper userPostMapper; private final SysUserPostMapper userPostMapper;
@@ -403,74 +403,16 @@ public class RemoteUserServiceImpl implements RemoteUserService {
* @param userIds 用户 ID 列表 * @param userIds 用户 ID 列表
* @return Map其中 key 为用户 IDvalue 为对应的用户名称 * @return Map其中 key 为用户 IDvalue 为对应的用户名称
*/ */
@Override
public Map<Long, String> selectUserNamesByIds(List<Long> userIds) { public Map<Long, String> selectUserNamesByIds(List<Long> userIds) {
if (CollUtil.isEmpty(userIds)) { if (CollUtil.isEmpty(userIds)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
return userMapper.selectList( List<SysUser> list = userMapper.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 为角色 IDvalue 为对应的角色名称
*/
@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 为部门 IDvalue 为对应的部门名称
*/
@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 为岗位 IDvalue 为对应的岗位名称
*/
@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));
} }
} }

View File

@@ -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;
@@ -69,6 +70,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查询部门树信息
* *

View File

@@ -144,10 +144,4 @@ public interface ISysDeptService {
*/ */
int deleteDeptById(Long deptId); int deleteDeptById(Long deptId);
/**
* 查询部门(简单查询)
*
* @return 部门列表
*/
List<SysDeptVo> selectDeptsSimple();
} }

View File

@@ -110,7 +110,7 @@ public interface ISysPostService {
* @param postIds 需要删除的岗位ID * @param postIds 需要删除的岗位ID
* @return 结果 * @return 结果
*/ */
int deletePostByIds(Long[] postIds); int deletePostByIds(List<Long> postIds);
/** /**
* 新增保存岗位信息 * 新增保存岗位信息

View File

@@ -107,10 +107,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
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);
}); });
} }
@@ -384,16 +381,4 @@ public class SysDeptServiceImpl implements ISysDeptService {
return baseMapper.deleteById(deptId); return baseMapper.deleteById(deptId);
} }
/**
* 查询部门(简单查询)
*
* @return 部门列表
*/
@Override
public List<SysDeptVo> selectDeptsSimple() {
return baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)
.eq(SysDept::getStatus, SystemConstants.NORMAL));
}
} }

View File

@@ -13,7 +13,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;
@@ -24,7 +23,6 @@ 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.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -91,9 +89,7 @@ public class SysPostServiceImpl implements ISysPostService {
} 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);
}); });
} }
@@ -216,14 +212,14 @@ public class SysPostServiceImpl implements ISysPostService {
* @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);
} }
/** /**

View File

@@ -77,10 +77,8 @@ public class SysUserServiceImpl implements ISysUserService {
.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);
} }
@@ -98,9 +96,7 @@ public class SysUserServiceImpl implements ISysUserService {
.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())) {

View File

@@ -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 -> {

View File

@@ -11,9 +11,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.enums.FormatsType; import org.dromara.common.core.enums.FormatsType;
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.system.api.RemoteDeptService; import org.dromara.system.api.*;
import org.dromara.system.api.RemoteTaskAssigneeService;
import org.dromara.system.api.RemoteUserService;
import org.dromara.system.api.domain.bo.RemoteTaskAssigneeBo; import org.dromara.system.api.domain.bo.RemoteTaskAssigneeBo;
import org.dromara.system.api.domain.vo.RemoteDeptVo; import org.dromara.system.api.domain.vo.RemoteDeptVo;
import org.dromara.system.api.domain.vo.RemoteTaskAssigneeVo; import org.dromara.system.api.domain.vo.RemoteTaskAssigneeVo;
@@ -50,6 +48,10 @@ public class FlwTaskAssigneeServiceImpl implements IFlwTaskAssigneeService, Hand
private RemoteUserService remoteUserService; private RemoteUserService remoteUserService;
@DubboReference @DubboReference
private RemoteDeptService remoteDeptService; private RemoteDeptService remoteDeptService;
@DubboReference
private RemoteRoleService remoteRoleService;
@DubboReference
private RemotePostService remotePostService;
/** /**
* 获取办理人权限设置列表tabs页签 * 获取办理人权限设置列表tabs页签
@@ -226,9 +228,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 -> remoteUserService.selectUserNamesByIds(ids); case USER -> remoteUserService.selectUserNamesByIds(ids);
case ROLE -> remoteUserService.selectRoleNamesByIds(ids); case ROLE -> remoteRoleService.selectRoleNamesByIds(ids);
case DEPT -> remoteUserService.selectDeptNamesByIds(ids); case DEPT -> remoteDeptService.selectDeptNamesByIds(ids);
case POST -> remoteUserService.selectPostNamesByIds(ids); case POST -> remotePostService.selectPostNamesByIds(ids);
}; };
} }