feat(系统设置): 优化用户创建的逻辑

This commit is contained in:
Jianguo-Genius 2024-05-30 18:12:27 +08:00 committed by 刘瑞斌
parent 37098287c8
commit 2bb7b7a8af
21 changed files with 120 additions and 1624 deletions

View File

@ -322,6 +322,8 @@ operation_history.type.length_range=变更记录操作类型长度必须在{min}
operation_history.source_id.not_blank=变更记录资源 ID 不能为空 operation_history.source_id.not_blank=变更记录资源 ID 不能为空
operation_history.version_id.not_blank=变更记录版本 ID 不能为空 operation_history.version_id.not_blank=变更记录版本 ID 不能为空
operation_history.version_id.length_range=变更记录版本 ID 长度必须在{min}和{max}之间 operation_history.version_id.length_range=变更记录版本 ID 长度必须在{min}和{max}之间
user_open_source_max=系统用户数超额({num}人),继续添加用户可申请企业版适用
user_dept_max=系统用户数超额({num}人),继续添加用户可申请企业版扩容

View File

@ -325,4 +325,6 @@ operation_history.version_id.not_blank=Operating history version id cannot be em
operation_history.version_id.length_range=Operating history version id length must be between {min} and {max} operation_history.version_id.length_range=Operating history version id length must be between {min} and {max}
permission.organization_task_center.name=Task center permission.organization_task_center.name=Task center
permission.organization_task_center.stop=Stop task permission.organization_task_center.stop=Stop task
user_open_source_max=There are too many users({num}),please apply for the enterprise version to use
user_dept_max=There are too many users({num}),please apply for enterprise version expansion

View File

