feat(工作台): 补充工作台缺陷卡片跳转参数

--task=1017265 --user=宋昌昌 首页部分指标增加跳转-缺陷-后端接口 https://www.tapd.cn/55049933/s/1623209
This commit is contained in:
song-cc-rock 2024-12-03 14:44:37 +08:00 committed by Craftsman
parent 8b98b6fa7c
commit 628b642b30
8 changed files with 100 additions and 58 deletions

View File

@ -95,6 +95,7 @@ public class BugController {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc"); StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
request.setUseTrash(false); request.setUseTrash(false);
request.setTodoParam(bugService.buildBugToDoParam(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId()));
return PageUtils.setPageInfo(page, bugService.list(request)); return PageUtils.setPageInfo(page, bugService.list(request));
} }

View File

@ -20,6 +20,18 @@ public class BugPageRequest extends BasePageRequest {
@Schema(description = "是否回收站, 后台默认设置") @Schema(description = "是否回收站, 后台默认设置")
private boolean useTrash; private boolean useTrash;
@Schema(description = "待办参数, 后台默认设置") @Schema(description = "待办参数: 后台默认设置")
private BugTodoRequest todoParam; private BugTodoRequest todoParam;
@Schema(description = "工作台参数: 是否属于测试计划")
private Boolean relatedToPlan = false;
@Schema(description = "工作台参数: 是否我创建的")
private Boolean createByMe = false;
@Schema(description = "工作台参数: 是否待我处理的")
private Boolean assignedToMe = false;
@Schema(description = "工作台参数: 是否遗留的")
private Boolean unresolved = false;
} }

View File

@ -8,7 +8,7 @@ import java.util.List;
/** /**
* @author song-cc-rock * @author song-cc-rock
* 缺陷待办参数 * 缺陷待办参数 (工作台)
*/ */
@Data @Data
@Builder @Builder

View File

@ -162,36 +162,48 @@
or b.tags like concat('%', #{request.keyword},'%') or b.tags like concat('%', #{request.keyword},'%')
) )
</if> </if>
<!-- 我的待办 --> <!-- 待办参数 -->
<if test="request.todoParam != null"> <if test="request.todoParam != null">
and ( and (
<!-- Local平台: 非结束状态&&处理人为当前登录用户 --> <!-- Local平台: 非结束状态&&处理人为当前登录用户 -->
( (
b.platform = 'Local' b.platform = 'Local'
<if test="request.todoParam.msLastStepStatus != null and request.todoParam.msLastStepStatus.size() > 0"> <if test="request.todoParam.msLastStepStatus != null and request.todoParam.msLastStepStatus.size() > 0">
and b.status not in and b.status not in
<foreach collection="request.todoParam.msLastStepStatus" item="lastStatus" separator="," open="(" close=")"> <foreach collection="request.todoParam.msLastStepStatus" item="lastStatus" separator="," open="(" close=")">
#{lastStatus} #{lastStatus}
</foreach> </foreach>
</if> </if>
and b.handle_user = #{request.todoParam.msUserId} <if test="request.todoParam.msUserId != null and request.todoParam.msUserId != ''">
) and b.handle_user = #{request.todoParam.msUserId}
<if test="request.todoParam.currentPlatform != null and request.todoParam.currentPlatform != 'Local'"> </if>
)
<if test="request.todoParam.currentPlatform != null and request.todoParam.currentPlatform != 'Local'">
<!-- 插件平台: 非平台结束状态&&处理人为个人中心账号配置 --> <!-- 插件平台: 非平台结束状态&&处理人为个人中心账号配置 -->
or or
( (
b.platform = #{request.todoParam.currentPlatform} b.platform = #{request.todoParam.currentPlatform}
<if test="request.todoParam.platformLastStatus != null and request.todoParam.platformLastStatus.size() > 0"> <if test="request.todoParam.platformLastStatus != null and request.todoParam.platformLastStatus.size() > 0">
and b.status not in and b.status not in
<foreach collection="request.todoParam.platformLastStatus" item="lastStatus" separator="," open="(" close=")"> <foreach collection="request.todoParam.platformLastStatus" item="lastStatus" separator="," open="(" close=")">
#{lastStatus} #{lastStatus}
</foreach> </foreach>
</if>
<if test="request.todoParam.platformUser != null and request.todoParam.platformUser != ''">
and b.handle_user = #{request.todoParam.platformUser}
</if>
)
</if> </if>
<if test="request.todoParam.platformUser != null and request.todoParam.platformUser != ''"> )
and b.handle_user = #{request.todoParam.platformUser} </if>
</if> <!-- 工作台参数 -->
) <if test="request.createByMe">
</if> and b.create_user = #{request.todoParam.msUserId}
</if>
<if test="request.relatedToPlan">
and b.id in (
select distinct b.id from bug b inner join bug_relation_case brc on b.id = brc.bug_id
where brc.test_plan_id is not null and b.project_id = #{request.projectId}
) )
</if> </if>
<include refid="filter"/> <include refid="filter"/>

View File

