feat(用例评审): 用例评审详情列表-批量修改评审人

This commit is contained in:
WangXu10 2023-12-26 17:19:13 +08:00 committed by Craftsman
parent e75b42a669
commit d88db61634
16 changed files with 296 additions and 19 deletions

View File

@ -10,6 +10,7 @@ public interface CaseEvent {
String DELETE_TRASH_FUNCTIONAL_CASE = "deleteTrashFunctionalCase";
String RECOVER_FUNCTIONAL_CASE = "recoverFunctionalCase";
String REVIEW_FUNCTIONAL_CASE = "reviewFunctionalCase";
String BATCH_UPDATE_REVIEWER = "batchUpdateReviewer";
}
interface Param {

View File

@ -5,10 +5,7 @@ import com.alibaba.excel.util.StringUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
import io.metersphere.functional.request.CaseReviewFunctionalCasePosRequest;
import io.metersphere.functional.request.BatchReviewFunctionalCaseRequest;
import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
import io.metersphere.functional.request.*;
import io.metersphere.functional.service.CaseReviewFunctionalCaseService;
import io.metersphere.functional.service.CaseReviewLogService;
import io.metersphere.sdk.constants.PermissionConstants;
@ -83,4 +80,11 @@ public class CaseReviewFunctionalCaseController {
caseReviewFunctionalCaseService.batchReview(request, SessionUtils.getUserId());
}
@PostMapping("/batch/edit/reviewers")
@Operation(summary = "用例管理-功能用例-评审列表-评审详情-列表-批量修改评审人")
@CheckOwner(resourceId = "#request.getReviewId()", resourceType = "case_review")
public void batchEditReviewUser(@Validated @RequestBody BatchEditReviewerRequest request) {
caseReviewFunctionalCaseService.batchEditReviewUser(request, SessionUtils.getUserId());
}
}

View File

@ -39,5 +39,5 @@ public interface ExtCaseReviewFunctionalCaseMapper {
List<CaseReviewFunctionalCase> getListExcludes(@Param("reviewIds")List<String> reviewIds, @Param("caseIds") List<String> caseIds, @Param("deleted") boolean deleted);
List<CaseReviewFunctionalCase> getCaseIdsByIds(@Param("ids") List<String> ids);
}

View File

@ -379,4 +379,10 @@
order by `pos` desc limit 1;
</select>
<select id="getCaseIdsByIds" resultType="io.metersphere.functional.domain.CaseReviewFunctionalCase">
select id, case_id as caseId, status from case_review_functional_case where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
</mapper>

View File

@ -10,4 +10,6 @@ import java.util.List;
*/
public interface ExtCaseReviewFunctionalCaseUserMapper {
List<ReviewsDTO> selectReviewers(@Param("ids") List<String> ids, @Param("reviewId") String reviewId);
void deleteByCaseIds(@Param("ids") List<String> ids, @Param("reviewId") String reviewId);
}

View File

@ -20,4 +20,12 @@
crfcu.case_id
</select>
<delete id="deleteByCaseIds">
DELETE FROM case_review_functional_case_user WHERE
review_id = #{reviewId} AND case_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -33,4 +33,5 @@ public interface ExtCaseReviewMapper {
long caseCount(@Param("request") CaseReviewPageRequest request);
String getReviewPassRule(@Param("id") String id);
}

View File

@ -439,4 +439,7 @@
1 = 1
</select>
<select id="getReviewPassRule" resultType="java.lang.String">
select review_pass_rule from case_review where id = #{id}
</select>
</mapper>

View File

@ -51,11 +51,31 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
case CaseEvent.Event.DELETE_TRASH_FUNCTIONAL_CASE -> updateCaseReviewByDeleteTrashFunctionalCase(paramMap);
case CaseEvent.Event.RECOVER_FUNCTIONAL_CASE -> updateCaseReviewByRecoverFunctionalCase(paramMap);
case CaseEvent.Event.REVIEW_FUNCTIONAL_CASE -> updateCaseReviewByReviewFunctionalCase(paramMap);
case CaseEvent.Event.BATCH_UPDATE_REVIEWER -> updateCaseReviewByBatchUpdateReviewer(paramMap);
default -> LogUtils.info("CaseProvider: " + event);
}
}
/**
* 批量修改评审人 重新计算通过率和用例数
*
* @param paramMap paramMap
*/
private void updateCaseReviewByBatchUpdateReviewer(Map<String, Object> paramMap) {
try {
String reviewId = paramMap.get(CaseEvent.Param.REVIEW_ID).toString();
int caseCount = Integer.parseInt(paramMap.get(CaseEvent.Param.CASE_COUNT).toString());
int passCount = Integer.parseInt(paramMap.get(CaseEvent.Param.PASS_COUNT).toString());
int unCompletedCaseCount = Integer.parseInt(paramMap.get(CaseEvent.Param.UN_COMPLETED_COUNT).toString());
updateCaseReview(reviewId, caseCount, passCount, unCompletedCaseCount, paramMap.get(CaseEvent.Param.USER_ID).toString());
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.BATCH_UPDATE_REVIEWER + "事件更新失败", e.getMessage());
}
}
/**
* 1.关联用例单独/批量重新计算用例评审的通过率和用例数
*/