@ -327,3 +327,5 @@ operation_history.version_id.length_range=变更记录版本 ID 长度必须在{
permission.organization_task_center.name=任务中心 permission.organization_task_center.name=任务中心
permission.organization_task_center.stop=停止 permission.organization_task_center.stop=停止
user_open_source_max=系统用户数超额({0}人),继续添加用户可申请企业版适用
user_dept_max=系统用户数超额({0}人),继续添加用户可申请企业版扩容

View File

@ -326,3 +326,5 @@ operation_history.version_id.length_range=變更記錄版本 ID 長度必須在{
permission.organization_task_center.name=任務中心 permission.organization_task_center.name=任務中心
permission.organization_task_center.stop=停止 permission.organization_task_center.stop=停止
user_open_source_max=系統用戶數超額({num}人),繼續添加用戶可申請企業版適用
user_dept_max=系統用戶數超額({num}人),繼續添加用戶可申請企業版擴容

View File

@ -9,7 +9,7 @@ import io.metersphere.api.service.definition.ApiDefinitionScheduleService;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.sdk.util.CommonBeanFactory;
import io.metersphere.system.schedule.BaseScheduleJob; import io.metersphere.system.schedule.BaseScheduleJob;
import io.metersphere.system.service.UserService; import io.metersphere.system.service.NormalUserService;
import org.quartz.JobDataMap; import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobKey; import org.quartz.JobKey;
@ -18,12 +18,12 @@ import org.quartz.TriggerKey;
public class SwaggerUrlImportJob extends BaseScheduleJob { public class SwaggerUrlImportJob extends BaseScheduleJob {
private ApiDefinitionImportUtilService apiDefinitionImportUtilService; private ApiDefinitionImportUtilService apiDefinitionImportUtilService;
private ApiDefinitionScheduleService apiDefinitionScheduleService; private ApiDefinitionScheduleService apiDefinitionScheduleService;
private UserService userService; private NormalUserService normalUserService;
public SwaggerUrlImportJob() { public SwaggerUrlImportJob() {
apiDefinitionImportUtilService = CommonBeanFactory.getBean(ApiDefinitionImportUtilService.class); apiDefinitionImportUtilService = CommonBeanFactory.getBean(ApiDefinitionImportUtilService.class);
apiDefinitionScheduleService = CommonBeanFactory.getBean(ApiDefinitionScheduleService.class); apiDefinitionScheduleService = CommonBeanFactory.getBean(ApiDefinitionScheduleService.class);
userService = CommonBeanFactory.getBean(UserService.class); normalUserService = CommonBeanFactory.getBean(NormalUserService.class);
} }
@Override @Override

View File

@ -10,7 +10,7 @@ import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.log.vo.OperationLogResponse; import io.metersphere.system.log.vo.OperationLogResponse;
import io.metersphere.system.log.vo.ProOperationLogRequest; import io.metersphere.system.log.vo.ProOperationLogRequest;
import io.metersphere.system.log.vo.SystemOperationLogRequest; import io.metersphere.system.log.vo.SystemOperationLogRequest;
import io.metersphere.system.service.UserService; import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
@ -37,7 +37,7 @@ import java.util.List;
public class ProjectLogController { public class ProjectLogController {
@Autowired @Autowired
private UserService userService; private NormalUserService normalUserService;
@Autowired @Autowired
private OperationLogService operationLogService; private OperationLogService operationLogService;
@ -48,7 +48,7 @@ public class ProjectLogController {
public List<User> getUserList(@PathVariable(value = "projectId") String projectId, public List<User> getUserList(@PathVariable(value = "projectId") String projectId,
@Schema(description = "查询关键字,根据邮箱和用户名查询") @Schema(description = "查询关键字,根据邮箱和用户名查询")
@RequestParam(value = "keyword", required = false) String keyword) { @RequestParam(value = "keyword", required = false) String keyword) {
return userService.getUserListByOrgId(StringUtils.defaultIfBlank(projectId, SessionUtils.getCurrentProjectId()), keyword); return normalUserService.getUserListByOrgId(StringUtils.defaultIfBlank(projectId, SessionUtils.getCurrentProjectId()), keyword);
} }

View File

@ -4,17 +4,17 @@ package io.metersphere.system.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.log.vo.SystemOperationLogRequest;
import io.metersphere.system.log.vo.OperationLogResponse;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.metersphere.system.domain.User; import io.metersphere.system.domain.User;
import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
import io.metersphere.system.dto.response.OrganizationProjectOptionsResponse; import io.metersphere.system.dto.response.OrganizationProjectOptionsResponse;
import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.log.vo.OperationLogResponse;
import io.metersphere.system.log.vo.SystemOperationLogRequest;
import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.service.OrganizationService; import io.metersphere.system.service.OrganizationService;
import io.metersphere.system.service.SystemProjectService; import io.metersphere.system.service.SystemProjectService;
import io.metersphere.system.service.UserService; import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -41,7 +41,7 @@ public class OperationLogController {
private OperationLogService operationLogService; private OperationLogService operationLogService;
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@GetMapping("/get/options") @GetMapping("/get/options")
@ -77,7 +77,7 @@ public class OperationLogController {
@RequiresPermissions(PermissionConstants.SYSTEM_LOG_READ) @RequiresPermissions(PermissionConstants.SYSTEM_LOG_READ)
public List<User> getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询") public List<User> getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询")
@RequestParam(value = "keyword", required = false) String keyword) { @RequestParam(value = "keyword", required = false) String keyword) {
List<User> userList = userService.getUserList(keyword); List<User> userList = normalUserService.getUserList(keyword);
return userList; return userList;
} }
} }

View File

@ -12,8 +12,8 @@ import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.log.vo.OperationLogResponse; import io.metersphere.system.log.vo.OperationLogResponse;
import io.metersphere.system.log.vo.OrgOperationLogRequest; import io.metersphere.system.log.vo.OrgOperationLogRequest;
import io.metersphere.system.log.vo.SystemOperationLogRequest; import io.metersphere.system.log.vo.SystemOperationLogRequest;
import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.service.SystemProjectService; import io.metersphere.system.service.SystemProjectService;
import io.metersphere.system.service.UserService;
import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
@ -45,7 +45,7 @@ public class OrganizationLogController {
private OperationLogService operationLogService; private OperationLogService operationLogService;
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@GetMapping("/get/options/{organizationId}") @GetMapping("/get/options/{organizationId}")
@ -67,7 +67,7 @@ public class OrganizationLogController {
public List<User> getLogUserList(@PathVariable(value = "organizationId") String organizationId, public List<User> getLogUserList(@PathVariable(value = "organizationId") String organizationId,
@Schema(description = "查询关键字,根据邮箱和用户名查询") @Schema(description = "查询关键字,根据邮箱和用户名查询")
@RequestParam(value = "keyword", required = false) String keyword) { @RequestParam(value = "keyword", required = false) String keyword) {
return userService.getUserListByOrgId(organizationId, keyword); return normalUserService.getUserListByOrgId(organizationId, keyword);
} }

View File

@ -6,8 +6,8 @@ import io.metersphere.system.dto.request.user.PersonalUpdateRequest;
import io.metersphere.system.dto.user.PersonalDTO; import io.metersphere.system.dto.user.PersonalDTO;
import io.metersphere.system.log.annotation.Log; import io.metersphere.system.log.annotation.Log;
import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.service.UserLogService; import io.metersphere.system.service.UserLogService;
import io.metersphere.system.service.UserService;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -23,13 +23,13 @@ public class
PersonalCenterController { PersonalCenterController {
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@GetMapping("/get/{id}") @GetMapping("/get/{id}")
@Operation(summary = "个人中心-获取信息") @Operation(summary = "个人中心-获取信息")
public PersonalDTO getInformation(@PathVariable String id) { public PersonalDTO getInformation(@PathVariable String id) {
this.checkPermission(id); this.checkPermission(id);
return userService.getPersonalById(id); return normalUserService.getPersonalById(id);
} }
@PostMapping("/update-info") @PostMapping("/update-info")
@ -37,7 +37,7 @@ PersonalCenterController {
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateAccountLog(#request)", msClass = UserLogService.class) @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateAccountLog(#request)", msClass = UserLogService.class)
public boolean updateUser(@Validated @RequestBody PersonalUpdateRequest request) { public boolean updateUser(@Validated @RequestBody PersonalUpdateRequest request) {
this.checkPermission(request.getId()); this.checkPermission(request.getId());
return userService.updateAccount(request, SessionUtils.getUserId()); return normalUserService.updateAccount(request, SessionUtils.getUserId());
} }
@PostMapping("/update-password") @PostMapping("/update-password")
@ -45,7 +45,7 @@ PersonalCenterController {
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updatePasswordLog(#request)", msClass = UserLogService.class) @Log(type = OperationLogType.UPDATE, expression = "#msClass.updatePasswordLog(#request)", msClass = UserLogService.class)
public String updateUser(@Validated @RequestBody PersonalUpdatePasswordRequest request) { public String updateUser(@Validated @RequestBody PersonalUpdatePasswordRequest request) {
this.checkPermission(request.getId()); this.checkPermission(request.getId());
if (userService.updatePassword(request)) { if (normalUserService.updatePassword(request)) {
SessionUtils.kickOutUser(SessionUtils.getUser().getId()); SessionUtils.kickOutUser(SessionUtils.getUser().getId());
} }
return "OK"; return "OK";

View File

@ -11,10 +11,10 @@ import io.metersphere.system.dto.sdk.OptionDTO;
import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.system.dto.user.UserExtendDTO;
import io.metersphere.system.log.annotation.Log; import io.metersphere.system.log.annotation.Log;
import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.service.OrganizationService; import io.metersphere.system.service.OrganizationService;
import io.metersphere.system.service.SystemOrganizationLogService; import io.metersphere.system.service.SystemOrganizationLogService;
import io.metersphere.system.service.SystemProjectService; import io.metersphere.system.service.SystemProjectService;
import io.metersphere.system.service.UserService;
import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
@ -43,7 +43,7 @@ import java.util.Map;
public class SystemOrganizationController { public class SystemOrganizationController {
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@Resource @Resource
private SystemProjectService systemProjectService; private SystemProjectService systemProjectService;
@Resource @Resource
@ -182,6 +182,6 @@ public class SystemOrganizationController {
public List<UserExtendDTO> getMemberOption(@PathVariable String sourceId, public List<UserExtendDTO> getMemberOption(@PathVariable String sourceId,
@Schema(description = "查询关键字,根据邮箱和用户名查询") @Schema(description = "查询关键字,根据邮箱和用户名查询")
@RequestParam(value = "keyword", required = false) String keyword) { @RequestParam(value = "keyword", required = false) String keyword) {
return userService.getMemberOption(sourceId, keyword); return normalUserService.getMemberOption(sourceId, keyword);
} }
} }

View File

@ -15,9 +15,9 @@ import io.metersphere.system.dto.user.UserExtendDTO;
import io.metersphere.system.log.annotation.Log; import io.metersphere.system.log.annotation.Log;
import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.security.CheckOwner; import io.metersphere.system.security.CheckOwner;
import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.service.SystemProjectLogService; import io.metersphere.system.service.SystemProjectLogService;
import io.metersphere.system.service.SystemProjectService; import io.metersphere.system.service.SystemProjectService;
import io.metersphere.system.service.UserService;
import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
@ -43,7 +43,7 @@ public class SystemProjectController {
@Resource @Resource
private SystemProjectService systemProjectService; private SystemProjectService systemProjectService;
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@PostMapping("/add") @PostMapping("/add")
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_ADD) @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_ADD)
@ -156,7 +156,7 @@ public class SystemProjectController {
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ) @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
public List<User> getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询") public List<User> getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询")
@RequestParam(value = "keyword", required = false) String keyword) { @RequestParam(value = "keyword", required = false) String keyword) {
return userService.getUserList(keyword); return normalUserService.getUserList(keyword);
} }
@PostMapping("/pool-options") @PostMapping("/pool-options")

View File

@ -49,7 +49,7 @@ import java.util.Map;
@RequestMapping("/system/user") @RequestMapping("/system/user")
public class UserController { public class UserController {
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@Resource @Resource
private UserToolService userToolService; private UserToolService userToolService;
@Resource @Resource
@ -67,14 +67,14 @@ public class UserController {
@Operation(summary = "通过email或id查找用户") @Operation(summary = "通过email或id查找用户")
@RequiresPermissions(PermissionConstants.SYSTEM_USER_READ) @RequiresPermissions(PermissionConstants.SYSTEM_USER_READ)
public UserDTO getUser(@PathVariable String keyword) { public UserDTO getUser(@PathVariable String keyword) {
return userService.getUserDTOByKeyword(keyword); return normalUserService.getUserDTOByKeyword(keyword);
} }
@PostMapping("/add") @PostMapping("/add")
@Operation(summary = "系统设置-系统-用户-添加用户") @Operation(summary = "系统设置-系统-用户-添加用户")
@RequiresPermissions(PermissionConstants.SYSTEM_USER_ADD) @RequiresPermissions(PermissionConstants.SYSTEM_USER_ADD)
public UserBatchCreateResponse addUser(@Validated({Created.class}) @RequestBody UserBatchCreateRequest userCreateDTO) { public UserBatchCreateResponse addUser(@Validated({Created.class}) @RequestBody UserBatchCreateRequest userCreateDTO) {
return userService.addUser(userCreateDTO, UserSource.LOCAL.name(), SessionUtils.getUserId()); return normalUserService.addUser(userCreateDTO, UserSource.LOCAL.name(), SessionUtils.getUserId());
} }
@PostMapping("/update") @PostMapping("/update")
@ -82,7 +82,7 @@ public class UserController {
@RequiresPermissions(PermissionConstants.SYSTEM_USER_UPDATE) @RequiresPermissions(PermissionConstants.SYSTEM_USER_UPDATE)
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = UserLogService.class) @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = UserLogService.class)
public UserEditRequest updateUser(@Validated({Updated.class}) @RequestBody UserEditRequest request) { public UserEditRequest updateUser(@Validated({Updated.class}) @RequestBody UserEditRequest request) {
return userService.updateUser(request, SessionUtils.getUserId()); return normalUserService.updateUser(request, SessionUtils.getUserId());
} }
@PostMapping("/page") @PostMapping("/page")
@ -91,7 +91,7 @@ public class UserController {
public Pager<List<UserTableResponse>> list(@Validated @RequestBody BasePageRequest request) { public Pager<List<UserTableResponse>> list(@Validated @RequestBody BasePageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString("id")) ? request.getSortString("id") : "create_time desc,id desc"); StringUtils.isNotBlank(request.getSortString("id")) ? request.getSortString("id") : "create_time desc,id desc");
return PageUtils.setPageInfo(page, userService.list(request)); return PageUtils.setPageInfo(page, normalUserService.list(request));
} }
@PostMapping("/update/enable") @PostMapping("/update/enable")
@ -99,14 +99,14 @@ public class UserController {
@RequiresPermissions(PermissionConstants.SYSTEM_USER_UPDATE) @RequiresPermissions(PermissionConstants.SYSTEM_USER_UPDATE)
@Log(type = OperationLogType.UPDATE, expression = "#msClass.batchUpdateEnableLog(#request)", msClass = UserLogService.class) @Log(type = OperationLogType.UPDATE, expression = "#msClass.batchUpdateEnableLog(#request)", msClass = UserLogService.class)
public TableBatchProcessResponse updateUserEnable(@Validated @RequestBody UserChangeEnableRequest request) { public TableBatchProcessResponse updateUserEnable(@Validated @RequestBody UserChangeEnableRequest request) {
return userService.updateUserEnable(request, SessionUtils.getUserId(), SessionUtils.getUser().getName()); return normalUserService.updateUserEnable(request, SessionUtils.getUserId(), SessionUtils.getUser().getName());
} }
@PostMapping(value = "/import", consumes = {"multipart/form-data"}) @PostMapping(value = "/import", consumes = {"multipart/form-data"})
@Operation(summary = "系统设置-系统-用户-导入用户") @Operation(summary = "系统设置-系统-用户-导入用户")
@RequiresPermissions(PermissionConstants.SYSTEM_USER_IMPORT) @RequiresPermissions(PermissionConstants.SYSTEM_USER_IMPORT)
public UserImportResponse importUser(@RequestPart(value = "file", required = false) MultipartFile excelFile) { public UserImportResponse importUser(@RequestPart(value = "file", required = false) MultipartFile excelFile) {
return userService.importByExcel(excelFile, UserSource.LOCAL.name(), SessionUtils.getUserId()); return normalUserService.importByExcel(excelFile, UserSource.LOCAL.name(), SessionUtils.getUserId());
} }
@PostMapping("/delete") @PostMapping("/delete")
@ -114,7 +114,7 @@ public class UserController {
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#request)", msClass = UserLogService.class) @Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#request)", msClass = UserLogService.class)
@RequiresPermissions(PermissionConstants.SYSTEM_USER_DELETE) @RequiresPermissions(PermissionConstants.SYSTEM_USER_DELETE)
public TableBatchProcessResponse deleteUser(@Validated @RequestBody TableBatchProcessDTO request) { public TableBatchProcessResponse deleteUser(@Validated @RequestBody TableBatchProcessDTO request) {
return userService.deleteUser(request, SessionUtils.getUserId(), SessionUtils.getUser().getName()); return normalUserService.deleteUser(request, SessionUtils.getUserId(), SessionUtils.getUser().getName());
} }
@PostMapping("/reset/password") @PostMapping("/reset/password")
@ -122,7 +122,7 @@ public class UserController {
@RequiresPermissions(PermissionConstants.SYSTEM_USER_UPDATE) @RequiresPermissions(PermissionConstants.SYSTEM_USER_UPDATE)
@Log(type = OperationLogType.UPDATE, expression = "#msClass.resetPasswordLog(#request)", msClass = UserLogService.class) @Log(type = OperationLogType.UPDATE, expression = "#msClass.resetPasswordLog(#request)", msClass = UserLogService.class)
public TableBatchProcessResponse resetPassword(@Validated @RequestBody TableBatchProcessDTO request) { public TableBatchProcessResponse resetPassword(@Validated @RequestBody TableBatchProcessDTO request) {
return userService.resetPassword(request, SessionUtils.getUserId()); return normalUserService.resetPassword(request, SessionUtils.getUserId());
} }
@GetMapping("/get/global/system/role") @GetMapping("/get/global/system/role")
@ -186,18 +186,18 @@ public class UserController {
@Operation(summary = "系统设置-系统-用户-邀请用户注册") @Operation(summary = "系统设置-系统-用户-邀请用户注册")
@RequiresPermissions(PermissionConstants.SYSTEM_USER_INVITE) @RequiresPermissions(PermissionConstants.SYSTEM_USER_INVITE)
public UserInviteResponse invite(@Validated @RequestBody UserInviteRequest request) { public UserInviteResponse invite(@Validated @RequestBody UserInviteRequest request) {
return userService.saveInviteRecord(request, SessionUtils.getUser()); return normalUserService.saveInviteRecord(request, SessionUtils.getUser());
} }
@GetMapping("/check-invite/{inviteId}") @GetMapping("/check-invite/{inviteId}")
@Operation(summary = "系统设置-系统-用户-用户接受注册邀请并创建账户") @Operation(summary = "系统设置-系统-用户-用户接受注册邀请并创建账户")
public void checkInviteNum(@PathVariable String inviteId) { public void checkInviteNum(@PathVariable String inviteId) {
userService.getUserInviteAndCheckEfficient(inviteId); normalUserService.getUserInviteAndCheckEfficient(inviteId);
} }
@PostMapping("/register-by-invite") @PostMapping("/register-by-invite")
@Operation(summary = "系统设置-系统-用户-用户接受注册邀请并创建账户") @Operation(summary = "系统设置-系统-用户-用户接受注册邀请并创建账户")
public String registerByInvite(@Validated @RequestBody UserRegisterRequest request) throws Exception { public String registerByInvite(@Validated @RequestBody UserRegisterRequest request) throws Exception {
return userService.registerByInvite(request); return normalUserService.registerByInvite(request);
} }
} }

View File

@ -7,6 +7,9 @@ import io.metersphere.sdk.exception.IResultCode;
*/ */
public enum SystemResultCode implements IResultCode { public enum SystemResultCode implements IResultCode {
USER_TOO_MANY(101511, "User too many"),
DEPT_USER_TOO_MANY(101512, "Department user too many"),
/** /**
* 调用获取全局用户组接口如果操作的是非全局的用户组会返回该响应码 * 调用获取全局用户组接口如果操作的是非全局的用户组会返回该响应码
*/ */

View File

@ -1,20 +1,20 @@
package io.metersphere.system.service; package io.metersphere.system.service;
import io.metersphere.sdk.constants.UserRoleScope; import io.metersphere.sdk.constants.UserRoleScope;
import io.metersphere.system.dto.table.TableBatchProcessResponse;
import io.metersphere.system.dto.user.UserExcludeOptionDTO;
import io.metersphere.system.dto.user.UserRoleRelationUserDTO;
import io.metersphere.system.dto.sdk.request.GlobalUserRoleRelationUpdateRequest;
import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.exception.MSException;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.UserRole; import io.metersphere.system.domain.UserRole;
import io.metersphere.system.domain.UserRoleRelation; import io.metersphere.system.domain.UserRoleRelation;
import io.metersphere.system.domain.UserRoleRelationExample; import io.metersphere.system.domain.UserRoleRelationExample;
import io.metersphere.system.dto.request.GlobalUserRoleRelationQueryRequest; import io.metersphere.system.dto.request.GlobalUserRoleRelationQueryRequest;
import io.metersphere.system.mapper.ExtUserRoleRelationMapper;
import io.metersphere.system.dto.request.user.UserRoleBatchRelationRequest; import io.metersphere.system.dto.request.user.UserRoleBatchRelationRequest;
import io.metersphere.system.dto.sdk.request.GlobalUserRoleRelationUpdateRequest;
import io.metersphere.system.dto.table.TableBatchProcessResponse;
import io.metersphere.system.dto.user.UserExcludeOptionDTO;
import io.metersphere.system.dto.user.UserRoleRelationUserDTO;
import io.metersphere.system.mapper.ExtUserRoleRelationMapper;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated; import io.metersphere.validation.groups.Updated;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -41,7 +41,7 @@ public class GlobalUserRoleRelationService extends BaseUserRoleRelationService {
@Resource @Resource
private GlobalUserRoleService globalUserRoleService; private GlobalUserRoleService globalUserRoleService;
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@Resource @Resource
private UserToolService userToolService; private UserToolService userToolService;
@Resource @Resource
@ -71,7 +71,7 @@ public class GlobalUserRoleRelationService extends BaseUserRoleRelationService {
this.checkGlobalSystemUserRoleLegality( this.checkGlobalSystemUserRoleLegality(
Collections.singletonList(request.getRoleId())); Collections.singletonList(request.getRoleId()));
//检查用户的合法性 //检查用户的合法性
userService.checkUserLegality(request.getUserIds()); normalUserService.checkUserLegality(request.getUserIds());
List<UserRoleRelation> userRoleRelations = new ArrayList<>(); List<UserRoleRelation> userRoleRelations = new ArrayList<>();
request.getUserIds().forEach(userId -> { request.getUserIds().forEach(userId -> {
UserRoleRelation userRoleRelation = new UserRoleRelation(); UserRoleRelation userRoleRelation = new UserRoleRelation();
@ -100,7 +100,7 @@ public class GlobalUserRoleRelationService extends BaseUserRoleRelationService {
//获取本次处理的用户 //获取本次处理的用户
request.setSelectIds(userToolService.getBatchUserIds(request)); request.setSelectIds(userToolService.getBatchUserIds(request));
//检查用户的合法性 //检查用户的合法性
userService.checkUserLegality(request.getSelectIds()); normalUserService.checkUserLegality(request.getSelectIds());
List<UserRoleRelation> savedUserRoleRelation = this.selectByUserIdAndRuleId(request.getSelectIds(), request.getRoleIds()); List<UserRoleRelation> savedUserRoleRelation = this.selectByUserIdAndRuleId(request.getSelectIds(), request.getRoleIds());
//过滤已经存储过的用户关系 //过滤已经存储过的用户关系
Map<String, List<String>> userRoleIdMap = savedUserRoleRelation.stream() Map<String, List<String>> userRoleIdMap = savedUserRoleRelation.stream()

View File

@ -2,9 +2,9 @@ package io.metersphere.system.service;
import com.alibaba.excel.EasyExcelFactory; import com.alibaba.excel.EasyExcelFactory;
import io.metersphere.sdk.constants.ParamConstants; import io.metersphere.sdk.constants.ParamConstants;
import io.metersphere.sdk.constants.UserSource;
import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.*; import io.metersphere.sdk.util.*;
import io.metersphere.system.controller.result.SystemResultCode;
import io.metersphere.system.domain.*; import io.metersphere.system.domain.*;
import io.metersphere.system.dto.excel.UserExcel; import io.metersphere.system.dto.excel.UserExcel;
import io.metersphere.system.dto.excel.UserExcelRowDTO; import io.metersphere.system.dto.excel.UserExcelRowDTO;
@ -32,7 +32,6 @@ import io.metersphere.system.dto.user.response.UserTableResponse;
import io.metersphere.system.log.service.OperationLogService; import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.mapper.*; import io.metersphere.system.mapper.*;
import io.metersphere.system.notice.sender.impl.MailNoticeSender; import io.metersphere.system.notice.sender.impl.MailNoticeSender;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
import io.metersphere.system.utils.UserImportEventListener; import io.metersphere.system.utils.UserImportEventListener;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -63,7 +62,7 @@ import java.util.stream.Collectors;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class UserService { public class NormalUserService {
@Resource @Resource
private BaseUserMapper baseUserMapper; private BaseUserMapper baseUserMapper;
@Resource @Resource
@ -131,29 +130,17 @@ public class UserService {
} }
private List<UserCreateInfo> saveUserAndRole(UserBatchCreateRequest userCreateDTO, String source, String operator, String requestPath) { private List<UserCreateInfo> saveUserAndRole(UserBatchCreateRequest userCreateDTO, String source, String operator, String requestPath) {
List<UserCreateInfo> insertList = new ArrayList<>(); int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).guessWhatHowToAddUser(userCreateDTO, source, operator);
long createTime = System.currentTimeMillis(); if (responseCode == 0) {
List<User> saveUserList = new ArrayList<>(); operationLogService.batchAdd(userLogService.getBatchAddLogs(userCreateDTO.getUserInfoList(), operator, requestPath));
//添加用户 } else {
for (UserCreateInfo userInfo : userCreateDTO.getUserInfoList()) { if (responseCode == -1) {
userInfo.setId(IDGenerator.nextStr()); throw new MSException(SystemResultCode.USER_TOO_MANY, Translator.getWithArgs("user_open_source_max", 30));
User user = new User(); } else {
BeanUtils.copyBean(user, userInfo); throw new MSException(SystemResultCode.DEPT_USER_TOO_MANY, Translator.getWithArgs("user_dept_max", responseCode));
user.setCreateUser(operator);
user.setCreateTime(createTime);
user.setUpdateUser(operator);
user.setUpdateTime(createTime);
user.setPassword(CodingUtils.md5(user.getEmail()));
user.setSource(source);
user.setDeleted(false);
userMapper.insertSelective(user);
saveUserList.add(user);
insertList.add(userInfo);
} }
userRoleRelationService.batchSave(userCreateDTO.getUserRoleIdList(), saveUserList); }
//写入操作日志 return userCreateDTO.getUserInfoList();
operationLogService.batchAdd(userLogService.getBatchAddLogs(saveUserList, requestPath));
return insertList;
} }
public UserDTO getUserDTOByKeyword(String email) { public UserDTO getUserDTOByKeyword(String email) {
@ -277,15 +264,16 @@ public class UserService {
} }
UserImportResponse importResponse = new UserImportResponse(); UserImportResponse importResponse = new UserImportResponse();
ExcelParseDTO<UserExcelRowDTO> excelParseDTO = new ExcelParseDTO<>();
try { try {
ExcelParseDTO<UserExcelRowDTO> excelParseDTO = this.getUserExcelParseDTO(excelFile); excelParseDTO = this.getUserExcelParseDTO(excelFile);
} catch (Exception e) {
LogUtils.info("import user error", e);
}
if (CollectionUtils.isNotEmpty(excelParseDTO.getDataList())) { if (CollectionUtils.isNotEmpty(excelParseDTO.getDataList())) {
this.saveUserByExcelData(excelParseDTO.getDataList(), source, sessionId); this.saveUserByExcelData(excelParseDTO.getDataList(), source, sessionId);
} }
importResponse.generateResponse(excelParseDTO); importResponse.generateResponse(excelParseDTO);
} catch (Exception e) {
LogUtils.info("import user error", e);
}
return importResponse; return importResponse;
} }
@ -297,7 +285,6 @@ public class UserService {
/** /**
* 校验excel导入的数据是否与数据库中的数据冲突 * 校验excel导入的数据是否与数据库中的数据冲突
*
*/ */
private ExcelParseDTO<UserExcelRowDTO> validateExcelUserInfo(@Valid @NotNull ExcelParseDTO<UserExcelRowDTO> excelParseDTO) { private ExcelParseDTO<UserExcelRowDTO> validateExcelUserInfo(@Valid @NotNull ExcelParseDTO<UserExcelRowDTO> excelParseDTO) {
List<UserExcelRowDTO> prepareSaveList = excelParseDTO.getDataList(); List<UserExcelRowDTO> prepareSaveList = excelParseDTO.getDataList();
@ -540,28 +527,23 @@ public class UserService {
this.add(userInvite.getEmail()); this.add(userInvite.getEmail());
}}); }});
//创建用户 int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).guessWhatHowToAddUser(request, userInvite);
long createTime = System.currentTimeMillis(); if (responseCode == 0) {
User user = new User();
user.setId(IDGenerator.nextStr());
user.setEmail(userInvite.getEmail());
user.setPassword(CodingUtils.md5(RsaUtils.privateDecrypt(request.getPassword(), RsaUtils.getRsaKey().getPrivateKey())));
user.setName(request.getName());
user.setPhone(request.getPhone());
user.setCreateUser(userInvite.getInviteUser());
user.setUpdateUser(userInvite.getInviteUser());
user.setCreateTime(createTime);
user.setUpdateTime(createTime);
user.setSource(UserSource.LOCAL.name());
user.setDeleted(false);
userMapper.insertSelective(user);
userRoleRelationService.batchSave(JSON.parseArray(userInvite.getRoles(), String.class), user);
//删除本次邀请记录 //删除本次邀请记录
userInviteService.deleteInviteById(userInvite.getId()); userInviteService.deleteInviteById(userInvite.getId());
//写入操作日志 //写入操作日志
userLogService.addRegisterLog(user, userInvite); UserExample userExample = new UserExample();
return user.getId(); userExample.createCriteria().andEmailEqualTo(userInvite.getEmail());
userLogService.addRegisterLog(userMapper.selectByExample(userExample).getFirst(), userInvite);
return userInvite.getEmail();
} else {
if (responseCode > 30) {
throw new MSException(SystemResultCode.DEPT_USER_TOO_MANY, Translator.getWithArgs("user_dept_max", responseCode));
} else {
throw new MSException(SystemResultCode.USER_TOO_MANY, Translator.getWithArgs("user_open_source_max", responseCode));
}
}
} }
public boolean updateAccount(PersonalUpdateRequest request, String operator) { public boolean updateAccount(PersonalUpdateRequest request, String operator) {

View File

@ -11,6 +11,7 @@ import io.metersphere.system.domain.*;
import io.metersphere.system.dto.builder.LogDTOBuilder; import io.metersphere.system.dto.builder.LogDTOBuilder;
import io.metersphere.system.dto.request.user.*; import io.metersphere.system.dto.request.user.*;
import io.metersphere.system.dto.table.TableBatchProcessDTO; import io.metersphere.system.dto.table.TableBatchProcessDTO;
import io.metersphere.system.dto.user.UserCreateInfo;
import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.dto.LogDTO; import io.metersphere.system.log.dto.LogDTO;
@ -45,7 +46,7 @@ public class UserLogService {
private UserRoleMapper userRoleMapper; private UserRoleMapper userRoleMapper;
//批量添加用户记录日志 //批量添加用户记录日志
public List<LogDTO> getBatchAddLogs(@Valid List<User> userList, String requestPath) { public List<LogDTO> getBatchAddLogs(@Valid List<UserCreateInfo> userList, String operator, String requestPath) {
List<LogDTO> logs = new ArrayList<>(); List<LogDTO> logs = new ArrayList<>();
userList.forEach(user -> { userList.forEach(user -> {
LogDTO log = LogDTOBuilder.builder() LogDTO log = LogDTOBuilder.builder()
@ -58,7 +59,7 @@ public class UserLogService {
.sourceId(user.getId()) .sourceId(user.getId())
.content(user.getName() + "(" + user.getEmail() + ")") .content(user.getName() + "(" + user.getEmail() + ")")
.originalValue(JSON.toJSONBytes(user)) .originalValue(JSON.toJSONBytes(user))
.createUser(user.getCreateUser()) .createUser(operator)
.build().getLogDTO(); .build().getLogDTO();
logs.add(log); logs.add(log);
}); });

View File

@ -23,10 +23,7 @@ import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -82,55 +79,6 @@ public class UserRoleRelationService {
return logs; return logs;
} }
public void batchSave(List<String> userRoleIdList, List<User> userList) {
long operationTime = System.currentTimeMillis();
List<UserRoleRelation> userRoleRelationSaveList = new ArrayList<>();
//添加用户组织关系
for (String userRoleId : userRoleIdList) {
for (User user : userList) {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setUserId(user.getId());
userRoleRelation.setRoleId(userRoleId);
userRoleRelation.setSourceId(UserRoleScope.SYSTEM);
userRoleRelation.setCreateTime(operationTime);
userRoleRelation.setCreateUser(user.getCreateUser());
userRoleRelation.setOrganizationId(UserRoleScope.SYSTEM);
userRoleRelationSaveList.add(userRoleRelation);
}
}
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
UserRoleRelationMapper batchSaveMapper = sqlSession.getMapper(UserRoleRelationMapper.class);
int insertIndex = 0;
for (UserRoleRelation userRoleRelation : userRoleRelationSaveList) {
batchSaveMapper.insert(userRoleRelation);
insertIndex++;
if (insertIndex % 50 == 0) {
sqlSession.flushStatements();
}
}
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
}
public void batchSave(List<String> userRoleIdList, User user) {
long operationTime = System.currentTimeMillis();
List<UserRoleRelation> userRoleRelationSaveList = new ArrayList<>();
//添加用户组织关系
for (String userRoleId : userRoleIdList) {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setUserId(user.getId());
userRoleRelation.setRoleId(userRoleId);
userRoleRelation.setSourceId(UserRoleScope.SYSTEM);
userRoleRelation.setOrganizationId(UserRoleScope.SYSTEM);
userRoleRelation.setCreateTime(operationTime);
userRoleRelation.setCreateUser(user.getCreateUser());
userRoleRelationSaveList.add(userRoleRelation);
}
userRoleRelationMapper.batchInsert(userRoleRelationSaveList);
}
public Map<Organization, List<Project>> selectOrganizationProjectByUserId(String userId) { public Map<Organization, List<Project>> selectOrganizationProjectByUserId(String userId) {
Map<Organization, List<Project>> returnMap = new LinkedHashMap<>(); Map<Organization, List<Project>> returnMap = new LinkedHashMap<>();
UserRoleRelationExample example = new UserRoleRelationExample(); UserRoleRelationExample example = new UserRoleRelationExample();

View File

@ -0,0 +1,15 @@
package io.metersphere.system.service;
import io.metersphere.system.domain.UserInvite;
import io.metersphere.system.dto.request.UserRegisterRequest;
import io.metersphere.system.dto.user.request.UserBatchCreateRequest;
/**
* 系统用户相关接口
*/
public interface UserXpackService {
int guessWhatHowToAddUser(UserBatchCreateRequest userCreateDTO, String source, String operator);
int guessWhatHowToAddUser(UserRegisterRequest registerRequest, UserInvite userInvite) throws Exception;
}

View File

@ -15,7 +15,7 @@ import io.metersphere.system.dto.user.UserDTO;
import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.mapper.UserExtendMapper; import io.metersphere.system.mapper.UserExtendMapper;
import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.service.UserService; import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.user.PersonalRequestUtils; import io.metersphere.system.utils.user.PersonalRequestUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -39,7 +39,7 @@ public class PersonalControllerTests extends BaseTest {
@Resource @Resource
private UserMapper userMapper; private UserMapper userMapper;
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@Test @Test
@Order(0) @Order(0)
@ -63,7 +63,7 @@ public class PersonalControllerTests extends BaseTest {
@Order(1) @Order(1)
void testPersonalUpdateInfo() throws Exception { void testPersonalUpdateInfo() throws Exception {
//方法测试 //方法测试
userService.checkUserEmail(IDGenerator.nextStr(), "admin_update@metersphere.io"); normalUserService.checkUserEmail(IDGenerator.nextStr(), "admin_update@metersphere.io");
PersonalUpdateRequest request = new PersonalUpdateRequest(); PersonalUpdateRequest request = new PersonalUpdateRequest();
request.setId(loginUser); request.setId(loginUser);
@ -76,7 +76,7 @@ public class PersonalControllerTests extends BaseTest {
boolean methodCheck = false; boolean methodCheck = false;
try { try {
userService.checkUserEmail(IDGenerator.nextStr(), "admin_update@metersphere.io"); normalUserService.checkUserEmail(IDGenerator.nextStr(), "admin_update@metersphere.io");
} catch (Exception e) { } catch (Exception e) {
methodCheck = true; methodCheck = true;
} }

View File

@ -24,7 +24,7 @@ import io.metersphere.system.dto.sdk.OptionDTO;
import io.metersphere.system.mapper.BaseUserMapper; import io.metersphere.system.mapper.BaseUserMapper;
import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.service.UserService; import io.metersphere.system.service.NormalUserService;
import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
@ -47,7 +47,7 @@ public class TestPlanReportService {
@Resource @Resource
private UserMapper userMapper; private UserMapper userMapper;
@Resource @Resource
private UserService userService; private NormalUserService normalUserService;
@Resource @Resource
private SqlSessionFactory sqlSessionFactory; private SqlSessionFactory sqlSessionFactory;
@Resource @Resource
@ -91,7 +91,7 @@ public class TestPlanReportService {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> distinctUserIds = reportList.stream().map(TestPlanReportPageResponse::getCreateUser).distinct().toList(); List<String> distinctUserIds = reportList.stream().map(TestPlanReportPageResponse::getCreateUser).distinct().toList();
Map<String, String> userMap = userService.getUserMapByIds(distinctUserIds); Map<String, String> userMap = normalUserService.getUserMapByIds(distinctUserIds);
reportList.forEach(report -> report.setCreateUserName(userMap.get(report.getCreateUser()))); reportList.forEach(report -> report.setCreateUserName(userMap.get(report.getCreateUser())));
return reportList; return reportList;
} }