refactor(缺陷管理): 补充缺陷管理关联相关的用户名称字段

This commit is contained in:
guoyuqi 2024-09-18 16:31:12 +08:00 committed by Craftsman
parent 2b4a5fcda3
commit 38ba1c030a
3 changed files with 6 additions and 6 deletions

View File

@ -109,7 +109,8 @@
b.num as num,
b.title as name,
b.handle_user as handleUser,
createUser.name AS createUser,
createUser.id AS createUser,
createUser.name AS createUserName,
bc.description AS content,
b.`status` as status,
b.tags as tags,

View File

@ -132,6 +132,7 @@
b.title as name,
b.handle_user handleUser,
b.create_user createUser,
createUser.name AS createUserName,
b.`status`,
bc.description as content,
brc.test_plan_id testPlanId,
@ -140,6 +141,7 @@
bug_relation_case brc
INNER JOIN bug b ON brc.bug_id = b.id
INNER JOIN bug_content bc ON brc.bug_id = bc.bug_id
LEFT JOIN user createUser ON b.create_user = createUser.id
left join test_plan tp on brc.test_plan_id = tp.id
<where>
<include refid="queryWhereConditionByProvider"/>
@ -287,6 +289,7 @@
b.title as name,
b.handle_user handleUser,
b.create_user createUser,
createUser.name AS createUserName,
b.`status`,
bc.description as content,
brc.test_plan_id testPlanId,
@ -296,6 +299,7 @@
INNER JOIN bug b ON brc.bug_id = b.id
INNER JOIN bug_content bc ON brc.bug_id = bc.bug_id
left join test_plan tp on brc.test_plan_id = tp.id
LEFT JOIN user createUser ON b.create_user = createUser.id
<where>
<if test="request.testPlanCaseId != null and request.testPlanCaseId != ''">
and brc.test_plan_case_id = #{request.testPlanCaseId}

View File

@ -19,13 +19,11 @@ import io.metersphere.system.service.UserLoginService;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@ -117,12 +115,9 @@ public class AssociateBugProvider implements BaseAssociateBugProvider {
public List<BugProviderDTO> buildAssociateBugs(List<BugProviderDTO> associateBugs, String projectId) {
List<SelectOption> headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
List<SelectOption> statusOption = bugStatusService.getHeaderStatusOption(projectId);
List<String> createUserList = associateBugs.stream().map(BugProviderDTO::getCreateUser).distinct().toList();
Map<String, String> userMap = userLoginService.getUserNameMap(createUserList.stream().filter(StringUtils::isNotBlank).distinct().toList());
associateBugs.forEach(item -> {
headerHandlerOption.stream().filter(option -> StringUtils.equals(option.getValue(), item.getHandleUser())).findFirst().ifPresent(option -> item.setHandleUserName(option.getText()));
statusOption.stream().filter(option -> StringUtils.equals(option.getValue(), item.getStatus())).findFirst().ifPresent(option -> item.setStatusName(option.getText()));
item.setCreateUserName(MapUtils.isNotEmpty(userMap) && userMap.containsKey(item.getCreateUser()) ? userMap.get(item.getCreateUser()) : StringUtils.EMPTY);
});
return associateBugs;
}