View File

@ -0,0 +1,20 @@
package io.metersphere.functional.request;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* @author wx
*/
@Data
public class BatchEditReviewerRequest extends BaseReviewCaseBatchRequest {
@Schema(description = "评审人id列表", requiredMode = Schema.RequiredMode.REQUIRED)
private List<String> reviewerId;
@Schema(description = "是否追加", requiredMode = Schema.RequiredMode.REQUIRED)
private boolean append;
}

View File

@ -387,4 +387,142 @@ public class CaseReviewFunctionalCaseService {
caseReviewHistory.setCreateTime(System.currentTimeMillis());
return caseReviewHistory;
}
public void batchEditReviewUser(BatchEditReviewerRequest request, String userId) {
List<String> ids = doSelectIds(request);
if (CollectionUtils.isNotEmpty(ids)) {
String reviewPassRule = caseReviewService.getReviewPassRule(request.getReviewId());
//评审人处理
List<CaseReviewFunctionalCase> cases = extCaseReviewFunctionalCaseMapper.getCaseIdsByIds(ids);
handleReviewers(request, cases, reviewPassRule, userId);
}
}
private void handleReviewers(BatchEditReviewerRequest request, List<CaseReviewFunctionalCase> cases, String reviewPassRule, String userId) {
List<String> caseIds = cases.stream().map(CaseReviewFunctionalCase::getCaseId).toList();
CaseReviewFunctionalCaseUserExample example = new CaseReviewFunctionalCaseUserExample();
example.createCriteria().andCaseIdIn(caseIds).andReviewIdEqualTo(request.getReviewId());
List<CaseReviewFunctionalCaseUser> oldReviewUsers = caseReviewFunctionalCaseUserMapper.selectByExample(example);
Map<String, List<CaseReviewFunctionalCaseUser>> oldReviewUserMap = oldReviewUsers.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCaseUser::getCaseId));
//处理评审人数据
handleReviewCaseUsers(request, caseIds, oldReviewUserMap);
if (CaseReviewPassRule.MULTIPLE.name().equals(reviewPassRule)) {
//如果是多人评审 需要重新评估用例评审状态
List<CaseReviewFunctionalCaseUser> newReviewers = caseReviewFunctionalCaseUserMapper.selectByExample(example);
Map<String, List<CaseReviewFunctionalCaseUser>> newReviewersMap = newReviewers.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCaseUser::getCaseId));
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
caseReviewHistoryExample.createCriteria().andCaseIdIn(caseIds).andReviewIdEqualTo(request.getReviewId()).andDeletedEqualTo(false);
List<CaseReviewHistory> caseReviewHistories = caseReviewHistoryMapper.selectByExample(caseReviewHistoryExample);
Map<String, List<CaseReviewHistory>> caseHistoryMap = caseReviewHistories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCaseId, Collectors.toList()));
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
FunctionalCaseMapper functionalCaseMapper = sqlSession.getMapper(FunctionalCaseMapper.class);
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
cases.forEach(caseReview -> {
String status = multipleReview(caseReview, caseHistoryMap.get(caseReview.getCaseId()), newReviewersMap.get(caseReview.getCaseId()), oldReviewUserMap.get(caseReview.getCaseId()));
caseReview.setStatus(status);
caseReviewFunctionalCaseMapper.updateByPrimaryKeySelective(caseReview);
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setId(caseReview.getCaseId());
functionalCase.setReviewStatus(caseReview.getStatus());
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
});
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
Map<String, Object> param = new HashMap<>();
List<CaseReviewFunctionalCase> list = extCaseReviewFunctionalCaseMapper.getList(request.getReviewId(), null, false);
List<CaseReviewFunctionalCase> passList = list.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getStatus(), FunctionalCaseReviewStatus.PASS.toString())).toList();
List<CaseReviewFunctionalCase> unCompletedCaseList = list.stream().filter(t -> StringUtils.equalsAnyIgnoreCase(t.getStatus(), FunctionalCaseReviewStatus.UN_REVIEWED.toString(), FunctionalCaseReviewStatus.UNDER_REVIEWED.toString(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())).toList();
param.put(CaseEvent.Param.REVIEW_ID, request.getReviewId());
param.put(CaseEvent.Param.USER_ID, userId);
param.put(CaseEvent.Param.CASE_COUNT, list.size());
param.put(CaseEvent.Param.PASS_COUNT, passList.size());
param.put(CaseEvent.Param.UN_COMPLETED_COUNT, unCompletedCaseList.size());
param.put(CaseEvent.Param.EVENT_NAME, CaseEvent.Event.BATCH_UPDATE_REVIEWER);
provider.updateCaseReview(param);
}
}
private String multipleReview(CaseReviewFunctionalCase caseReviewFunctionalCase, List<CaseReviewHistory> reviewHistories, List<CaseReviewFunctionalCaseUser> newReviewers, List<CaseReviewFunctionalCaseUser> oldReviewers) {
if (CollectionUtils.isNotEmpty(reviewHistories)) {
List<String> historyUsers = reviewHistories.stream().map(CaseReviewHistory::getCreateUser).toList();
List<String> newUsers = newReviewers.stream().map(CaseReviewFunctionalCaseUser::getUserId).toList();
if (CollectionUtils.isEmpty(oldReviewers)) {
oldReviewers = new ArrayList<>();
}
List<String> oldUsers = oldReviewers.stream().map(CaseReviewFunctionalCaseUser::getUserId).toList();
if (CollectionUtils.isEqualCollection(newUsers, oldUsers)) {
return caseReviewFunctionalCase.getStatus();
}
Collection intersection = CollectionUtils.intersection(historyUsers, newUsers);
if (CollectionUtils.isNotEmpty(intersection)) {
//存在已经评审的人 状态列表
List<String> statusList = reviewHistories.stream().filter(item -> intersection.contains(item.getCreateUser())).map(CaseReviewHistory::getStatus).toList();
if (statusList.contains(FunctionalCaseReviewStatus.UN_PASS.name())) {
return FunctionalCaseReviewStatus.UN_PASS.name();
}
long count = statusList.stream().filter(item -> StringUtils.equalsIgnoreCase(FunctionalCaseReviewStatus.PASS.name(), item)).count();
if (count == statusList.size() && newUsers.size() <= oldUsers.size()) {
return FunctionalCaseReviewStatus.PASS.name();
} else {
return FunctionalCaseReviewStatus.UNDER_REVIEWED.name();
}
} else {
return FunctionalCaseReviewStatus.UN_REVIEWED.name();
}
} else {
return FunctionalCaseReviewStatus.UN_REVIEWED.name();
}
}
private void handleReviewCaseUsers(BatchEditReviewerRequest request, List<String> caseIds, Map<String, List<CaseReviewFunctionalCaseUser>> listMap) {
if (request.isAppend()) {
//追加评审人
List<CaseReviewFunctionalCaseUser> list = new ArrayList<>();
caseIds.forEach(caseId -> {
//原评审人
List<CaseReviewFunctionalCaseUser> users = listMap.get(caseId);
//新评审人
List<String> reviewerIds = request.getReviewerId();
if (CollectionUtils.isNotEmpty(users)) {
List<String> userIds = users.stream().map(CaseReviewFunctionalCaseUser::getUserId).toList();
reviewerIds.removeAll(userIds);
}
reviewerIds.forEach(reviewer -> {
CaseReviewFunctionalCaseUser caseUser = new CaseReviewFunctionalCaseUser();
caseUser.setReviewId(request.getReviewId());
caseUser.setCaseId(caseId);
caseUser.setUserId(reviewer);
list.add(caseUser);
});
});
caseReviewFunctionalCaseUserMapper.batchInsert(list);
} else {
//更新评审人
extCaseReviewFunctionalCaseUserMapper.deleteByCaseIds(caseIds, request.getReviewId());
List<String> reviewerIds = request.getReviewerId();
List<CaseReviewFunctionalCaseUser> list = new ArrayList<>();
caseIds.forEach(caseId -> {
reviewerIds.forEach(reviewer -> {
CaseReviewFunctionalCaseUser caseUser = new CaseReviewFunctionalCaseUser();
caseUser.setReviewId(request.getReviewId());
caseUser.setCaseId(caseId);
caseUser.setUserId(reviewer);
list.add(caseUser);
});
});
caseReviewFunctionalCaseUserMapper.batchInsert(list);
}
}
}

