mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-10-14 14:10:24 +00:00
update 优化 重构代码逻辑 封装简化方法
This commit is contained in:
@@ -3,6 +3,7 @@ package org.dromara.system.api;
|
||||
import org.dromara.system.api.domain.vo.RemoteDeptVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门服务
|
||||
@@ -34,4 +35,12 @@ public interface RemoteDeptService {
|
||||
*/
|
||||
List<RemoteDeptVo> selectDeptsByList();
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
|
||||
|
||||
}
|
||||
|
@@ -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 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
|
||||
|
||||
}
|
@@ -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 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
|
||||
|
||||
}
|
@@ -165,28 +165,4 @@ public interface RemoteUserService {
|
||||
*/
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -107,7 +108,7 @@ public class SysPostController extends BaseController {
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
return toAjax(postService.deletePostByIds(Arrays.asList(postIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,7 +9,6 @@ import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.system.api.RemoteDataScopeService;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysRoleDept;
|
||||
import org.dromara.system.mapper.SysDeptMapper;
|
||||
import org.dromara.system.mapper.SysRoleDeptMapper;
|
||||
@@ -68,13 +67,8 @@ public class RemoteDataScopeServiceImpl implements RemoteDataScopeService {
|
||||
if (ObjectUtil.isNull(deptId)) {
|
||||
return "-1";
|
||||
}
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(deptId);
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(deptId);
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
return StreamUtils.join(ids, Convert::toStr);
|
||||
}
|
||||
return "-1";
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(deptId);
|
||||
return CollUtil.isNotEmpty(deptIds) ? StreamUtils.join(deptIds, Convert::toStr) : "-1";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,15 +1,23 @@
|
||||
package org.dromara.system.dubbo;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.constant.SystemConstants;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.system.api.RemoteDeptService;
|
||||
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.mapper.SysDeptMapper;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门服务
|
||||
@@ -21,7 +29,8 @@ import java.util.List;
|
||||
@DubboService
|
||||
public class RemoteDeptServiceImpl implements RemoteDeptService {
|
||||
|
||||
private final ISysDeptService sysDeptService;
|
||||
private final ISysDeptService deptService;
|
||||
private final SysDeptMapper deptMapper;
|
||||
|
||||
/**
|
||||
* 通过部门ID查询部门名称
|
||||
@@ -31,7 +40,7 @@ public class RemoteDeptServiceImpl implements RemoteDeptService {
|
||||
*/
|
||||
@Override
|
||||
public String selectDeptNameByIds(String deptIds) {
|
||||
return sysDeptService.selectDeptNameByIds(deptIds);
|
||||
return deptService.selectDeptNameByIds(deptIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +51,7 @@ public class RemoteDeptServiceImpl implements RemoteDeptService {
|
||||
*/
|
||||
@Override
|
||||
public Long selectDeptLeaderById(Long deptId) {
|
||||
SysDeptVo vo = sysDeptService.selectDeptById(deptId);
|
||||
SysDeptVo vo = deptService.selectDeptById(deptId);
|
||||
return vo.getLeader();
|
||||
}
|
||||
|
||||
@@ -53,8 +62,29 @@ public class RemoteDeptServiceImpl implements RemoteDeptService {
|
||||
*/
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门 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 = deptMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.in(SysDept::getDeptId, deptIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysDept::getDeptId, SysDept::getDeptName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
@@ -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 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
@@ -24,18 +24,21 @@ import org.dromara.system.api.model.LoginUser;
|
||||
import org.dromara.system.api.model.PostDTO;
|
||||
import org.dromara.system.api.model.RoleDTO;
|
||||
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.vo.SysDeptVo;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
import org.dromara.system.domain.vo.SysRoleVo;
|
||||
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.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户服务
|
||||
@@ -54,9 +57,6 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||
private final ISysDeptService deptService;
|
||||
private final ISysPostService postService;
|
||||
private final SysUserMapper userMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
private final SysDeptMapper deptMapper;
|
||||
private final SysPostMapper postMapper;
|
||||
private final SysUserRoleMapper userRoleMapper;
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
|
||||
@@ -403,74 +403,16 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||
* @param userIds 用户 ID 列表
|
||||
* @return Map,其中 key 为用户 ID,value 为对应的用户名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectUserNamesByIds(List<Long> userIds) {
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return userMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserId, SysUser::getNickName)
|
||||
.in(SysUser::getUserId, userIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(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));
|
||||
List<SysUser> list = userMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserId, SysUser::getNickName)
|
||||
.in(SysUser::getUserId, userIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysUser::getUserId, SysUser::getNickName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
@@ -69,6 +70,19 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
||||
.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查询部门树信息
|
||||
*
|
||||
|
@@ -144,10 +144,4 @@ public interface ISysDeptService {
|
||||
*/
|
||||
int deleteDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 查询部门(简单查询)
|
||||
*
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<SysDeptVo> selectDeptsSimple();
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ public interface ISysPostService {
|
||||
* @param postIds 需要删除的岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePostByIds(Long[] postIds);
|
||||
int deletePostByIds(List<Long> postIds);
|
||||
|
||||
/**
|
||||
* 新增保存岗位信息
|
||||
|
@@ -107,10 +107,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||
//部门树搜索
|
||||
lqw.and(x -> {
|
||||
Long parentId = bo.getBelongDeptId();
|
||||
List<SysDept> deptList = baseMapper.selectListByParentId(parentId);
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(parentId);
|
||||
List<Long> deptIds = baseMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||
x.in(SysDept::getDeptId, deptIds);
|
||||
});
|
||||
}
|
||||
@@ -384,16 +381,4 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
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.SysUserPost;
|
||||
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.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -91,9 +89,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||
//部门树搜索
|
||||
wrapper.and(x -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(bo.getBelongDeptId());
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(bo.getBelongDeptId());
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||
x.in(SysPost::getDeptId, deptIds);
|
||||
});
|
||||
}
|
||||
@@ -216,14 +212,14 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(Long[] postIds) {
|
||||
for (Long postId : postIds) {
|
||||
SysPost post = baseMapper.selectById(postId);
|
||||
if (countUserPostById(postId) > 0) {
|
||||
public int deletePostByIds(List<Long> postIds) {
|
||||
List<SysPost> list = baseMapper.selectByIds(postIds);
|
||||
for (SysPost post : list) {
|
||||
if (this.countUserPostById(post.getPostId()) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName()));
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteByIds(Arrays.asList(postIds));
|
||||
return baseMapper.deleteByIds(postIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -77,10 +77,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(user.getDeptId());
|
||||
w.in("u.dept_id", ids);
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||
w.in("u.dept_id", deptIds);
|
||||
}).orderByAsc("u.user_id");
|
||||
return baseMapper.selectUserExportList(wrapper);
|
||||
}
|
||||
@@ -98,9 +96,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysUser::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(user.getDeptId());
|
||||
List<Long> ids = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||
w.in(SysUser::getDeptId, ids);
|
||||
}).orderByAsc(SysUser::getUserId);
|
||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||
|
@@ -49,7 +49,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 流程实例 服务层实现
|
||||
@@ -203,9 +203,11 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
return false;
|
||||
}
|
||||
// 获取定义信息
|
||||
Map<Long, Definition> definitionMap = defService.getByIds(
|
||||
StreamUtils.toList(instances, Instance::getDefinitionId)
|
||||
).stream().collect(Collectors.toMap(Definition::getId, definition -> definition));
|
||||
Map<Long, Definition> definitionMap = StreamUtils.toMap(
|
||||
defService.getByIds(StreamUtils.toList(instances, Instance::getDefinitionId)),
|
||||
Definition::getId,
|
||||
Function.identity()
|
||||
);
|
||||
|
||||
// 逐一触发删除事件
|
||||
instances.forEach(instance -> {
|
||||
|
@@ -11,9 +11,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.enums.FormatsType;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.system.api.RemoteDeptService;
|
||||
import org.dromara.system.api.RemoteTaskAssigneeService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.*;
|
||||
import org.dromara.system.api.domain.bo.RemoteTaskAssigneeBo;
|
||||
import org.dromara.system.api.domain.vo.RemoteDeptVo;
|
||||
import org.dromara.system.api.domain.vo.RemoteTaskAssigneeVo;
|
||||
@@ -50,6 +48,10 @@ public class FlwTaskAssigneeServiceImpl implements IFlwTaskAssigneeService, Hand
|
||||
private RemoteUserService remoteUserService;
|
||||
@DubboReference
|
||||
private RemoteDeptService remoteDeptService;
|
||||
@DubboReference
|
||||
private RemoteRoleService remoteRoleService;
|
||||
@DubboReference
|
||||
private RemotePostService remotePostService;
|
||||
|
||||
/**
|
||||
* 获取办理人权限设置列表tabs页签
|
||||
@@ -226,9 +228,9 @@ public class FlwTaskAssigneeServiceImpl implements IFlwTaskAssigneeService, Hand
|
||||
private Map<Long, String> getNamesByType(TaskAssigneeEnum type, List<Long> ids) {
|
||||
return switch (type) {
|
||||
case USER -> remoteUserService.selectUserNamesByIds(ids);
|
||||
case ROLE -> remoteUserService.selectRoleNamesByIds(ids);
|
||||
case DEPT -> remoteUserService.selectDeptNamesByIds(ids);
|
||||
case POST -> remoteUserService.selectPostNamesByIds(ids);
|
||||
case ROLE -> remoteRoleService.selectRoleNamesByIds(ids);
|
||||
case DEPT -> remoteDeptService.selectDeptNamesByIds(ids);
|
||||
case POST -> remotePostService.selectPostNamesByIds(ids);
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user