|
@@ -2,9 +2,14 @@ package com.qunzhixinxi.hnqz.admin.controller.user;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysUserRole;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysUserRoleService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.constant.CacheConstants;
|
|
|
+import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
import java.util.Collections;
|
|
@@ -31,6 +36,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
public class SysUserControllerV2 {
|
|
|
|
|
|
@Resource private RedisTemplate redisTemplate;
|
|
|
+ @Resource private SysUserRoleService sysUserRoleService;
|
|
|
+ @Resource private SysUserService sysUserService;
|
|
|
|
|
|
@GetMapping(value = "/avail")
|
|
|
public R<List<Map<String, Object>>> listAvail(
|
|
@@ -79,14 +86,43 @@ public class SysUserControllerV2 {
|
|
|
@GetMapping(value = "/list")
|
|
|
public R<List<SysUser>> listVendor() {
|
|
|
|
|
|
- List<SysUser> range = redisTemplate.opsForList().range(CacheConstants.USER_KEY, 0, -1);
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+
|
|
|
+ List<SysUser> users =
|
|
|
+ sysUserService.list(
|
|
|
+ Wrappers.<SysUser>lambdaQuery()
|
|
|
+ .eq(SysUser::getLockFlag, CommonConstants.STATUS_NORMAL)
|
|
|
+ .eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL)
|
|
|
+ .eq(SysUser::getDeptId, deptId));
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(users)) {
|
|
|
+ return R.ok(Collections.emptyList());
|
|
|
+ }
|
|
|
+ List<Integer> uid =
|
|
|
+ users.stream()
|
|
|
+ .mapToInt(SysUser::getUserId)
|
|
|
+ .boxed()
|
|
|
+ .distinct()
|
|
|
+ .sorted()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 全职
|
|
|
+ List<SysUserRole> list =
|
|
|
+ sysUserRoleService.list(
|
|
|
+ Wrappers.<SysUserRole>lambdaQuery()
|
|
|
+ .eq(SysUserRole::getRoleId, 5)
|
|
|
+ .in(SysUserRole::getUserId, uid));
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ return R.ok(Collections.emptyList());
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Integer> collect =
|
|
|
+ list.stream().mapToInt(SysUserRole::getUserId).boxed().collect(Collectors.toSet());
|
|
|
|
|
|
- Map<Integer, List<SysUser>> collect =
|
|
|
- range.stream().collect(Collectors.groupingBy(SysUser::getDeptId));
|
|
|
+ List<SysUser> finalUsers =
|
|
|
+ users.stream().filter(u -> collect.contains(u.getUserId())).collect(Collectors.toList());
|
|
|
|
|
|
- return R.ok(
|
|
|
- CollUtil.isEmpty(collect)
|
|
|
- ? Collections.emptyList()
|
|
|
- : collect.get(SecurityUtils.getUser().getDeptId()));
|
|
|
+ return R.ok(finalUsers);
|
|
|
}
|
|
|
}
|