|
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.SysUserDTO;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserDTO;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserInfo;
|
|
@@ -68,13 +69,16 @@ import javax.validation.Valid;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -1109,6 +1113,7 @@ public class SysUserController {
|
|
|
|
|
|
|
|
|
SysRole role = null;
|
|
|
+ boolean needArea = false;
|
|
|
|
|
|
// 系统管理员
|
|
|
if (operatorRoleIds.contains(1)) {
|
|
@@ -1129,13 +1134,15 @@ public class SysUserController {
|
|
|
// 区域管理员
|
|
|
else if (operatorRoleIds.contains(4)) {
|
|
|
role = roleId2RoleMap.get(4);
|
|
|
+ needArea = true;
|
|
|
}
|
|
|
// 服务商管理员
|
|
|
else if (operatorRoleIds.contains(37)) {
|
|
|
role = roleId2RoleMap.get(37);
|
|
|
+ needArea = true;
|
|
|
}
|
|
|
|
|
|
- if (role == null){
|
|
|
+ if (role == null) {
|
|
|
throw new BizException("当前用户角色不可用");
|
|
|
} else {
|
|
|
String visible = role.getVisible();
|
|
@@ -1145,9 +1152,9 @@ public class SysUserController {
|
|
|
|
|
|
Set<Integer> visibles = Arrays.stream(visible.split(StrUtil.COMMA)).mapToInt(Integer::valueOf).boxed().collect(Collectors.toSet());
|
|
|
|
|
|
- Integer targetRoleId = query.getRoleId();
|
|
|
+ Integer targetRoleId = CollUtil.isEmpty(query.getRole()) ? null : query.getRole().get(0);
|
|
|
|
|
|
- if (targetRoleId == null){
|
|
|
+ if (targetRoleId == null) {
|
|
|
targetRoleIds.addAll(visibles);
|
|
|
} else if (visibles.contains(targetRoleId)) {
|
|
|
targetRoleIds.add(targetRoleId);
|
|
@@ -1156,7 +1163,26 @@ public class SysUserController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- query.setFinalQueryRoleIds(targetRoleIds);
|
|
|
+ // 获取所有三级区域
|
|
|
+
|
|
|
+ String areaCacheKey = "sys:area:lv3";
|
|
|
+ Set<Long> areaEntities;
|
|
|
+ if (Boolean.TRUE.equals(redisTemplate.hasKey(areaCacheKey))) {
|
|
|
+ areaEntities = (Set<Long>) redisTemplate.opsForValue().get(areaCacheKey);
|
|
|
+ } else {
|
|
|
+ areaEntities = areaEntityService.list(Wrappers.<SysAreaEntity>lambdaQuery().eq(SysAreaEntity::getAreaType, UpmsType.AreaType.DISTRICT))
|
|
|
+ .stream().map(SysAreaEntity::getAreaId).collect(Collectors.toSet());
|
|
|
+ redisTemplate.opsForValue().set(areaCacheKey, areaEntities, 12, TimeUnit.HOURS);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> areas = query.getAreaCodes();
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(areas) && needArea) {
|
|
|
+ areas = userAreaService.listUserAreas(Long.valueOf(SecurityUtils.getUser().getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ query.setAreaCodes(new LinkedList<>(CollUtil.intersectionDistinct(areaEntities, areas)));
|
|
|
+ query.setRole(new LinkedList<>(targetRoleIds));
|
|
|
|
|
|
Page<?> userVosPage = userService.pageUser(query, SecurityUtils.getUser());
|
|
|
|