View File

@ -579,4 +579,8 @@ public class CaseReviewService {
moduleCountMap.put(CASE_MODULE_COUNT_ALL, allCount);
return moduleCountMap;
}
public String getReviewPassRule(String id) {
return extCaseReviewMapper.getReviewPassRule(id);
}
}

View File

@ -41,6 +41,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
public static final String FUNCTIONAL_CASE_ADD_URL = "/functional/case/add";
public static final String REVIEW_FUNCTIONAL_CASE_POS = "/case/review/detail/edit/pos";
public static final String BATCH_EDIT_REVIEWERS = "/case/review/detail/batch/edit/reviewers";
public static final String REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW = "/case/review/detail/batch/review";
@ -205,25 +206,25 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
request.setStatus(FunctionalCaseReviewStatus.UN_PASS.toString());
request.setSelectAll(true);
List<String>excludeIds = new ArrayList<>();
List<String> excludeIds = new ArrayList<>();
excludeIds.add("gyq_test_4");
request.setExcludeIds(excludeIds);
request.setContent("测试批量评审不通过");
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
CaseReviewFunctionalCase caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_4");
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(),FunctionalCaseReviewStatus.UNDER_REVIEWED.toString()));
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(), FunctionalCaseReviewStatus.UNDER_REVIEWED.toString()));
request = new BatchReviewFunctionalCaseRequest();
request.setReviewId("wx_review_id_1");
request.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
request.setStatus(FunctionalCaseReviewStatus.PASS.toString());
request.setSelectAll(false);
List<String>ids = new ArrayList<>();
List<String> ids = new ArrayList<>();
ids.add("gyq_test_3");
request.setSelectIds(ids);
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_3");
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(),FunctionalCaseReviewStatus.PASS.toString()));
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(), FunctionalCaseReviewStatus.PASS.toString()));
request = new BatchReviewFunctionalCaseRequest();
request.setReviewId("wx_review_id_1");
@ -266,4 +267,36 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
return functionalCaseAddRequest;
}
@Test
@Order(9)
public void testBatchEditReviewers() throws Exception {
BatchEditReviewerRequest request = new BatchEditReviewerRequest();
//更新评审人
request.setAppend(false);
request.setReviewerId(List.of("wx1"));
request.setReviewId("wx_review_id_1");
//增加覆盖率
this.requestPost(BATCH_EDIT_REVIEWERS, request);
//测试选中id进行更新 单人评审情况下
request.setSelectIds(List.of("wx_test_3", "wx_test_4"));
this.requestPostWithOkAndReturn(BATCH_EDIT_REVIEWERS, request);
//多人评审情况下
request.setReviewId("wx_review_id_3");
request.setSelectIds(List.of("wx_test_5", "wx_test_6"));
this.requestPostWithOkAndReturn(BATCH_EDIT_REVIEWERS, request);
//多人 更新不变
request.setReviewId("wx_review_id_4");
request.setReviewerId(List.of("admin"));
request.setSelectIds(List.of("wx_test_8", "wx_test_9", "wx_test_10"));
this.requestPostWithOkAndReturn(BATCH_EDIT_REVIEWERS, request);
//追加评审人
request.setAppend(true);
request.setReviewId("wx_review_id_4");
request.setReviewerId(List.of("wx11"));
request.setSelectIds(List.of("wx_test_10"));
this.requestPostWithOkAndReturn(BATCH_EDIT_REVIEWERS, request);
}
}

