✨ Introducing new features. org component

This commit is contained in:
lbw committed 2023-12-03 23:44:09 +08:00
1 parent a6457abe8e
commit 747acc370a
13 files changed
+543 -462

No files matched your search

@@ -1,44 +0,0 @@
package com.pig4cloud.pigx.flow.task.controller;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.flow.task.service.IOrgService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author : willian fu
* @date : 2022/6/27
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/org")
public class OrgController {
private final IOrgService orgService;
/**
* 查询组织架构树
* @param deptId 部门id
* @param showLeave 是否显示离职员工
* @return 组织架构树数据
*/
@GetMapping("tree")
public R getOrgTreeData(@RequestParam(defaultValue = "0") Long deptId, String type,
@RequestParam(defaultValue = "false") Boolean showLeave) {
return orgService.getOrgTreeData(deptId, type, showLeave);
}
/**
* 模糊搜索用户
* @param userName 用户名/拼音/首字母
* @return 匹配到的用户
*/
@GetMapping("tree/user/search")
public R getOrgTreeUser(@RequestParam String userName) {
return orgService.getOrgTreeUser(userName.trim());
}
}
@@ -1,27 +0,0 @@
package com.pig4cloud.pigx.flow.task.service;
import com.pig4cloud.pigx.common.core.util.R;
/**
* @author : willian fu
* @version : 1.0
*/
public interface IOrgService {
/**
* 查询组织架构树
* @param deptId 部门id
* @param type 只查询部门架构
* @param showLeave 是否显示离职员工
* @return 组织架构树数据
*/
R getOrgTreeData(Long deptId, String type, Boolean showLeave);
/**
* 模糊搜索用户
* @param userName 用户名/拼音/首字母
* @return 匹配到的用户
*/
R getOrgTreeUser(String userName);
}
@@ -1,131 +0,0 @@
package com.pig4cloud.pigx.flow.task.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil;
import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.api.entity.SysRole;
import com.pig4cloud.pigx.admin.api.entity.SysUser;
import com.pig4cloud.pigx.admin.api.feign.RemoteDeptService;
import com.pig4cloud.pigx.admin.api.feign.RemoteRoleService;
import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.core.util.RetOps;
import com.pig4cloud.pigx.flow.task.constant.NodeUserTypeEnum;
import com.pig4cloud.pigx.flow.task.service.IOrgService;
import com.pig4cloud.pigx.flow.task.utils.DataUtil;
import com.pig4cloud.pigx.flow.task.vo.OrgTreeVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class OrgServiceImpl implements IOrgService {
private final RemoteUserService remoteUserService;
private final RemoteRoleService remoteRoleService;
private final RemoteDeptService remoteDeptService;
/**
* 查询组织架构树
* @param deptId 部门id
* @param type 只查询部门架构
* @param showLeave 是否显示离职员工
* @return 组织架构树数据
*/
@Override
public R getOrgTreeData(Long deptId, String type, Boolean showLeave) {
List<OrgTreeVo> orgs = new LinkedList<>();
if (StrUtil.equals(type, NodeUserTypeEnum.ROLE.getKey())) {
// 角色
List<SysRole> roleList = remoteRoleService.getAllRole().getData();
for (SysRole role : roleList) {
OrgTreeVo orgTreeVo = new OrgTreeVo();
orgTreeVo.setId(role.getRoleId());
orgTreeVo.setName(role.getRoleName());
orgTreeVo.setType(NodeUserTypeEnum.ROLE.getKey());
orgTreeVo.setSelected(false);
orgs.add(orgTreeVo);
}
Dict dict = Dict.create().set("roleList", orgs).set("childDepartments", orgs).set("employees",
new ArrayList<>());
return R.ok(dict);
}
Dict dict = Dict.create().set("titleDepartments", new ArrayList<>()).set("roleList", new ArrayList<>())
.set("employees", new ArrayList<>());
List<SysDept> deptList = remoteDeptService.getAllDept().getData();
// 查询所有部门及员工
{
List deptVoList = new ArrayList();
for (SysDept dept : deptList) {
OrgTreeVo orgTreeVo = new OrgTreeVo();
orgTreeVo.setId(dept.getDeptId());
orgTreeVo.setName(dept.getName());
orgTreeVo.setType(NodeUserTypeEnum.DEPT.getKey());
orgTreeVo.setSelected(false);
deptVoList.add(orgTreeVo);
}
dict.set("childDepartments", deptVoList);
}
if (!StrUtil.equals(type, NodeUserTypeEnum.DEPT.getKey())) {
List userVoList = new ArrayList();
List<SysUser> userList = remoteUserService.getUserIdListByDeptIdList(CollUtil.toList(deptId)).getData();
for (SysUser user : userList) {
OrgTreeVo orgTreeVo = new OrgTreeVo();
orgTreeVo.setId(user.getUserId());
orgTreeVo.setName(user.getUsername());
orgTreeVo.setType(NodeUserTypeEnum.USER.getKey());
orgTreeVo.setSelected(false);
orgTreeVo.setAvatar(user.getAvatar());
userVoList.add(orgTreeVo);
}
dict.set("employees", userVoList);
}
if (deptId > 0) {
List<SysDept> allDept = remoteDeptService.getAllDept().getData();
List<SysDept> depts = DataUtil.selectParentByDept(deptId, allDept);
dict.set("titleDepartments", CollUtil.reverse(depts));
}
return R.ok(dict);
}
/**
* 模糊搜索用户
* @param userName 用户名/拼音/首字母
* @return 匹配到的用户
*/
@Override
public R getOrgTreeUser(String userName) {
return R.ok(RetOps.of(remoteUserService.getUserListByUserName(userName)).getData().orElseGet(ArrayList::new)
.stream().map(user -> {
OrgTreeVo orgTreeVo = new OrgTreeVo();
orgTreeVo.setId(user.getUserId());
orgTreeVo.setName(user.getUsername());
orgTreeVo.setType(NodeUserTypeEnum.USER.getKey());
orgTreeVo.setSelected(false);
orgTreeVo.setAvatar(user.getAvatar());
return orgTreeVo;
}).collect(Collectors.toList()));
}
}
@@ -8,6 +8,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.api.entity.SysUser;
import com.pig4cloud.pigx.admin.api.feign.RemoteDeptService;
import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
import com.pig4cloud.pigx.admin.api.utils.DataUtil;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.flow.task.constant.NodeStatusEnum;
import com.pig4cloud.pigx.flow.task.dto.*;
@@ -16,7 +17,6 @@ import com.pig4cloud.pigx.flow.task.entity.ProcessCopy;
import com.pig4cloud.pigx.flow.task.entity.ProcessGroup;
import com.pig4cloud.pigx.flow.task.entity.ProcessInstanceRecord;
import com.pig4cloud.pigx.flow.task.service.*;
import com.pig4cloud.pigx.flow.task.utils.DataUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -73,13 +73,15 @@ public class RemoteServiceImpl implements IRemoteService {
ThreadUtil.execute(() -> {
try {
ProcessInstanceRecord processInstanceRecord = processInstanceRecordService.lambdaQuery()
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId).one();
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId)
.one();
int index = 10;
while (index > 0 && processInstanceRecord == null) {
TimeUnit.SECONDS.sleep(5);
processInstanceRecord = processInstanceRecordService.lambdaQuery()
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId).one();
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId)
.one();
index--;
}
@@ -110,7 +112,7 @@ public class RemoteServiceImpl implements IRemoteService {
Long parentId = checkParentDto.getParentId();
List<Long> deptIdList = checkParentDto.getDeptIdList();
// 查询子级包括自己
List<SysDept> allDept = deptService.getAllDept().getData();
List<SysDept> allDept = deptService.getAllDept(null).getData();
List<SysDept> childrenDeptList = DataUtil.selectChildrenByDept(parentId, allDept);
List<Long> childrenDeptIdList = childrenDeptList.stream().map(SysDept::getDeptId).collect(Collectors.toList());
@@ -128,8 +130,11 @@ public class RemoteServiceImpl implements IRemoteService {
*/
@Override
public R<List<Long>> queryUserIdListByDepIdList(List<Long> depIdList) {
List<Long> list = userService.getUserIdListByDeptIdList(depIdList).getData().stream().map(SysUser::getUserId)
.collect(Collectors.toList());
List<Long> list = userService.getUserIdListByDeptIdList(depIdList)
.getData()
.stream()
.map(SysUser::getUserId)
.collect(Collectors.toList());
return R.ok(list);
}
@@ -143,14 +148,11 @@ public class RemoteServiceImpl implements IRemoteService {
Long childId = checkChildDto.getChildId();
List<Long> deptIdList = checkChildDto.getDeptIdList();
// 查询父级包括自己
List<SysDept> allDept = deptService.getAllDept().getData();
List<SysDept> allDept = deptService.getAllDept(null).getData();
List<SysDept> parentDeptList = DataUtil.selectParentByDept(childId, allDept);
List<Long> parentDeptIdList = parentDeptList.stream().map(SysDept::getDeptId).collect(Collectors.toList());
parentDeptIdList.remove(childId);
List<Long> remainIdList = CollUtil.removeAny(deptIdList, ArrayUtil.toArray(parentDeptIdList, Long.class));
return R.ok(remainIdList.isEmpty());
}
@@ -0,0 +1,19 @@
package com.pig4cloud.pigx.admin.api.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 用户节点类型枚举
*/
@Getter
@AllArgsConstructor
public enum NodeUserTypeEnum {
USER("user", "用户"), DEPT("dept", "部门"), ROLE("role", "角色"),;
private String key;
private String name;
}
@@ -0,0 +1,86 @@
package com.pig4cloud.pigx.admin.api.utils;
import cn.hutool.core.collection.CollUtil;
import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.api.entity.SysMenu;
import lombok.experimental.UtilityClass;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@UtilityClass
public class DataUtil {
/**
* 根据当前部门id,向上查找所有的部门
* @param deptId 当前部门id
* @param allDeptList 所有部门列表
* @return 返回包括自己部门在内的所有父级部门
*/
public List<SysDept> selectParentByDept(long deptId, List<SysDept> allDeptList) {
List<SysDept> list = new ArrayList<>();
Optional<SysDept> optionalDept = allDeptList.stream().filter(w -> w.getDeptId() == deptId).findFirst();
optionalDept.ifPresent(dept -> {
if (dept.getParentId() != null) {
Long parentId = dept.getParentId();
List<SysDept> depts = selectParentByDept(parentId, allDeptList);
list.add(dept);
list.addAll(depts);
}
});
return list;
}
/**
* 根据当前部门id,向下查找所有的部门
* @param deptId 当前部门id
* @param allDeptList 所有部门列表
* @return 返回包括自己部门在内的所有子级部门
*/
public List<SysDept> selectChildrenByDept(long deptId, List<SysDept> allDeptList) {
List<SysDept> list = new ArrayList<>();
Optional<SysDept> optionalDept = allDeptList.stream().filter(w -> w.getDeptId() == deptId).findFirst();
optionalDept.ifPresent(list::add);
List<SysDept> collect = allDeptList.stream()
.filter(w -> w.getParentId() == deptId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(collect)) {
return list;
}
collect.forEach(dept -> {
List<SysDept> depts = selectChildrenByDept(dept.getDeptId(), allDeptList);
list.addAll(depts);
});
return list;
}
/**
* 根据当前菜单id,向下查找所有的菜单
* @param menuId 当前菜单id
* @param allMenuList 所有菜单列表
* @return 返回包括自己在内的所有子级菜单
*/
public List<SysMenu> selectChildrenByMenu(long menuId, List<SysMenu> allMenuList) {
List<SysMenu> list = new ArrayList<>();
list.add(allMenuList.stream().filter(w -> w.getMenuId() == menuId).findFirst().get());
List<SysMenu> collect = allMenuList.stream()
.filter(w -> w.getParentId() == menuId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(collect)) {
return list;
}
collect.forEach(dept -> list.addAll(selectChildrenByMenu(dept.getMenuId(), allMenuList)));
return list;
}
}
@@ -0,0 +1,45 @@
package com.pig4cloud.pigx.admin.api.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author : willian fu
* @version : 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrgTreeVO implements Serializable {
/**
* 用户od
*/
private Long id;
/**
* 用户名称
*/
private String name;
/**
* 类型
*/
private String type;
/**
* 选择
*/
private Boolean selected;
/**
* 头像
*/
private String avatar;
}
@@ -20,7 +20,7 @@
package com.pig4cloud.pigx.admin.controller;
import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVo;
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVO;
import com.pig4cloud.pigx.admin.service.SysDeptService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.excel.annotation.RequestExcel;
@@ -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 javax.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 javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.List;
@@ -140,7 +140,7 @@ public class SysDeptController {
*/
@ResponseExcel
@GetMapping("/export")
public List<DeptExcelVo> export() {
public List<DeptExcelVO> export() {
return sysDeptService.listExcelVo();
}
@@ -151,8 +151,28 @@ public class SysDeptController {
* @return
*/
@PostMapping("import")
public R importDept(@RequestExcel List<DeptExcelVo> excelVOList, BindingResult bindingResult) {
public R importDept(@RequestExcel List<DeptExcelVO> excelVOList, BindingResult bindingResult) {
return sysDeptService.importDept(excelVOList, bindingResult);
}
/**
* 查询全部部门包含用户
* @param parentDeptId 父部门ID
* @param type 查询类型
*/
@GetMapping("/org")
public R listOrgTree(Long parentDeptId, String type) {
return R.ok(sysDeptService.listOrgTree(parentDeptId, type));
}
/**
* 模糊搜索用户
* @param username 用户名/拼音/首字母
* @return 匹配到的用户
*/
@GetMapping("/org/user/search")
public R getOrgTreeUser(@RequestParam String username) {
return R.ok(sysDeptService.getOrgTreeUser(username));
}
}
@@ -38,6 +38,7 @@ import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.validation.Valid;
import lombok.AllArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
@@ -45,7 +46,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
@@ -256,24 +256,4 @@ public class SysUserController {
return R.ok(userService.listUserIdByRoleIds(CollUtil.toList(roleIdList)));
}
/**
* 根据部门ID列表获取用户ID列表接口
* @param deptIdList 部门ID列表
* @return R 返回结果对象,包含根据部门ID列表获取到的用户ID列表信息
*/
@GetMapping("/getUserIdListByDeptIdList")
public R<List<SysUser>> getUserIdListByDeptIdList(Long[] deptIdList) {
return R.ok(userService.listUserIdByDeptIds(CollUtil.toList(deptIdList)));
}
/**
* 根据用户名获取用户列表
* @param username 用户名
* @return 用户列表
*/
@GetMapping("/getUserListByUserName")
public R<List<SysUser>> getUserListByUserName(String username) {
return R.ok(userService.list(Wrappers.<SysUser>lambdaQuery().like(SysUser::getUsername, username)));
}
}
@@ -22,11 +22,13 @@ package com.pig4cloud.pigx.admin.service;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVo;
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVO;
import com.pig4cloud.pigx.admin.api.vo.OrgTreeVO;
import com.pig4cloud.pigx.common.core.util.R;
import org.springframework.validation.BindingResult;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -52,9 +54,9 @@ public interface SysDeptService extends IService<SysDept> {
*/
Boolean removeDeptById(Long id);
List<DeptExcelVo> listExcelVo();
List<DeptExcelVO> listExcelVo();
R importDept(List<DeptExcelVo> excelVOList, BindingResult bindingResult);
R importDept(List<DeptExcelVO> excelVOList, BindingResult bindingResult);
/**
* 获取部门的所有后代部门列表
@@ -70,4 +72,18 @@ public interface SysDeptService extends IService<SysDept> {
*/
List<Long> listDeptLeader(Long deptId);
/**
* 查询全部部门包含用户
* @param parentDeptId 父部门ID
* @param type 查询类型
*/
Map<String, Object> listOrgTree(Long parentDeptId, String type);
/**
* 根据用户名模糊搜索用户
* @param username 用户名
* @return List user
*/
List<OrgTreeVO> getOrgTreeUser(String username);
}
@@ -138,11 +138,4 @@ public interface SysUserService extends IService<SysUser> {
*/
List<Long> listUserIdByRoleIds(List<Long> roleIdList);
/**
* 根据部门ID列表获取用户ID列表接口
* @param deptIdList 部门ID列表
* @return List<Long> 返回结果对象,包含根据部门ID列表获取到的用户ID列表信息
*/
List<SysUser> listUserIdByDeptIds(List<Long> deptIdList);
}
@@ -20,21 +20,19 @@
package com.pig4cloud.pigx.admin.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
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.api.constant.NodeUserTypeEnum;
import com.pig4cloud.pigx.admin.api.entity.*;
import com.pig4cloud.pigx.admin.api.utils.DataUtil;
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVO;
import com.pig4cloud.pigx.admin.api.vo.OrgTreeVO;
import com.pig4cloud.pigx.admin.mapper.*;
import com.pig4cloud.pigx.admin.service.SysDeptService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.data.datascope.DataScope;
@@ -60,191 +58,307 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
private final SysUserMapper userMapper;
private final SysUserMapper userMapper;
private final SysDeptMapper deptMapper;
private final SysDeptMapper deptMapper;
private final SysPostMapper postMapper;
private final SysPostMapper postMapper;
private final SysUserPostMapper userPostMapper;
private final SysRoleMapper roleMapper;
/**
* 删除部门
* @param id 部门 ID
* @return 成功、失败
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeDeptById(Long id) {
// 级联删除部门
List<Long> idList = this.listDescendant(id).stream().map(SysDept::getDeptId).collect(Collectors.toList());
private final SysUserPostMapper userPostMapper;
Optional.ofNullable(idList).filter(CollUtil::isNotEmpty).ifPresent(this::removeByIds);
/**
* 删除部门
*
* @param id 部门 ID
* @return 成功、失败
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeDeptById(Long id) {
// 级联删除部门
List<Long> idList = this.listDescendant(id).stream().map(SysDept::getDeptId).collect(Collectors.toList());
return Boolean.TRUE;
}
Optional.ofNullable(idList).filter(CollUtil::isNotEmpty).ifPresent(this::removeByIds);
/**
* 查询全部部门树
* @param deptName
* @param parentId
* @return 树 部门名称
*/
@Override
public List<Tree<Long>> selectTree(String deptName, Long parentId) {
// 查询全部部门
List<SysDept> deptAllList = deptMapper.selectList(
Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName));
// 查询数据权限内部门
List<Long> deptOwnIdList = deptMapper.selectListByScope(
Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName),
DataScope.of()).stream().map(SysDept::getDeptId).collect(Collectors.toList());
return Boolean.TRUE;
}
// 权限内部门
List<TreeNode<Long>> collect = deptAllList.stream()
.filter(dept -> dept.getDeptId().intValue() != dept.getParentId())
.sorted(Comparator.comparingInt(SysDept::getSortOrder)).map(dept -> {
TreeNode<Long> treeNode = new TreeNode<>();
treeNode.setId(dept.getDeptId());
treeNode.setParentId(dept.getParentId());
treeNode.setName(dept.getName());
treeNode.setWeight(dept.getSortOrder());
// 有权限不返回标识
Map<String, Object> extra = new HashMap<>(8);
extra.put("isLock", !deptOwnIdList.contains(dept.getDeptId()));
extra.put("createTime", dept.getCreateTime());
treeNode.setExtra(extra);
return treeNode;
}).collect(Collectors.toList());
/**
* 查询全部部门树
*
* @param deptName
* @param parentId
* @return 树 部门名称
*/
@Override
public List<Tree<Long>> selectTree(String deptName, Long parentId) {
// 查询全部部门
List<SysDept> deptAllList = deptMapper
.selectList(Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName));
// 查询数据权限内部门
List<Long> deptOwnIdList = deptMapper
.selectListByScope(
Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName),
DataScope.of())
.stream()
.map(SysDept::getDeptId)
.collect(Collectors.toList());
// 模糊查询 不组装树结构 直接返回 表格方便编辑
if (StrUtil.isNotBlank(deptName)) {
return collect.stream().map(node -> {
Tree<Long> tree = new Tree<>();
tree.putAll(node.getExtra());
BeanUtils.copyProperties(node, tree);
return tree;
}).collect(Collectors.toList());
}
// 权限内部门
List<TreeNode<Long>> collect = deptAllList.stream()
.filter(dept -> dept.getDeptId().intValue() != dept.getParentId())
.sorted(Comparator.comparingInt(SysDept::getSortOrder))
.map(dept -> {
TreeNode<Long> treeNode = new TreeNode<>();
treeNode.setId(dept.getDeptId());
treeNode.setParentId(dept.getParentId());
treeNode.setName(dept.getName());
treeNode.setWeight(dept.getSortOrder());
// 有权限不返回标识
Map<String, Object> extra = new HashMap<>(8);
extra.put("isLock", !deptOwnIdList.contains(dept.getDeptId()));
extra.put("createTime", dept.getCreateTime());
treeNode.setExtra(extra);
return treeNode;
})
.collect(Collectors.toList());
return TreeUtil.build(collect, parentId == null ? 0 : parentId);
}
// 模糊查询 不组装树结构 直接返回 表格方便编辑
if (StrUtil.isNotBlank(deptName)) {
return collect.stream().map(node -> {
Tree<Long> tree = new Tree<>();
tree.putAll(node.getExtra());
BeanUtils.copyProperties(node, tree);
return tree;
}).collect(Collectors.toList());
}
/**
* 导出部门
* @return
*/
@Override
public List<DeptExcelVo> listExcelVo() {
List<SysDept> list = this.list();
List<DeptExcelVo> deptExcelVos = list.stream().map(item -> {
DeptExcelVo deptExcelVo = new DeptExcelVo();
deptExcelVo.setName(item.getName());
Optional<String> first = this.list().stream().filter(it -> item.getParentId().equals(it.getDeptId()))
.map(SysDept::getName).findFirst();
deptExcelVo.setParentName(first.orElse("根部门"));
deptExcelVo.setSortOrder(item.getSortOrder());
return deptExcelVo;
}).collect(Collectors.toList());
return deptExcelVos;
}
return TreeUtil.build(collect, parentId == null ? 0 : parentId);
}
@Override
public R importDept(List<DeptExcelVo> excelVOList, BindingResult bindingResult) {
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
/**
* 导出部门
*
* @return
*/
@Override
public List<DeptExcelVO> listExcelVo() {
List<SysDept> list = this.list();
List<DeptExcelVO> deptExcelVos = list.stream().map(item -> {
DeptExcelVO deptExcelVo = new DeptExcelVO();
deptExcelVo.setName(item.getName());
Optional<String> first = this.list()
.stream()
.filter(it -> item.getParentId().equals(it.getDeptId()))
.map(SysDept::getName)
.findFirst();
deptExcelVo.setParentName(first.orElse("根部门"));
deptExcelVo.setSortOrder(item.getSortOrder());
return deptExcelVo;
}).collect(Collectors.toList());
return deptExcelVos;
}
List<SysDept> deptList = this.list();
for (DeptExcelVo item : excelVOList) {
Set<String> errorMsg = new HashSet<>();
boolean exsitUsername = deptList.stream().anyMatch(sysDept -> item.getName().equals(sysDept.getName()));
if (exsitUsername) {
errorMsg.add("部门名称已经存在");
}
SysDept one = this.getOne(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getName, item.getParentName()));
if (item.getParentName().equals("根部门")) {
one = new SysDept();
one.setDeptId(0L);
}
if (one == null) {
errorMsg.add("上级部门不存在");
}
if (CollUtil.isEmpty(errorMsg)) {
SysDept sysDept = new SysDept();
sysDept.setName(item.getName());
sysDept.setParentId(one.getDeptId());
sysDept.setSortOrder(item.getSortOrder());
baseMapper.insert(sysDept);
}
else {
// 数据不合法情况
errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok(null, "部门导入成功");
}
@Override
public R importDept(List<DeptExcelVO> excelVOList, BindingResult bindingResult) {
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
/**
* 查询所有子节点 (包含当前节点)
* @param deptId 部门ID 目标部门ID
* @return ID
*/
@Override
public List<SysDept> listDescendant(Long deptId) {
// 查询全部部门
List<SysDept> allDeptList = baseMapper.selectList(Wrappers.emptyWrapper());
List<SysDept> deptList = this.list();
for (DeptExcelVO item : excelVOList) {
Set<String> errorMsg = new HashSet<>();
boolean exsitUsername = deptList.stream().anyMatch(sysDept -> item.getName().equals(sysDept.getName()));
if (exsitUsername) {
errorMsg.add("部门名称已经存在");
}
SysDept one = this.getOne(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getName, item.getParentName()));
if (item.getParentName().equals("根部门")) {
one = new SysDept();
one.setDeptId(0L);
}
if (one == null) {
errorMsg.add("上级部门不存在");
}
if (CollUtil.isEmpty(errorMsg)) {
SysDept sysDept = new SysDept();
sysDept.setName(item.getName());
sysDept.setParentId(one.getDeptId());
sysDept.setSortOrder(item.getSortOrder());
baseMapper.insert(sysDept);
} else {
// 数据不合法情况
errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok(null, "部门导入成功");
}
// 递归查询所有子节点
List<SysDept> resDeptList = new ArrayList<>();
recursiveDept(allDeptList, deptId, resDeptList);
/**
* 查询所有子节点 (包含当前节点)
*
* @param deptId 部门ID 目标部门ID
* @return ID
*/
@Override
public List<SysDept> listDescendant(Long deptId) {
// 查询全部部门
List<SysDept> allDeptList = baseMapper.selectList(Wrappers.emptyWrapper());
// 添加当前节点
resDeptList.addAll(allDeptList.stream().filter(sysDept -> deptId.equals(sysDept.getDeptId()))
.collect(Collectors.toList()));
return resDeptList;
}
// 递归查询所有子节点
List<SysDept> resDeptList = new ArrayList<>();
recursiveDept(allDeptList, deptId, 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;
}
// 添加当前节点
resDeptList.addAll(allDeptList.stream().filter(sysDept -> deptId.equals(sysDept.getDeptId())).collect(Collectors.toList()));
return resDeptList;
}
SysPost deptLeader = postMapper
.selectOne(Wrappers.<SysPost>lambdaQuery().eq(SysPost::getPostCode, "DEPT_LEADER"));
if (deptLeader == null) {
return null;
}
/**
* 获取部门负责人
* <p>
* 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;
}
List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList());
return userPostMapper.selectList(Wrappers.<SysUserPost>lambdaQuery().in(SysUserPost::getUserId, userIdList))
.stream().filter(post -> Objects.equals(post.getPostId(), deptLeader.getPostId()))
.map(SysUserPost::getUserId).collect(Collectors.toList());
}
SysPost deptLeader = postMapper
.selectOne(Wrappers.<SysPost>lambdaQuery().eq(SysPost::getPostCode, "DEPT_LEADER"));
if (deptLeader == null) {
return null;
}
/**
* 递归查询所有子节点。
* @param allDeptList 所有部门列表
* @param parentId 父部门ID
* @param resDeptList 结果集合
*/
private void recursiveDept(List<SysDept> allDeptList, Long parentId, List<SysDept> resDeptList) {
// 使用 Stream API 进行筛选和遍历
allDeptList.stream().filter(sysDept -> sysDept.getParentId().equals(parentId)).forEach(sysDept -> {
resDeptList.add(sysDept);
recursiveDept(allDeptList, sysDept.getDeptId(), resDeptList);
});
}
List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList());
return userPostMapper.selectList(Wrappers.<SysUserPost>lambdaQuery().in(SysUserPost::getUserId, userIdList))
.stream()
.filter(post -> Objects.equals(post.getPostId(), deptLeader.getPostId()))
.map(SysUserPost::getUserId)
.collect(Collectors.toList());
}
/**
* 根据父部门ID和类型获取组织树
*
* @param parentDeptId 父部门ID
* @param type 类型
* @return 组织树信息
*/
public Map<String, Object> listOrgTree(Long parentDeptId, String type) {
List<OrgTreeVO> orgs = new LinkedList<>();
if (StrUtil.equals(type, "role")) {
// 角色
List<SysRole> roleList = roleMapper.selectList(Wrappers.emptyWrapper());
roleList.forEach(role -> {
OrgTreeVO orgTreeVo = new OrgTreeVO();
orgTreeVo.setId(role.getRoleId());
orgTreeVo.setName(role.getRoleName());
orgTreeVo.setType("role");
orgTreeVo.setSelected(false);
orgs.add(orgTreeVo);
});
return Dict.create()
.set("roleList", orgs)
.set("childDepartments", orgs)
.set("employees", new ArrayList<>());
}
Dict dict = Dict.create()
.set("titleDepartments", new ArrayList<>())
.set("roleList", new ArrayList<>())
.set("employees", new ArrayList<>());
List<SysDept> deptList = this.list(
Wrappers.<SysDept>lambdaQuery().eq(Objects.nonNull(parentDeptId), SysDept::getParentId, parentDeptId));
// 查询所有部门及员工
List<OrgTreeVO> deptVoList = new ArrayList<>();
deptList.forEach(dept -> {
OrgTreeVO orgTreeVo = new OrgTreeVO();
orgTreeVo.setId(dept.getDeptId());
orgTreeVo.setName(dept.getName());
orgTreeVo.setType("dept");
orgTreeVo.setSelected(false);
deptVoList.add(orgTreeVo);
});
dict.set("childDepartments", deptVoList);
if (!StrUtil.equals(type, "dept")) {
List<OrgTreeVO> userVoList = new ArrayList<>();
List<SysUser> userList = userMapper
.selectList(Wrappers.<SysUser>lambdaQuery().in(SysUser::getDeptId, CollUtil.toList(parentDeptId)));
userList.forEach(user -> {
OrgTreeVO orgTreeVo = new OrgTreeVO();
orgTreeVo.setId(user.getUserId());
orgTreeVo.setName(user.getUsername());
orgTreeVo.setType("user");
orgTreeVo.setSelected(false);
orgTreeVo.setAvatar(user.getAvatar());
userVoList.add(orgTreeVo);
});
dict.set("employees", userVoList);
}
if (parentDeptId > 0) {
List<SysDept> allDept = this.list();
List<SysDept> depts = DataUtil.selectParentByDept(parentDeptId, allDept);
dict.set("titleDepartments", CollUtil.reverse(depts));
}
return dict;
}
/**
* 模糊搜索用户
*
* @param username 用户名/拼音/首字母
* @return 匹配到的用户
*/
public List<OrgTreeVO> getOrgTreeUser(String username) {
return userMapper.selectList(Wrappers.<SysUser>lambdaQuery().like(SysUser::getUsername, username))
.stream()
.map(user -> {
OrgTreeVO orgTreeVo = new OrgTreeVO();
orgTreeVo.setId(user.getUserId());
orgTreeVo.setName(user.getUsername());
orgTreeVo.setType(NodeUserTypeEnum.USER.getKey());
orgTreeVo.setSelected(false);
orgTreeVo.setAvatar(user.getAvatar());
return orgTreeVo;
})
.collect(Collectors.toList());
}
/**
* 递归查询所有子节点。
*
* @param allDeptList 所有部门列表
* @param parentId 父部门ID
* @param resDeptList 结果集合
*/
private void recursiveDept(List<SysDept> allDeptList, Long parentId, List<SysDept> resDeptList) {
// 使用 Stream API 进行筛选和遍历
allDeptList.stream().filter(sysDept -> sysDept.getParentId().equals(parentId)).forEach(sysDept -> {
resDeptList.add(sysDept);
recursiveDept(allDeptList, sysDept.getDeptId(), resDeptList);
});
}
}
@@ -99,7 +99,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public Boolean saveUser(UserDTO userDto) {
SysUser sysUser = new SysUser();
BeanUtils.copyProperties(userDto, sysUser);
sysUser.setDelFlag(CommonConstants.STATUS_NORMAL);
sysUser
.setDelFlag(StrUtil.isBlank(userDto.getLockFlag()) ? CommonConstants.STATUS_NORMAL : userDto.getDelFlag());
sysUser.setCreateBy(userDto.getUsername());
sysUser.setUpdateBy(userDto.getUsername());
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
@@ -120,7 +121,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
String defaultRole = ParamResolver.getStr("USER_DEFAULT_ROLE");
// 默认角色
SysRole sysRole = sysRoleService
.getOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, defaultRole));
.getOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, defaultRole));
userDto.setRole(Collections.singletonList(sysRole.getRoleId()));
}
@@ -144,16 +145,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
UserInfo userInfo = new UserInfo();
userInfo.setSysUser(sysUser);
// 设置角色列表 (ID)
List<Long> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId()).stream().map(SysRole::getRoleId)
.collect(Collectors.toList());
List<Long> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId())
.stream()
.map(SysRole::getRoleId)
.collect(Collectors.toList());
userInfo.setRoles(ArrayUtil.toArray(roleIds, Long.class));
// 设置权限列表(menu.permission)
Set<String> permissions = new HashSet<>();
roleIds.forEach(roleId -> {
List<String> permissionList = sysMenuService.findMenuByRoleId(roleId).stream()
.filter(menu -> StrUtil.isNotEmpty(menu.getPermission())).map(SysMenu::getPermission)
.collect(Collectors.toList());
List<String> permissionList = sysMenuService.findMenuByRoleId(roleId)
.stream()
.filter(menu -> StrUtil.isNotEmpty(menu.getPermission()))
.map(SysMenu::getPermission)
.collect(Collectors.toList());
permissions.addAll(permissionList);
});
userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class));
@@ -235,7 +240,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 更新用户角色表
if (userDto.getRole() != null) {
sysUserRoleMapper
.delete(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userDto.getUserId()));
.delete(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userDto.getUserId()));
userDto.getRole().stream().map(roleId -> {
SysUserRole userRole = new SysUserRole();
userRole.setUserId(sysUser.getUserId());
@@ -247,7 +252,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 更新用户岗位表
if (userDto.getPost() != null) {
sysUserPostMapper
.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
userDto.getPost().stream().map(postId -> {
SysUserPost userPost = new SysUserPost();
userPost.setUserId(sysUser.getUserId());
@@ -291,11 +296,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
List<UserExcelVO> userExcelVOList = voList.stream().map(userVO -> {
UserExcelVO excelVO = new UserExcelVO();
BeanUtils.copyProperties(userVO, excelVO);
String roleNameList = userVO.getRoleList().stream().map(SysRole::getRoleName)
.collect(Collectors.joining(StrUtil.COMMA));
String roleNameList = userVO.getRoleList()
.stream()
.map(SysRole::getRoleName)
.collect(Collectors.joining(StrUtil.COMMA));
excelVO.setRoleNameList(roleNameList);
String postNameList = userVO.getPostList().stream().map(SysPost::getPostName)
.collect(Collectors.joining(StrUtil.COMMA));
String postNameList = userVO.getPostList()
.stream()
.map(SysPost::getPostName)
.collect(Collectors.joining(StrUtil.COMMA));
excelVO.setPostNameList(postNameList);
return excelVO;
}).collect(Collectors.toList());
@@ -324,7 +333,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
Set<String> errorMsg = new HashSet<>();
// 校验用户名是否存在
boolean exsitUserName = userList.stream()
.anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername()));
.anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername()));
if (exsitUserName) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, excel.getUsername()));
@@ -332,7 +341,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 判断输入的部门名称列表是否合法
Optional<SysDept> deptOptional = deptList.stream()
.filter(dept -> excel.getDeptName().equals(dept.getName())).findFirst();
.filter(dept -> excel.getDeptName().equals(dept.getName()))
.findFirst();
if (!deptOptional.isPresent()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_DEPT_DEPTNAME_INEXISTENCE, excel.getDeptName()));
}
@@ -340,8 +350,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 判断输入的角色名称列表是否合法
List<String> roleNameList = StrUtil.split(excel.getRoleNameList(), StrUtil.COMMA);
List<SysRole> roleCollList = roleList.stream()
.filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name)))
.collect(Collectors.toList());
.filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name)))
.collect(Collectors.toList());
if (roleCollList.size() != roleNameList.size()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList()));
@@ -350,8 +360,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 判断输入的部门名称列表是否合法
List<String> postNameList = StrUtil.split(excel.getPostNameList(), StrUtil.COMMA);
List<SysPost> postCollList = postList.stream()
.filter(post -> postNameList.stream().anyMatch(name -> post.getPostName().equals(name)))
.collect(Collectors.toList());
.filter(post -> postNameList.stream().anyMatch(name -> post.getPostName().equals(name)))
.collect(Collectors.toList());
if (postCollList.size() != postNameList.size()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_POSTNAME_INEXISTENCE, excel.getPostNameList()));
@@ -385,6 +395,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userDTO.setNickname(excel.getNickname());
userDTO.setName(excel.getName());
userDTO.setEmail(excel.getEmail());
userDTO.setLockFlag(excel.getLockFlag());
// 批量导入初始密码为手机号
userDTO.setPassword(userDTO.getPhone());
// 根据部门名称查询部门ID
@@ -455,8 +466,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
String password = ENCODER.encode(userDto.getNewpassword1());
this.update(Wrappers.<SysUser>lambdaUpdate().set(SysUser::getPassword, password).eq(SysUser::getUserId,
userVO.getUserId()));
this.update(Wrappers.<SysUser>lambdaUpdate()
.set(SysUser::getPassword, password)
.eq(SysUser::getUserId, userVO.getUserId()));
return R.ok();
}
@@ -465,20 +477,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
PigxUser user = SecurityUtils.getUser();
LambdaUpdateWrapper<SysUser> wrapper = null;
if (type.equals("wechat")) {
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getWxOpenid, null).eq(SysUser::getUserId,
user.getId());
wrapper = Wrappers.<SysUser>lambdaUpdate()
.set(SysUser::getWxOpenid, null)
.eq(SysUser::getUserId, user.getId());
}
else if (type.equals("gitee")) {
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getGiteeLogin, null).eq(SysUser::getUserId,
user.getId());
wrapper = Wrappers.<SysUser>lambdaUpdate()
.set(SysUser::getGiteeLogin, null)
.eq(SysUser::getUserId, user.getId());
}
else if (type.equals("osc")) {
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getOscId, null).eq(SysUser::getUserId,
user.getId());
wrapper = Wrappers.<SysUser>lambdaUpdate()
.set(SysUser::getOscId, null)
.eq(SysUser::getUserId, user.getId());
}
else if (type.equals("tencent")) {
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getQqOpenid, null).eq(SysUser::getUserId,
user.getId());
wrapper = Wrappers.<SysUser>lambdaUpdate()
.set(SysUser::getQqOpenid, null)
.eq(SysUser::getUserId, user.getId());
}
if (wrapper == null) {
return R.failed("解绑账号类型不存在");
@@ -506,17 +522,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
public List<Long> listUserIdByRoleIds(List<Long> roleIdList) {
return sysUserRoleMapper.selectList(Wrappers.<SysUserRole>lambdaQuery().in(SysUserRole::getRoleId, roleIdList))
.stream().map(SysUserRole::getUserId).collect(Collectors.toList());
}
/**
* 根据部门ID列表获取用户ID列表接口
* @param deptIdList 部门ID列表
* @return List<Long> 返回结果对象,包含根据部门ID列表获取到的用户ID列表信息
*/
@Override
public List<SysUser> listUserIdByDeptIds(List<Long> deptIdList) {
return baseMapper.selectList(Wrappers.<SysUser>lambdaQuery().in(SysUser::getDeptId, deptIdList));
.stream()
.map(SysUserRole::getUserId)
.collect(Collectors.toList());
}
}