feat(用例评审): 获取评审历史列表功能
This commit is contained in:
parent
8a56091639
commit
9f810c0c36
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.functional.controller;
|
package io.metersphere.functional.controller;
|
||||||
|
|
||||||
|
import io.metersphere.functional.dto.CaseReviewHistoryDTO;
|
||||||
import io.metersphere.functional.request.ReviewFunctionalCaseRequest;
|
import io.metersphere.functional.request.ReviewFunctionalCaseRequest;
|
||||||
import io.metersphere.functional.service.ReviewFunctionalCaseService;
|
import io.metersphere.functional.service.ReviewFunctionalCaseService;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
|
@ -9,10 +10,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@Tag(name = "用例管理-用例评审-评审功能用例")
|
@Tag(name = "用例管理-用例评审-评审功能用例")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -29,5 +29,12 @@ public class ReviewFunctionalCaseController {
|
||||||
reviewFunctionalCaseService.saveReview(request, SessionUtils.getUserId());
|
reviewFunctionalCaseService.saveReview(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/list/{reviewId}/{caseId}")
|
||||||
|
@Operation(summary = "用例管理-用例评审-评审功能用例-获取用例评审历史")
|
||||||
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
|
||||||
|
public List<CaseReviewHistoryDTO> getCaseReviewHistoryList(@PathVariable String reviewId, @PathVariable String caseId) {
|
||||||
|
return reviewFunctionalCaseService.getCaseReviewHistoryList(reviewId, caseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package io.metersphere.functional.dto;
|
||||||
|
|
||||||
|
import io.metersphere.functional.domain.CaseReviewHistory;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CaseReviewHistoryDTO extends CaseReviewHistory {
|
||||||
|
|
||||||
|
@Schema(description = "评审人头像")
|
||||||
|
private String userLogo;
|
||||||
|
|
||||||
|
@Schema(description = "评审人名")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "评审解析内容")
|
||||||
|
private String contentText;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package io.metersphere.functional.mapper;
|
||||||
|
|
||||||
|
import io.metersphere.functional.dto.CaseReviewHistoryDTO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author guoyuqi
|
||||||
|
*/
|
||||||
|
public interface ExtCaseReviewHistoryMapper {
|
||||||
|
|
||||||
|
List<CaseReviewHistoryDTO> list(@Param("caseId") String caseId, @Param("reviewId") String reviewId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="io.metersphere.functional.mapper.ExtCaseReviewHistoryMapper">
|
||||||
|
|
||||||
|
<select id="list" resultType="io.metersphere.functional.dto.CaseReviewHistoryDTO">
|
||||||
|
SELECT
|
||||||
|
ch.id,
|
||||||
|
ch.review_id,
|
||||||
|
ch.case_id,
|
||||||
|
ch.status,
|
||||||
|
ch.notifier,
|
||||||
|
ch.create_user,
|
||||||
|
ch.create_time,
|
||||||
|
ch.content,
|
||||||
|
u.name as userName,
|
||||||
|
ux.avatar as userLogo
|
||||||
|
FROM
|
||||||
|
case_review_history ch
|
||||||
|
left join user u on ch.create_user = u.id
|
||||||
|
left join user_extend ux on ch.create_user = ux.id
|
||||||
|
where ch.case_id = #{caseId} and ch.review_id = #{reviewId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -4,6 +4,7 @@ import io.metersphere.functional.constants.CaseReviewPassRule;
|
||||||
import io.metersphere.functional.constants.CaseReviewStatus;
|
import io.metersphere.functional.constants.CaseReviewStatus;
|
||||||
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
||||||
import io.metersphere.functional.domain.*;
|
import io.metersphere.functional.domain.*;
|
||||||
|
import io.metersphere.functional.dto.CaseReviewHistoryDTO;
|
||||||
import io.metersphere.functional.mapper.*;
|
import io.metersphere.functional.mapper.*;
|
||||||
import io.metersphere.functional.request.ReviewFunctionalCaseRequest;
|
import io.metersphere.functional.request.ReviewFunctionalCaseRequest;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
|
@ -22,6 +23,7 @@ import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -45,6 +47,9 @@ public class ReviewFunctionalCaseService {
|
||||||
private NoticeSendService noticeSendService;
|
private NoticeSendService noticeSendService;
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionalCaseMapper functionalCaseMapper;
|
private FunctionalCaseMapper functionalCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtCaseReviewHistoryMapper extCaseReviewHistoryMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,4 +217,12 @@ public class ReviewFunctionalCaseService {
|
||||||
caseReviewHistory.setCreateTime(System.currentTimeMillis());
|
caseReviewHistory.setCreateTime(System.currentTimeMillis());
|
||||||
return caseReviewHistory;
|
return caseReviewHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CaseReviewHistoryDTO> getCaseReviewHistoryList(String reviewId, String caseId) {
|
||||||
|
List<CaseReviewHistoryDTO> list = extCaseReviewHistoryMapper.list(caseId, reviewId);
|
||||||
|
for (CaseReviewHistoryDTO caseReviewHistoryDTO : list) {
|
||||||
|
caseReviewHistoryDTO.setContentText(new String(caseReviewHistoryDTO.getContent(),StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.functional.constants.CaseReviewPassRule;
|
||||||
import io.metersphere.functional.constants.CaseReviewStatus;
|
import io.metersphere.functional.constants.CaseReviewStatus;
|
||||||
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
||||||
import io.metersphere.functional.domain.*;
|
import io.metersphere.functional.domain.*;
|
||||||
|
import io.metersphere.functional.dto.CaseReviewHistoryDTO;
|
||||||
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper;
|
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper;
|
||||||
import io.metersphere.functional.mapper.CaseReviewHistoryMapper;
|
import io.metersphere.functional.mapper.CaseReviewHistoryMapper;
|
||||||
import io.metersphere.functional.mapper.CaseReviewMapper;
|
import io.metersphere.functional.mapper.CaseReviewMapper;
|
||||||
|
@ -12,19 +13,27 @@ import io.metersphere.functional.request.ReviewFunctionalCaseRequest;
|
||||||
import io.metersphere.project.domain.Notification;
|
import io.metersphere.project.domain.Notification;
|
||||||
import io.metersphere.project.domain.NotificationExample;
|
import io.metersphere.project.domain.NotificationExample;
|
||||||
import io.metersphere.project.mapper.NotificationMapper;
|
import io.metersphere.project.mapper.NotificationMapper;
|
||||||
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.context.jdbc.Sql;
|
import org.springframework.test.context.jdbc.Sql;
|
||||||
import org.springframework.test.context.jdbc.SqlConfig;
|
import org.springframework.test.context.jdbc.SqlConfig;
|
||||||
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
@ -36,6 +45,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
|
||||||
|
|
||||||
private static final String SAVE_REVIEW = "/review/functional/case/save";
|
private static final String SAVE_REVIEW = "/review/functional/case/save";
|
||||||
private static final String ADD_CASE_REVIEW = "/case/review/add";
|
private static final String ADD_CASE_REVIEW = "/case/review/add";
|
||||||
|
private static final String REVIEW_LIST = "/review/functional/case/get/list/";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CaseReviewMapper caseReviewMapper;
|
private CaseReviewMapper caseReviewMapper;
|
||||||
|
@ -215,6 +225,29 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(4)
|
||||||
|
public void getListSuccess() throws Exception {
|
||||||
|
List<CaseReview> caseReviews = getCaseReviews("创建用例评审1");
|
||||||
|
String reviewId = caseReviews.get(0).getId();
|
||||||
|
List<CaseReviewHistoryDTO> gyqReviewCaseTest = getCaseReviewHistoryList("gyqReviewCaseTest", reviewId);
|
||||||
|
System.out.println(JSON.toJSONString(gyqReviewCaseTest));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<CaseReviewHistoryDTO> getCaseReviewHistoryList(String caseId,String reviewId) throws Exception {
|
||||||
|
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(REVIEW_LIST +"/"+reviewId +"/"+ caseId).header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
|
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||||
|
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||||
|
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||||
|
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), CaseReviewHistoryDTO.class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private List<CaseReview> addReview(String name, List<String> caseIds, List<String> reviewers) throws Exception {
|
private List<CaseReview> addReview(String name, List<String> caseIds, List<String> reviewers) throws Exception {
|
||||||
CaseReviewRequest caseReviewRequest = new CaseReviewRequest();
|
CaseReviewRequest caseReviewRequest = new CaseReviewRequest();
|
||||||
caseReviewRequest.setProjectId(projectId);
|
caseReviewRequest.setProjectId(projectId);
|
||||||
|
|
Loading…
Reference in New Issue