feat(sysuser): ByIds 批量姓名回显端点——管理面聚合页(消息追溯台收件明细)用,仅超管、窄投影 id/account/realName
build / build-push (push) Failing after 30s
build / build-push (push) Failing after 30s
This commit is contained in:
@@ -28,7 +28,10 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author chenx
|
||||
@@ -203,4 +206,22 @@ public class SysUserController {
|
||||
requireQueryGroupInScope(groupId);
|
||||
sysUserService.exportUsers(groupId, withSub, name, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 id 批量取用户展示信息(id/账号/姓名),管理面聚合页(消息/待办追溯台收件明细)回显名称用。<br>
|
||||
* 只读窄投影:不透出手机号/身份证等敏感列;用户目录属平台主数据,仅超管。
|
||||
*/
|
||||
@GetMapping("ByIds")
|
||||
public List<Map<String, Object>> byIds(@RequestParam("ids") List<Integer> ids) {
|
||||
accessScopeService.requireSuper();
|
||||
return sysUserService.listByIds(ids).stream()
|
||||
.map(u -> {
|
||||
Map<String, Object> item = new LinkedHashMap<>();
|
||||
item.put("id", u.getId());
|
||||
item.put("account", u.getAccount());
|
||||
item.put("realName", u.getRealName());
|
||||
return item;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.yunhai.userbase.entity.SysUser;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -25,6 +27,13 @@ public interface ISysUserService {
|
||||
/** 新增用户:校验密码/手机号/身份证,BCrypt 加密,并写入组用户关联。返回创建后的用户ID。 */
|
||||
Integer add(SysUserRequest request);
|
||||
|
||||
/**
|
||||
* 按 id 批量取用户实体(窄用途:管理面聚合页回显 id/账号/姓名)。<br>
|
||||
* 只读;入参去重、去 null、截断到 200 个;查无返回空列表。调用方(控制器)自行投影白名单字段,
|
||||
* 不得把实体直接序列化出站(实体含手机号/身份证等敏感列)。
|
||||
*/
|
||||
List<SysUser> listByIds(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 编辑用户(管理端);密码为空时不修改密码。<br>
|
||||
* 用户身份按「schoolId 该校全量覆盖」写(勾选框语义);带了 schoolId 却不带 roleIds 直接报错,
|
||||
|
||||
@@ -1795,6 +1795,24 @@ public class SysUserService implements ISysUserService {
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== 按 id 批量窄读 =====================
|
||||
|
||||
/** 批量上限:聚合页一次回显的收件用户规模远小于此,防误用放大查询 */
|
||||
private static final int LIST_BY_IDS_MAX = 200;
|
||||
|
||||
@Override
|
||||
public List<SysUser> listByIds(List<Integer> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Integer> safeIds = ids.stream()
|
||||
.filter(id -> id != null && id > 0)
|
||||
.distinct()
|
||||
.limit(LIST_BY_IDS_MAX)
|
||||
.collect(Collectors.toList());
|
||||
return safeIds.isEmpty() ? Collections.emptyList() : sysUserRepository.findAllById(safeIds);
|
||||
}
|
||||
|
||||
// ===================== 推送事件 + 缓存失效事件 =====================
|
||||
// 用户域全部写口在此收口:DataSyncEvent 由 PushDispatcher 消费(push_enabled 默认 0 不触发);
|
||||
// UserChangedEvent 由 CacheInvalidationListener AFTER_COMMIT 消费,按 id/login/phone
|
||||
|
||||
Reference in New Issue
Block a user