refactor(用例管理):新增日志类型加sourceId
This commit is contained in:
parent
33dfa35bd3
commit
1e6a09ca72
|
@ -3,6 +3,7 @@ package io.metersphere.functional.controller;
|
|||
import com.alibaba.excel.util.StringUtils;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.functional.domain.CaseReview;
|
||||
import io.metersphere.functional.dto.CaseReviewDTO;
|
||||
import io.metersphere.functional.request.*;
|
||||
import io.metersphere.functional.service.CaseReviewLogService;
|
||||
|
@ -64,7 +65,7 @@ public class CaseReviewController {
|
|||
@SendNotice(taskType = NoticeConstants.TaskType.CASE_REVIEW_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.getMainCaseReview(#request)", targetClass = CaseReviewNoticeService.class)
|
||||
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ_ADD)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public String addCaseReview(@Validated @RequestBody CaseReviewRequest request) {
|
||||
public CaseReview addCaseReview(@Validated @RequestBody CaseReviewRequest request) {
|
||||
return caseReviewService.addCaseReview(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
@ -74,7 +75,7 @@ public class CaseReviewController {
|
|||
@SendNotice(taskType = NoticeConstants.TaskType.CASE_REVIEW_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.getMainCaseReview(#request)", targetClass = CaseReviewNoticeService.class)
|
||||
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ_ADD)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public String copyCaseReview(@Validated @RequestBody CaseReviewCopyRequest request) {
|
||||
public CaseReview copyCaseReview(@Validated @RequestBody CaseReviewCopyRequest request) {
|
||||
return caseReviewService.copyCaseReview(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
|
|
@ -203,13 +203,13 @@ public class CaseReviewService {
|
|||
* @param request 页面参数
|
||||
* @param userId 当前操作人
|
||||
*/
|
||||
public String addCaseReview(CaseReviewRequest request, String userId) {
|
||||
public CaseReview addCaseReview(CaseReviewRequest request, String userId) {
|
||||
String caseReviewId = IDGenerator.nextStr();
|
||||
BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
|
||||
List<String> caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId());
|
||||
addCaseReview(request, userId, caseReviewId, caseIds);
|
||||
CaseReview caseReview = addCaseReview(request, userId, caseReviewId, caseIds);
|
||||
addAssociate(request, userId, caseReviewId, caseIds);
|
||||
return caseReviewId;
|
||||
return caseReview;
|
||||
}
|
||||
|
||||
private void addAssociate(CaseReviewRequest request, String userId, String caseReviewId, List<String> caseIds) {
|
||||
|
@ -230,15 +230,15 @@ public class CaseReviewService {
|
|||
}
|
||||
}
|
||||
|
||||
public String copyCaseReview(CaseReviewCopyRequest request, String userId) {
|
||||
public CaseReview copyCaseReview(CaseReviewCopyRequest request, String userId) {
|
||||
String caseReviewId = IDGenerator.nextStr();
|
||||
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
|
||||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(request.getCopyId());
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
List<String> caseIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).distinct().toList();
|
||||
addCaseReview(request, userId, caseReviewId, caseIds);
|
||||
CaseReview caseReview = addCaseReview(request, userId, caseReviewId, caseIds);
|
||||
addAssociate(request, userId, caseReviewId, caseIds);
|
||||
return caseReviewId;
|
||||
return caseReview;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,7 +340,7 @@ public class CaseReviewService {
|
|||
* @param userId 当前操作人
|
||||
* @param caseReviewId 用例评审id
|
||||
*/
|
||||
private void addCaseReview(CaseReviewRequest request, String userId, String caseReviewId, List<String> caseIds) {
|
||||
private CaseReview addCaseReview(CaseReviewRequest request, String userId, String caseReviewId, List<String> caseIds) {
|
||||
CaseReview caseReview = new CaseReview();
|
||||
caseReview.setId(caseReviewId);
|
||||
caseReview.setNum(getNextNum(request.getProjectId()));
|
||||
|
@ -367,6 +367,7 @@ public class CaseReviewService {
|
|||
caseReview.setCreateUser(userId);
|
||||
caseReview.setUpdateUser(userId);
|
||||
caseReviewMapper.insert(caseReview);
|
||||
return caseReview;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,7 @@ import io.metersphere.system.base.BaseTest;
|
|||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -79,7 +80,9 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
@Sql(scripts = {"/dml/init_case_review.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||
public void addCaseReviewSuccess() throws Exception {
|
||||
CaseReviewRequest caseReviewRequest = getCaseReviewAddRequest("创建评审1", CaseReviewPassRule.SINGLE.toString(), "CASE_REVIEW_TEST_GYQ_ID", false, true, null);
|
||||
this.requestPostWithOk(ADD_CASE_REVIEW, caseReviewRequest);
|
||||
MvcResult mvcResult = this.requestPostWithOkAndReturn(ADD_CASE_REVIEW, caseReviewRequest);
|
||||
CaseReview caseReview = getResultData(mvcResult, CaseReview.class);
|
||||
checkLog(caseReview.getId(), OperationLogType.ADD);
|
||||
List<CaseReview> caseReviews = getCaseReviews("创建评审1");
|
||||
Assertions.assertEquals(1, caseReviews.size());
|
||||
String caseReviewId = caseReviews.get(0).getId();
|
||||
|
@ -95,7 +98,9 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
|
||||
CaseReviewCopyRequest caseReviewCopyRequest = getCaseReviewAddRequest("创建评审1", CaseReviewPassRule.SINGLE.toString(), "CASE_REVIEW_TEST_GYQ_ID", false, true, null);
|
||||
caseReviewCopyRequest.setCopyId(caseReviewId);
|
||||
this.requestPostWithOk(COPY_CASE_REVIEW, caseReviewCopyRequest);
|
||||
MvcResult mvcResult1 = this.requestPostWithOkAndReturn(COPY_CASE_REVIEW, caseReviewCopyRequest);
|
||||
CaseReview caseReview1 = getResultData(mvcResult1, CaseReview.class);
|
||||
checkLog(caseReview1.getId(), OperationLogType.COPY);
|
||||
caseReviews = getCaseReviews("创建评审1");
|
||||
Assertions.assertEquals(2, caseReviews.size());
|
||||
List<String> list = caseReviews.stream().map(CaseReview::getId).distinct().toList();
|
||||
|
|
Loading…
Reference in New Issue