refactor(功能用例): 去掉评审详情废弃参数

--task=1016128 --user=陈建星 高级搜索-视图增删改查-后端 https://www.tapd.cn/55049933/s/1573254
This commit is contained in:
AgAngle 2024-09-09 13:38:37 +08:00 committed by Craftsman
parent c6c47cff95
commit d5c739a4da
8 changed files with 30 additions and 58 deletions

View File

@ -58,17 +58,13 @@ public class CaseReviewFunctionalCaseController {
@Operation(summary = "用例管理-用例评审-评审列表-评审详情-已关联用例列表") @Operation(summary = "用例管理-用例评审-评审列表-评审详情-已关联用例列表")
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ) @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ)
public Pager<List<ReviewFunctionalCaseDTO>> page(@Validated @RequestBody ReviewFunctionalCasePageRequest request) { public Pager<List<ReviewFunctionalCaseDTO>> page(@Validated @RequestBody ReviewFunctionalCasePageRequest request) {
String userId = StringUtils.EMPTY;
if (request.isViewFlag()) {
userId = SessionUtils.getUserId();
}
String viewStatusUserId = StringUtils.EMPTY; String viewStatusUserId = StringUtils.EMPTY;
if (request.isViewStatusFlag()) { if (request.isViewStatusFlag()) {
viewStatusUserId = SessionUtils.getUserId(); viewStatusUserId = SessionUtils.getUserId();
} }
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize()); Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
return PageUtils.setPageInfo(page, caseReviewFunctionalCaseService.page(request, false, userId, viewStatusUserId)); return PageUtils.setPageInfo(page, caseReviewFunctionalCaseService.page(request, false, viewStatusUserId));
} }
@ -86,11 +82,7 @@ public class CaseReviewFunctionalCaseController {
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ) @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ)
@CheckOwner(resourceId = "#request.getReviewId()", resourceType = "case_review") @CheckOwner(resourceId = "#request.getReviewId()", resourceType = "case_review")
public Map<String, Long> moduleCount(@Validated @RequestBody ReviewFunctionalCasePageRequest request) { public Map<String, Long> moduleCount(@Validated @RequestBody ReviewFunctionalCasePageRequest request) {
String userId = StringUtils.EMPTY; return caseReviewFunctionalCaseService.moduleCount(request, false);
if (request.isViewFlag()) {
userId = SessionUtils.getUserId();
}
return caseReviewFunctionalCaseService.moduleCount(request, false, userId);
} }

View File

