mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
CRM-客户:实现数据权限、场景检索和公海数据分页查询
This commit is contained in:
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Admin 用户 API 接口
|
||||
@ -22,6 +23,14 @@ public interface AdminUserApi {
|
||||
*/
|
||||
AdminUserRespDTO getUser(Long id);
|
||||
|
||||
/**
|
||||
* 通过用户 ID 查询用户下属
|
||||
*
|
||||
* @param id 用户编号
|
||||
* @return 用户下属用户编号列表
|
||||
*/
|
||||
Set<Long> getSubordinateIds(Long id);
|
||||
|
||||
/**
|
||||
* 通过用户 ID 查询用户们
|
||||
*
|
||||
|
@ -1,14 +1,21 @@
|
||||
package cn.iocoder.yudao.module.system.api.user;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
/**
|
||||
* Admin 用户 API 实现类
|
||||
@ -20,6 +27,8 @@ public class AdminUserApiImpl implements AdminUserApi {
|
||||
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
|
||||
@Override
|
||||
public AdminUserRespDTO getUser(Long id) {
|
||||
@ -27,6 +36,22 @@ public class AdminUserApiImpl implements AdminUserApi {
|
||||
return UserConvert.INSTANCE.convert4(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getSubordinateIds(Long id) {
|
||||
AdminUserDO user = userService.getUser(id);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<Long> subordinateIds = null; // 下属用户编号
|
||||
DeptDO dept = deptService.getDept(user.getDeptId());
|
||||
if (ObjUtil.equal(dept.getLeaderUserId(), id)) { // 校验是否是该部门的负责人
|
||||
List<AdminUserDO> users = userService.getUserListByDeptIds(Collections.singletonList(dept.getId()));
|
||||
subordinateIds = convertSet(users, AdminUserDO::getId);
|
||||
}
|
||||
return subordinateIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminUserRespDTO> getUserList(Collection<Long> ids) {
|
||||
List<AdminUserDO> users = userService.getUserList(ids);
|
||||
|
Reference in New Issue
Block a user