View File

@ -10,10 +10,19 @@ VALUES ('gyq_case_id_3', 102, 'TEST_MODULE_ID', 'wx_test_project', '100001', '
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('gyq_case_id_4', 102, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_4', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('wx_case_id_3', 104, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'TEST_REF_ID', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('wx_case_id_4', 104, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'TEST_REF_ID', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('wx_case_id_1', 'STEP', '1111', '', '', 'TEST');
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('wx_case_id_2', 'STEP', '1111', '', '', '1111');
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('gyq_case_id_3', 'STEP', '1111', '', '', '1111');
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('gyq_case_id_4', 'STEP', '1111', '', '', '1111');
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('wx_case_id_3', 'STEP', '1111', '', '', '1111');
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('wx_case_id_4', 'STEP', '1111', '', '', '1111');
@ -25,20 +34,46 @@ INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('wx_c
INSERT INTO case_review(id, num, name, module_id, project_id, status, review_pass_rule, pos, start_time, end_time, case_count, pass_rate, tags, description, create_time, create_user, update_time, update_user)
VALUES ('wx_review_id_1',10001,'wx1', 'wx_module_1', 'wx_test_project', 'COMPLETED', 'SINGLE', 001, null, null, 1,100.00,null,null,1698058347559,'admin',1698058347559,'admin'),
('wx_review_id_2',10002,'wx2', 'wx_module_2', 'wx_test_project', 'COMPLETED', 'SINGLE', 001, null, null, 1,100.00,null,null,1698058347559,'admin',1698058347559,'admin');
('wx_review_id_2',10002,'wx2', 'wx_module_2', 'wx_test_project', 'COMPLETED', 'SINGLE', 001, null, null, 1,100.00,null,null,1698058347559,'admin',1698058347559,'admin'),
('wx_review_id_3',10003,'wx3', 'wx_module_3', 'wx_test_project', 'COMPLETED', 'MULTIPLE', 003, null, null, 1,100.00,null,null,1698058347559,'admin',1698058347559,'admin'),
('wx_review_id_4',10004,'wx3', 'wx_module_3', 'wx_test_project', 'COMPLETED', 'MULTIPLE', 003, null, null, 1,100.00,null,null,1698058347559,'admin',1698058347559,'admin');
INSERT INTO case_review_functional_case(id, review_id, case_id, status, create_time, create_user, update_time, pos)
VALUES ('wx_test_1', 'wx_review_id_1', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 1000),
('gyq_test_3', 'wx_review_id_1', 'gyq_case_id_3', 'PASS', 1698058347559,'admin',1698058347559, 1500),
('gyq_test_4', 'wx_review_id_1', 'gyq_case_id_4', 'PASS', 1698058347559,'admin',1698058347559, 2000),
('wx_test_2', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000);
('wx_test_2', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_3', 'wx_review_id_2', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_4', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_5', 'wx_review_id_3', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_6', 'wx_review_id_3', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_7', 'wx_review_id_3', 'wx_case_id_3', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_8', 'wx_review_id_4', 'wx_case_id_4', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_9', 'wx_review_id_4', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000),
('wx_test_10', 'wx_review_id_4', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000);
INSERT INTO case_review_functional_case_user(case_id, review_id, user_id)
VALUES ('wx_case_id_1', 'wx_review_id_1', 'admin'),
('wx_case_id_1', 'wx_review_id_1', 'gyq'),
('gyq_case_id_3', 'wx_review_id_1', 'gyq2'),
('gyq_case_id_4', 'wx_review_id_1', 'gyq');
('gyq_case_id_4', 'wx_review_id_1', 'gyq'),
('wx_case_id_3', 'wx_review_id_3', 'admin'),
('wx_case_id_4', 'wx_review_id_4', 'admin'),
('wx_case_id_1', 'wx_review_id_4', '123'),
('wx_case_id_1', 'wx_review_id_4', 'admin'),
('wx_case_id_2', 'wx_review_id_4', '123'),
('wx_case_id_2', 'wx_review_id_4', 'admin');
INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user) VALUES ('wx_module_1', 'wx_test_project', '测试所属模块', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin');
INSERT INTO case_review_history(id, review_id, case_id, content, status, deleted, notifier, create_user, create_time)
VALUES ('wx_history', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999),
('wx_histor_1', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999),
('wx_history_2', 'wx_review_id_3', 'wx_case_id_3', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999),
('wx_history_3', 'wx_review_id_4', 'wx_case_id_4', NULL, 'PASS', b'0', NULL, 'A', 1669174143999),
('wx_history_4', 'wx_review_id_4', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999),
('wx_history_5', 'wx_review_id_4', 'wx_case_id_2', NULL, 'UN_PASS', b'0', NULL, 'admin', 1669174143999);

View File

@ -8,10 +8,10 @@ import io.metersphere.project.service.ProjectService;
import io.metersphere.sdk.constants.ApplicationScope;
import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.sdk.constants.ProjectApplicationType;
import io.metersphere.system.dto.sdk.OptionDTO;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.sdk.OptionDTO;
import io.metersphere.system.log.annotation.Log;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.utils.SessionUtils;
@ -40,6 +40,8 @@ public class ProjectApplicationController {
@Resource
private ProjectService projectService;
private static final String UNDERLINE = "_";
/**
* ==========测试计划==========
*/
@ -165,7 +167,7 @@ public class ProjectApplicationController {
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_CASE_UPDATE)
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateCaseLog(#application)", msClass = ProjectApplicationService.class)
public void updateCase(@Validated({Updated.class}) @RequestBody ProjectApplication application) {
if (ProjectApplicationType.CASE_RELATED_CONFIG.CASE_ENABLE.name().equals(application.getType())) {
if ((ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + UNDERLINE + ProjectApplicationType.CASE_RELATED_CONFIG.CASE_ENABLE.name()).equals(application.getType())) {
String projectDemandThirdPartConfig = projectApplicationService.getProjectDemandThirdPartConfig(application.getProjectId());
if (StringUtils.isBlank(projectDemandThirdPartConfig)) {
throw new MSException(Translator.get("third_part_config_is_null"));
@ -247,7 +249,7 @@ public class ProjectApplicationController {
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_BUG_UPDATE)
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateBugLog(#application)", msClass = ProjectApplicationService.class)
public void updateBug(@Validated({Updated.class}) @RequestBody ProjectApplication application) {
if (ProjectApplicationType.BUG_SYNC_CONFIG.SYNC_ENABLE.name().equals(application.getType())) {
if ((ProjectApplicationType.BUG.BUG_SYNC.name() + UNDERLINE + ProjectApplicationType.BUG_SYNC_CONFIG.SYNC_ENABLE.name()).equals(application.getType())) {
String projectBugThirdPartConfig = projectApplicationService.getProjectBugThirdPartConfig(application.getProjectId());
if (StringUtils.isBlank(projectBugThirdPartConfig)) {
throw new MSException(Translator.get("third_part_config_is_null"));

View File

@ -496,7 +496,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
@Test
@Order(34)
public void testBugConfig() throws Exception {
ProjectApplication request = creatRequest(ProjectApplicationType.BUG_SYNC_CONFIG.SYNC_ENABLE.name(), "true");
ProjectApplication request = creatRequest(ProjectApplicationType.BUG.BUG_SYNC.name() + "_" + ProjectApplicationType.BUG_SYNC_CONFIG.SYNC_ENABLE.name(), "true");
this.requestPost(BUG_UPDATE_URL, request);
Map<String, String> congifs = mockTestData();
@ -516,7 +516,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
congifs.remove("CRON_EXPRESSION");
this.requestPostWithOkAndReturn(UPDATE_BUG_CONFIG_URL + "/default-project-2", congifs);
ProjectApplication afterRequest = creatRequest(ProjectApplicationType.BUG_SYNC_CONFIG.SYNC_ENABLE.name(), "true");
ProjectApplication afterRequest = creatRequest(ProjectApplicationType.BUG.BUG_SYNC.name() + "_" + ProjectApplicationType.BUG_SYNC_CONFIG.SYNC_ENABLE.name(), "true");
this.requestPost(BUG_UPDATE_URL, afterRequest);
}
@ -575,7 +575,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
@Test
@Order(37)
public void testCaseRelatedConfig() throws Exception {
ProjectApplication request = creatRequest(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_ENABLE.name(), "true");
ProjectApplication request = creatRequest(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + "_" + ProjectApplicationType.CASE_RELATED_CONFIG.CASE_ENABLE.name(), "true");
this.requestPost(CASE_UPDATE_URL, request);
Map<String, String> configs = mockRelatedTestData();
MvcResult mvcResult = this.requestPostWithOkAndReturn(UPDATE_CASE_RELATED_CONFIG_URL + "/project_application_test_id", configs);
@ -593,7 +593,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
ResultHolder updateResultHolder = JSON.parseObject(updateData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(updateResultHolder);
ProjectApplication afterRequest = creatRequest(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_ENABLE.name(), "true");
ProjectApplication afterRequest = creatRequest(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + "_" + ProjectApplicationType.CASE_RELATED_CONFIG.CASE_ENABLE.name(), "true");
this.requestPost(CASE_UPDATE_URL, afterRequest);
}