diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java index 8505f96e4f..3b60e1c1b5 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java @@ -10,6 +10,7 @@ import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.log.service.OperationLogService; +import io.metersphere.sdk.service.BaseUserService; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Translator; @@ -62,8 +63,9 @@ public class OrganizationService { @Resource private UserRolePermissionMapper userRolePermissionMapper; @Resource - @Lazy private PluginOrganizationService pluginOrganizationService; + @Resource + private BaseUserService baseUserService; private static final String ADD_MEMBER_PATH = "/system/organization/add-member"; private static final String REMOVE_MEMBER_PATH = "/system/organization/remove-member"; @@ -76,7 +78,8 @@ public class OrganizationService { */ public List list(OrganizationRequest organizationRequest) { List organizationDTOS = extOrganizationMapper.list(organizationRequest); - return buildOrgAdminInfo(organizationDTOS); + List organizations = buildUserInfo(organizationDTOS); + return buildOrgAdminInfo(organizations); } /** @@ -781,6 +784,22 @@ public class OrganizationService { return organizationDTOS; } + /** + * 设置用户信息 + * + * @param organizationDTOS 组织集合 + * @return 组织集合 + */ + private List buildUserInfo(List organizationDTOS) { + Map userMap = baseUserService.getUserNameMap(); + organizationDTOS.forEach(organizationDTO -> { + organizationDTO.setCreateUser(userMap.get(organizationDTO.getCreateUser())); + organizationDTO.setDeleteUser(userMap.get(organizationDTO.getDeleteUser())); + organizationDTO.setUpdateUser(userMap.get(organizationDTO.getUpdateUser())); + }); + return organizationDTOS; + } + /** * 设置操作日志 * @@ -809,13 +828,6 @@ public class OrganizationService { logs.add(dto); } - public List getOptionsByIds(List orgIds) { - if (CollectionUtils.isEmpty(orgIds)) { - return new ArrayList<>(0); - } - return extOrganizationMapper.getOptionsByIds(orgIds); - } - public LinkedHashMap> getOrgProjectMap() { ProjectExample projectExample = new ProjectExample(); projectExample.setOrderByClause("name asc"); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginOrganizationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginOrganizationService.java index 979d147d6e..4f186117ef 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginOrganizationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginOrganizationService.java @@ -3,6 +3,7 @@ package io.metersphere.system.service; import io.metersphere.sdk.dto.OptionDTO; import io.metersphere.system.domain.PluginOrganization; import io.metersphere.system.domain.PluginOrganizationExample; +import io.metersphere.system.mapper.ExtOrganizationMapper; import io.metersphere.system.mapper.PluginOrganizationMapper; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; @@ -19,7 +20,7 @@ public class PluginOrganizationService { @Resource private PluginOrganizationMapper pluginOrganizationMapper; @Resource - private OrganizationService organizationService; + private ExtOrganizationMapper extOrganizationMapper; public void add(String pluginId, List orgIds) { if (CollectionUtils.isEmpty(orgIds)) { @@ -69,7 +70,7 @@ public class PluginOrganizationService { // 查询组织信息 List orgIds = pluginOrganizations.stream().map(PluginOrganization::getOrganizationId).toList(); - List orgList = organizationService.getOptionsByIds(orgIds); + List orgList = getOptionsByIds(orgIds); Map orgInfoMap = orgList.stream().collect(Collectors.toMap(OptionDTO::getId, i -> i)); // 组装成 map @@ -86,4 +87,11 @@ public class PluginOrganizationService { } return orgMap; } + + public List getOptionsByIds(List orgIds) { + if (CollectionUtils.isEmpty(orgIds)) { + return new ArrayList<>(0); + } + return extOrganizationMapper.getOptionsByIds(orgIds); + } }