feat(测试计划): 计划详情返回关注计划标识

This commit is contained in:
WangXu10 2024-05-20 18:30:52 +08:00 committed by Craftsman
parent 8e41b18136
commit 2b609c41f9
3 changed files with 17 additions and 2 deletions

View File

@ -131,7 +131,7 @@ public class TestPlanController {
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ)
@CheckOwner(resourceId = "#id", resourceType = "test_plan")
public TestPlanDetailResponse detail(@NotBlank @PathVariable String id) {
return testPlanService.detail(id);
return testPlanService.detail(id, SessionUtils.getUserId());
}
@PostMapping(value = "/batch-delete")

View File

@ -60,4 +60,7 @@ public class TestPlanDetailResponse extends TestPlanStatisticsResponse implement
@Schema(description = "是否定时任务")
private Boolean useSchedule;
@Schema(description = "关注标识")
private Boolean followFlag;
}

View File

@ -460,7 +460,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
* @param id 计划ID
* @return 计划的详情数据
*/
public TestPlanDetailResponse detail(String id) {
public TestPlanDetailResponse detail(String id, String userId) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(id);
TestPlanDetailResponse response = new TestPlanDetailResponse();
String moduleName = getModuleName(testPlan.getModuleId());
@ -485,9 +485,21 @@ public class TestPlanService extends TestPlanBaseUtilsService {
ScheduleExample example = new ScheduleExample();
example.createCriteria().andResourceIdEqualTo(id).andResourceTypeEqualTo("TEST_PLAN");
response.setUseSchedule(scheduleMapper.countByExample(example) > 0);
//是否关注计划
Boolean isFollow = checkIsFollowCase(id, userId);
response.setFollowFlag(isFollow);
return response;
}
private Boolean checkIsFollowCase(String testPlanId, String userId) {
TestPlanFollowerExample example = new TestPlanFollowerExample();
example.createCriteria().andTestPlanIdEqualTo(testPlanId).andUserIdEqualTo(userId);
return testPlanFollowerMapper.countByExample(example) > 0;
}
private void getOtherConfig(TestPlanDetailResponse response, TestPlan testPlan) {
TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(testPlan.getId());
response.setAutomaticStatusUpdate(testPlanConfig.getAutomaticStatusUpdate());