@ -2106,7 +2106,49 @@ public class BugService {
} }
} }
/**
* 获取平台临时富文本图片URL
* @param key 富文本图片key
* @return 富文本图片URL
*/
private String getPlatformTmpRichUrlOfKey(String key) { private String getPlatformTmpRichUrlOfKey(String key) {
return "alt=\"" + key + "\""; return "alt=\"" + key + "\"";
} }
/**
* 设置缺陷待办参数
* @param request 请求参数
* @param currentUserId 当前用户ID
* @param currentOrgId 当前组织ID
* @return 待办参数
*/
public BugTodoRequest buildBugToDoParam(BugPageRequest request, String currentUserId, String currentOrgId) {
List<String> msLastStepStatusIds = bugCommonService.getLocalLastStepStatus(request.getProjectId());
BugTodoRequest todoParam = BugTodoRequest.builder().build();
if (request.getAssignedToMe() || request.getCreateByMe()) {
todoParam.setMsUserId(currentUserId);
}
if (request.getUnresolved()) {
todoParam.setMsLastStepStatus(msLastStepStatusIds);
}
try {
// 设置待办的平台参数
String platformName = projectApplicationService.getPlatformName(request.getProjectId());
if (StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
return todoParam;
}
if (request.getUnresolved()) {
todoParam.setCurrentPlatform(platformName);
todoParam.setPlatformLastStatus(bugCommonService.getPlatformLastStepStatus(request.getProjectId()));
}
if (request.getAssignedToMe()) {
todoParam.setPlatformUser(bugCommonService.getPlatformHandlerUser(request.getProjectId(), currentUserId, currentOrgId));
}
} catch (Exception e) {
// 设置平台参数异常时, 无法正常过滤平台非结束的缺陷
LogUtils.error(e.getMessage());
return todoParam;
}
return todoParam;
}
} }

View File

@ -189,6 +189,7 @@ public class BugControllerTests extends BaseTest {
bugPageRequest.setPageSize(10); bugPageRequest.setPageSize(10);
bugPageRequest.setKeyword("default-x"); bugPageRequest.setKeyword("default-x");
bugPageRequest.setProjectId("default-project-for-bug"); bugPageRequest.setProjectId("default-project-for-bug");
bugPageRequest.setCreateByMe(true);
MvcResult mvcResult = this.requestPostWithOkAndReturn(BUG_PAGE, bugPageRequest); MvcResult mvcResult = this.requestPostWithOkAndReturn(BUG_PAGE, bugPageRequest);
// 获取返回值 // 获取返回值
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
@ -608,6 +609,8 @@ public class BugControllerTests extends BaseTest {
BugPageRequest bugPageRequest = new BugPageRequest(); BugPageRequest bugPageRequest = new BugPageRequest();
bugPageRequest.setCurrent(1); bugPageRequest.setCurrent(1);
bugPageRequest.setPageSize(10); bugPageRequest.setPageSize(10);
bugPageRequest.setUnresolved(true);
bugPageRequest.setAssignedToMe(true);
bugPageRequest.setProjectId("default-project-for-bug"); bugPageRequest.setProjectId("default-project-for-bug");
this.requestPostWithOk(BUG_PAGE, bugPageRequest); this.requestPostWithOk(BUG_PAGE, bugPageRequest);

View File

@ -3,9 +3,7 @@ package io.metersphere.dashboard.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.bug.dto.request.BugPageRequest; import io.metersphere.bug.dto.request.BugPageRequest;
import io.metersphere.bug.dto.request.BugTodoRequest;
import io.metersphere.bug.dto.response.BugDTO; import io.metersphere.bug.dto.response.BugDTO;
import io.metersphere.bug.enums.BugPlatform;
import io.metersphere.bug.service.BugCommonService; import io.metersphere.bug.service.BugCommonService;
import io.metersphere.bug.service.BugService; import io.metersphere.bug.service.BugService;
import io.metersphere.functional.dto.CaseReviewDTO; import io.metersphere.functional.dto.CaseReviewDTO;
@ -17,7 +15,6 @@ import io.metersphere.plan.dto.response.TestPlanStatisticsResponse;
import io.metersphere.plan.service.TestPlanManagementService; import io.metersphere.plan.service.TestPlanManagementService;
import io.metersphere.plan.service.TestPlanStatisticsService; import io.metersphere.plan.service.TestPlanStatisticsService;
import io.metersphere.project.service.ProjectApplicationService; import io.metersphere.project.service.ProjectApplicationService;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.security.CheckOwner; import io.metersphere.system.security.CheckOwner;
import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.Pager;
@ -96,36 +93,11 @@ public class ToDoController {
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public Pager<List<BugDTO>> bugPage(@Validated @RequestBody BugPageRequest request) { public Pager<List<BugDTO>> bugPage(@Validated @RequestBody BugPageRequest request) {
request.setUseTrash(false); request.setUseTrash(false);
request.setTodoParam(buildBugToDoParam(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId())); request.setAssignedToMe(true);
request.setUnresolved(true);
request.setTodoParam(bugService.buildBugToDoParam(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId()));
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "b.pos desc"); StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "b.pos desc");
return PageUtils.setPageInfo(page, bugService.list(request)); return PageUtils.setPageInfo(page, bugService.list(request));
} }
/**
* 设置缺陷待办参数
* @param request 请求参数
* @param currentUserId 当前用户ID
* @param currentOrgId 当前组织ID
* @return 待办参数
*/
private BugTodoRequest buildBugToDoParam(BugPageRequest request, String currentUserId, String currentOrgId) {
List<String> msLastStepStatusIds = bugCommonService.getLocalLastStepStatus(request.getProjectId());
BugTodoRequest todoParam = BugTodoRequest.builder().msUserId(currentUserId).msLastStepStatus(msLastStepStatusIds).build();
try {
// 设置待办的平台参数
String platformName = projectApplicationService.getPlatformName(request.getProjectId());
if (StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
return todoParam;
}
todoParam.setCurrentPlatform(platformName);
todoParam.setPlatformLastStatus(bugCommonService.getPlatformLastStepStatus(request.getProjectId()));
todoParam.setPlatformUser(bugCommonService.getPlatformHandlerUser(request.getProjectId(), currentUserId, currentOrgId));
} catch (Exception e) {
// 设置平台参数异常时, 无法正常过滤平台非结束的缺陷
LogUtils.error(e.getMessage());
return todoParam;
}
return todoParam;
}
} }