@ -24,7 +24,7 @@ public interface ExtCaseReviewFunctionalCaseMapper {
List<String> getCaseIdsByReviewId(@Param("reviewId") String reviewId); List<String> getCaseIdsByReviewId(@Param("reviewId") String reviewId);
@BaseConditionFilter @BaseConditionFilter
List<ReviewFunctionalCaseDTO> page(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId, @Param("sort") String sort); List<ReviewFunctionalCaseDTO> page(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("sort") String sort);
Long getPos(@Param("reviewId") String reviewId); Long getPos(@Param("reviewId") String reviewId);
@ -33,10 +33,10 @@ public interface ExtCaseReviewFunctionalCaseMapper {
Long getLastPos(@Param("reviewId") String reviewId, @Param("basePos") Long basePos); Long getLastPos(@Param("reviewId") String reviewId, @Param("basePos") Long basePos);
@BaseConditionFilter @BaseConditionFilter
List<String> getIds(@Param("request") BaseReviewCaseBatchRequest request, @Param("userId") String userId, @Param("deleted") boolean deleted); List<String> getIds(@Param("request") BaseReviewCaseBatchRequest request, @Param("deleted") boolean deleted);
@BaseConditionFilter @BaseConditionFilter
List<CaseReviewFunctionalCase> getListByRequest(@Param("request") BaseReviewCaseBatchRequest request, @Param("userId") String userId, @Param("deleted") boolean deleted); List<CaseReviewFunctionalCase> getListByRequest(@Param("request") BaseReviewCaseBatchRequest request, @Param("deleted") boolean deleted);
List<CaseReviewFunctionalCase> getList(@Param("reviewId") String reviewId, @Param("reviewIds") List<String> reviewIds, @Param("deleted") boolean deleted); List<CaseReviewFunctionalCase> getList(@Param("reviewId") String reviewId, @Param("reviewIds") List<String> reviewIds, @Param("deleted") boolean deleted);
@ -46,9 +46,9 @@ public interface ExtCaseReviewFunctionalCaseMapper {
List<CaseReviewFunctionalCase> getCaseIdsByIds(@Param("ids") List<String> ids); List<CaseReviewFunctionalCase> getCaseIdsByIds(@Param("ids") List<String> ids);
@BaseConditionFilter @BaseConditionFilter
List<FunctionalCaseModuleCountDTO> countModuleIdByRequest(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId); List<FunctionalCaseModuleCountDTO> countModuleIdByRequest(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted);
@BaseConditionFilter @BaseConditionFilter
long caseCount(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId); long caseCount(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted);
} }

View File

@ -52,10 +52,6 @@
WHERE WHERE
review_id = #{request.reviewId} review_id = #{request.reviewId}
AND functional_case.deleted = #{deleted} AND functional_case.deleted = #{deleted}
<if test="userId != null and userId != ''">
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id =
#{request.reviewId} and crfcu.user_id = #{userId})
</if>
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
order by order by
<if test="sort != null and sort != ''"> <if test="sort != null and sort != ''">
@ -142,9 +138,17 @@
<trim prefix="AND" suffixOverrides="AND|OR"> <trim prefix="AND" suffixOverrides="AND|OR">
<if test="${combineSearch} != null"> <if test="${combineSearch} != null">
<foreach collection="${combineSearch}.userViewConditions" item="condition"> <foreach collection="${combineSearch}.userViewConditions" item="condition">
<if test="condition.name == 'follower'"> <if test="condition.name == 'createUser'">
functional_case.id in ( <include refid="io.metersphere.system.mapper.BaseMapper.condition">
select case_id from functional_case_follower where <property name="condition" value="condition"/>
<property name="column" value="functional_case.create_user"/>
</include>
</if>
<if test="condition.name == 'reviewUser'">
crfc.case_id in (
select case_id from case_review_functional_case_user
where review_id = #{request.reviewId}
and
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/> <property name="condition" value="condition"/>
<property name="column" value="user_id"/> <property name="column" value="user_id"/>
@ -210,10 +214,6 @@
WHERE WHERE
review_id = #{request.reviewId} review_id = #{request.reviewId}
AND functional_case.deleted = #{deleted} AND functional_case.deleted = #{deleted}
<if test="userId != null and userId != ''">
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id =
#{request.reviewId} and crfcu.user_id = #{userId})
</if>
<include refid="queryWhereConditionByBaseQueryRequest"/> <include refid="queryWhereConditionByBaseQueryRequest"/>
</select> </select>
@ -226,10 +226,6 @@
WHERE WHERE
review_id = #{request.reviewId} review_id = #{request.reviewId}
AND functional_case.deleted = #{deleted} AND functional_case.deleted = #{deleted}
<if test="userId != null and userId != ''">
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id =
#{request.reviewId} and crfcu.user_id = #{userId})
</if>
<include refid="queryWhereConditionByBaseQueryRequest"/> <include refid="queryWhereConditionByBaseQueryRequest"/>
<if test="request.excludeIds != null and request.excludeIds.size() > 0"> <if test="request.excludeIds != null and request.excludeIds.size() > 0">
and crfc.id not in and crfc.id not in
@ -343,10 +339,6 @@
LEFT JOIN project ON functional_case.project_id = project.id LEFT JOIN project ON functional_case.project_id = project.id
WHERE crfc.review_id = #{request.reviewId} WHERE crfc.review_id = #{request.reviewId}
AND functional_case.deleted = #{deleted} AND functional_case.deleted = #{deleted}
<if test="userId != null and userId != ''">
AND crfc.case_id in (select crfcu.case_id from case_review_functional_case_user crfcu where crfcu.review_id
= #{request.reviewId} and crfcu.user_id = #{userId})
</if>
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
GROUP BY module_id GROUP BY module_id
</select> </select>
@ -357,10 +349,6 @@
FROM case_review_functional_case crfc LEFT JOIN functional_case ON crfc.case_id = functional_case.id FROM case_review_functional_case crfc LEFT JOIN functional_case ON crfc.case_id = functional_case.id
WHERE crfc.review_id = #{request.reviewId} WHERE crfc.review_id = #{request.reviewId}
AND functional_case.deleted = #{deleted} AND functional_case.deleted = #{deleted}
<if test="userId != null and userId != ''">
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id =
#{request.reviewId} and crfcu.user_id = #{userId})
</if>
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
</select> </select>

View File

@ -22,10 +22,6 @@ public class BaseReviewCaseBatchRequest extends TableBatchProcessDTO implements
@NotBlank(message = "{case_review_user.review_id.not_blank}") @NotBlank(message = "{case_review_user.review_id.not_blank}")
private String reviewId; private String reviewId;
@Schema(description = "userId用来判断是否只看我的")
private String userId;
@Schema(description = "模块id") @Schema(description = "模块id")
private List<String> moduleIds; private List<String> moduleIds;
} }

View File

@ -25,9 +25,6 @@ public class ReviewFunctionalCasePageRequest extends BasePageRequest implements
@NotBlank(message = "{case_review.project_id.not_blank}") @NotBlank(message = "{case_review.project_id.not_blank}")
private String projectId; private String projectId;
@Schema(description = "是否只看我的", requiredMode = Schema.RequiredMode.REQUIRED)
private boolean viewFlag;
@Schema(description = "模块id") @Schema(description = "模块id")
private List<String> moduleIds; private List<String> moduleIds;

View File

@ -133,8 +133,8 @@ public class CaseReviewFunctionalCaseService {
* @param deleted deleted * @param deleted deleted
* @return ReviewFunctionalCaseDTO * @return ReviewFunctionalCaseDTO
*/ */
public List<ReviewFunctionalCaseDTO> page(ReviewFunctionalCasePageRequest request, boolean deleted, String userId, String viewStatusUserId) { public List<ReviewFunctionalCaseDTO> page(ReviewFunctionalCasePageRequest request, boolean deleted, String viewStatusUserId) {
List<ReviewFunctionalCaseDTO> list = extCaseReviewFunctionalCaseMapper.page(request, deleted, userId, request.getSortString()); List<ReviewFunctionalCaseDTO> list = extCaseReviewFunctionalCaseMapper.page(request, deleted, request.getSortString());
return doHandleDTO(list, request, viewStatusUserId); return doHandleDTO(list, request, viewStatusUserId);
} }
@ -252,7 +252,7 @@ public class CaseReviewFunctionalCaseService {
public List<String> doSelectIds(BaseReviewCaseBatchRequest request) { public List<String> doSelectIds(BaseReviewCaseBatchRequest request) {
if (request.isSelectAll()) { if (request.isSelectAll()) {
List<String> ids = extCaseReviewFunctionalCaseMapper.getIds(request, request.getUserId(), false); List<String> ids = extCaseReviewFunctionalCaseMapper.getIds(request, false);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) { if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
ids.removeAll(request.getExcludeIds()); ids.removeAll(request.getExcludeIds());
} }
@ -264,7 +264,7 @@ public class CaseReviewFunctionalCaseService {
public List<CaseReviewFunctionalCase> doCaseReviewFunctionalCases(BaseReviewCaseBatchRequest request) { public List<CaseReviewFunctionalCase> doCaseReviewFunctionalCases(BaseReviewCaseBatchRequest request) {
if (request.isSelectAll()) { if (request.isSelectAll()) {
return extCaseReviewFunctionalCaseMapper.getListByRequest(request, request.getUserId(), false); return extCaseReviewFunctionalCaseMapper.getListByRequest(request, false);
} else { } else {
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
caseReviewFunctionalCaseExample.createCriteria().andIdIn(request.getSelectIds()); caseReviewFunctionalCaseExample.createCriteria().andIdIn(request.getSelectIds());
@ -856,10 +856,10 @@ public class CaseReviewFunctionalCaseService {
return returnList; return returnList;
} }
public Map<String, Long> moduleCount(ReviewFunctionalCasePageRequest request, boolean deleted, String userId) { public Map<String, Long> moduleCount(ReviewFunctionalCasePageRequest request, boolean deleted) {
//查出每个模块节点下的资源数量 不需要按照模块进行筛选 //查出每个模块节点下的资源数量 不需要按照模块进行筛选
request.setModuleIds(null); request.setModuleIds(null);
List<FunctionalCaseModuleCountDTO> projectModuleCountDTOList = extCaseReviewFunctionalCaseMapper.countModuleIdByRequest(request, deleted, userId); List<FunctionalCaseModuleCountDTO> projectModuleCountDTOList = extCaseReviewFunctionalCaseMapper.countModuleIdByRequest(request, deleted);
Map<String, List<FunctionalCaseModuleCountDTO>> projectCountMap = projectModuleCountDTOList.stream().collect(Collectors.groupingBy(FunctionalCaseModuleCountDTO::getProjectId)); Map<String, List<FunctionalCaseModuleCountDTO>> projectCountMap = projectModuleCountDTOList.stream().collect(Collectors.groupingBy(FunctionalCaseModuleCountDTO::getProjectId));
Map<String, Long> projectModuleCountMap = new HashMap<>(); Map<String, Long> projectModuleCountMap = new HashMap<>();
projectCountMap.forEach((projectId, moduleCountDTOList) -> { projectCountMap.forEach((projectId, moduleCountDTOList) -> {
@ -879,7 +879,7 @@ public class CaseReviewFunctionalCaseService {
projectModuleCountMap.put(projectId, (long) sum); projectModuleCountMap.put(projectId, (long) sum);
}); });
//查出全部用例数量 //查出全部用例数量
long allCount = extCaseReviewFunctionalCaseMapper.caseCount(request, deleted, userId); long allCount = extCaseReviewFunctionalCaseMapper.caseCount(request, deleted);
projectModuleCountMap.put(CASE_MODULE_COUNT_ALL, allCount); projectModuleCountMap.put(CASE_MODULE_COUNT_ALL, allCount);
return projectModuleCountMap; return projectModuleCountMap;
} }

View File

@ -122,7 +122,6 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
request.setProjectId("wx_test_project"); request.setProjectId("wx_test_project");
request.setReviewId("wx_review_id_5"); request.setReviewId("wx_review_id_5");
request.setViewFlag(true);
request.setViewStatusFlag(true); request.setViewStatusFlag(true);
this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request); this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request);
request.setReviewId("wx_review_id_1"); request.setReviewId("wx_review_id_1");
@ -130,11 +129,9 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
request.setReviewId("wx_review_id_1"); request.setReviewId("wx_review_id_1");
request.setCombineSearch(getCustomCombineSearch()); request.setCombineSearch(getCustomCombineSearch());
request.setViewFlag(true);
request.setViewStatusFlag(true); request.setViewStatusFlag(true);
this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request); this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request);
this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_MODULE_COUNT, request); this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_MODULE_COUNT, request);
request.setViewFlag(false);
request.setViewStatusFlag(false); request.setViewStatusFlag(false);
this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request); this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request);
@ -654,7 +651,6 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
request.setReviewId("wx_review_id_1"); request.setReviewId("wx_review_id_1");
request.setCurrent(1); request.setCurrent(1);
request.setPageSize(10); request.setPageSize(10);
request.setViewFlag(false);
request.setProjectId("wx_test_project"); request.setProjectId("wx_test_project");
MvcResult moduleCountMvcResult = this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_MODULE_COUNT, request); MvcResult moduleCountMvcResult = this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_MODULE_COUNT, request);
Map<String, Integer> moduleCount = JSON.parseObject(JSON.toJSONString( Map<String, Integer> moduleCount = JSON.parseObject(JSON.toJSONString(

View File

@ -3,6 +3,7 @@ import io.metersphere.sdk.dto.BaseCondition;
import io.metersphere.sdk.dto.CombineCondition; import io.metersphere.sdk.dto.CombineCondition;
import io.metersphere.sdk.dto.CombineSearch; import io.metersphere.sdk.dto.CombineSearch;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.constants.InternalUserView; import io.metersphere.system.constants.InternalUserView;
import io.metersphere.system.dto.UserViewDTO; import io.metersphere.system.dto.UserViewDTO;
import io.metersphere.system.dto.sdk.*; import io.metersphere.system.dto.sdk.*;
@ -77,8 +78,10 @@ public class BaseConditionFilterAspect {
for (InternalUserView internalUserView : InternalUserView.values()) { for (InternalUserView internalUserView : InternalUserView.values()) {
UserViewDTO userView = internalUserView.getUserView(); UserViewDTO userView = internalUserView.getUserView();
if (StringUtils.equals(userView.getId(), viewId)) { if (StringUtils.equals(userView.getId(), viewId)) {
replaceCurrentUser(userView.getConditions()); // 复制视图查询条件
dbCombineSearch.setUserViewConditions(userView.getConditions()); List<CombineCondition> conditions = JSON.parseArray(JSON.toJSONString(userView.getConditions()), CombineCondition.class);
replaceCurrentUser(conditions);
dbCombineSearch.setUserViewConditions(conditions);
} }
} }
} }