Skip to content

Commit

Permalink
Merge pull request #396 from caofengbin/feature/add_search_by_designer
Browse files Browse the repository at this point in the history
feat:用例支持按作者进行筛选的操作
  • Loading branch information
ZhouYixun authored Dec 20, 2023
2 parents 8a3c513 + 9ffd935 commit 823a634
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public class TestCasesController {
@Parameter(name = "platform", description = "平台类型"),
@Parameter(name = "name", description = "用例名称"),
@Parameter(name = "moduleIds", description = "模块Id"),
@Parameter(name = "caseAuthorNames", description = "用例作者列表"),
@Parameter(name = "page", description = "页码"),
@Parameter(name = "pageSize", description = "页数据大小"),
@Parameter(name = "idSort", description = "控制id排序方式"),
@Parameter(name = "designerSort", description = "控制designer排序方式"),
@Parameter(name = "editTimeSort", description = "控制editTime排序方式")

})
Expand All @@ -71,15 +71,16 @@ public RespModel<CommentPage<TestCasesDTO>> findAll(@RequestParam(name = "projec
@RequestParam(name = "platform") int platform,
@RequestParam(name = "name", required = false) String name,
@RequestParam(name = "moduleIds[]", required = false) List<Integer> moduleIds,
@RequestParam(name = "caseAuthorNames[]", required = false) List<String> caseAuthorNames,
@RequestParam(name = "page") int page,
@RequestParam(name = "pageSize") int pageSize,
@RequestParam(name = "idSort", required = false) String idSort,
@RequestParam(value = "designerSort", required = false) String designerSort,
@RequestParam(value = "editTimeSort", required = false) String editTimeSort) {
Page<TestCases> pageable = new Page<>(page, pageSize);
return new RespModel<>(
RespEnum.SEARCH_OK,
testCasesService.findAll(projectId, platform, name, moduleIds, pageable, idSort, designerSort, editTimeSort)
testCasesService.findAll(projectId, platform, name, moduleIds, caseAuthorNames,
pageable, idSort, editTimeSort)
);
}

Expand Down Expand Up @@ -167,4 +168,19 @@ public RespModel<String> copyTestById(@RequestParam(name = "id") Integer id) {
testCasesService.copyTestById(id);
return new RespModel<>(RespEnum.COPY_OK);
}

@WebAspect
@Operation(summary = "查询用例所有的作者列表", description = "查找对应项目id下对应平台的所有作者列表")
@Parameters(value = {
@Parameter(name = "projectId", description = "项目id"),
@Parameter(name = "platform", description = "平台类型"),
})
@GetMapping("/listAllCaseAuthor")
public RespModel<List<String>> findAllCaseAuthor(@RequestParam(name = "projectId") int projectId,
@RequestParam(name = "platform") int platform) {
return new RespModel<>(
RespEnum.SEARCH_OK,
testCasesService.findAllCaseAuthor(projectId, platform)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public interface TestCasesMapper extends BaseMapper<TestCases> {
"where tstc.test_suites_id = #{suiteId} " +
"order by tstc.sort asc")
List<TestCases> listByTestSuitesId(@Param("suiteId") int suiteId);

@Select("select DISTINCT designer from test_cases WHERE project_id= #{projectId} and platform= #{platform}")
List<String> listAllTestCaseAuthor(@Param("projectId") int projectId, @Param("platform") int platform);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* @date 2021/8/20 17:51
*/
public interface TestCasesService extends IService<TestCases> {
CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds, Page<TestCases> pageable,
String idSort, String designerSort, String editTimeSort);
CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds,
List<String> caseAuthorNames, Page<TestCases> pageable,
String idSort, String editTimeSort);

List<TestCases> findAll(int projectId, int platform);

Expand All @@ -41,4 +42,13 @@ CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List
boolean copyTestById(int id);

Boolean updateTestCaseModuleByModuleId(Integer module);

/**
* 查询指定项目,指定平台下,所有的用例作者列表集合
*
* @param projectId 项目id
* @param platform 平台
* @return 用例作者列表集合
*/
List<String> findAllCaseAuthor(int projectId, int platform);
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,22 @@ public class TestCasesServiceImpl extends SonicServiceImpl<TestCasesMapper, Test
private ModulesMapper modulesMapper;

@Override
public CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds, Page<TestCases> pageable,
String idSort, String designerSort, String editTimeSort) {
public CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds,
List<String> caseAuthorNames,
Page<TestCases> pageable,
String idSort, String editTimeSort) {

LambdaQueryChainWrapper<TestCases> lambdaQuery = lambdaQuery();

lambdaQuery.eq(projectId != 0, TestCases::getProjectId, projectId)
.eq(platform != 0, TestCases::getPlatform, platform)
.in(moduleIds != null && moduleIds.size() > 0, TestCases::getModuleId, moduleIds)
.in(caseAuthorNames != null && caseAuthorNames.size() > 0, TestCases::getDesigner, caseAuthorNames)
.like(!StringUtils.isEmpty(name), TestCases::getName, name)
.orderByDesc(StringUtils.isEmpty(editTimeSort) && StringUtils.isEmpty(idSort) && StringUtils.isEmpty(designerSort),
.orderByDesc(StringUtils.isEmpty(editTimeSort) && StringUtils.isEmpty(idSort),
TestCases::getEditTime)
.orderBy(!StringUtils.isEmpty(editTimeSort), "asc".equals(editTimeSort), TestCases::getEditTime)
.orderBy(!StringUtils.isEmpty(idSort), "asc".equals(idSort), TestCases::getId)
.orderBy(!StringUtils.isEmpty(designerSort), "asc".equals(designerSort), TestCases::getDesigner);
.orderBy(!StringUtils.isEmpty(idSort), "asc".equals(idSort), TestCases::getId);

//写入对应模块信息
Page<TestCases> page = lambdaQuery.page(pageable);
Expand Down Expand Up @@ -286,5 +288,10 @@ public Boolean updateTestCaseModuleByModuleId(Integer module) {
}
return true;
}

@Override
public List<String> findAllCaseAuthor(int projectId, int platform) {
return testCasesMapper.listAllTestCaseAuthor(projectId, platform);
}
}

0 comments on commit 823a634

Please sign in to comment.