Skip to content

Commit 823a634

Browse files
authored
Merge pull request SonicCloudOrg#396 from caofengbin/feature/add_search_by_designer
feat:用例支持按作者进行筛选的操作
2 parents 8a3c513 + 9ffd935 commit 823a634

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/TestCasesController.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ public class TestCasesController {
5959
@Parameter(name = "platform", description = "平台类型"),
6060
@Parameter(name = "name", description = "用例名称"),
6161
@Parameter(name = "moduleIds", description = "模块Id"),
62+
@Parameter(name = "caseAuthorNames", description = "用例作者列表"),
6263
@Parameter(name = "page", description = "页码"),
6364
@Parameter(name = "pageSize", description = "页数据大小"),
6465
@Parameter(name = "idSort", description = "控制id排序方式"),
65-
@Parameter(name = "designerSort", description = "控制designer排序方式"),
6666
@Parameter(name = "editTimeSort", description = "控制editTime排序方式")
6767

6868
})
@@ -71,15 +71,16 @@ public RespModel<CommentPage<TestCasesDTO>> findAll(@RequestParam(name = "projec
7171
@RequestParam(name = "platform") int platform,
7272
@RequestParam(name = "name", required = false) String name,
7373
@RequestParam(name = "moduleIds[]", required = false) List<Integer> moduleIds,
74+
@RequestParam(name = "caseAuthorNames[]", required = false) List<String> caseAuthorNames,
7475
@RequestParam(name = "page") int page,
7576
@RequestParam(name = "pageSize") int pageSize,
7677
@RequestParam(name = "idSort", required = false) String idSort,
77-
@RequestParam(value = "designerSort", required = false) String designerSort,
7878
@RequestParam(value = "editTimeSort", required = false) String editTimeSort) {
7979
Page<TestCases> pageable = new Page<>(page, pageSize);
8080
return new RespModel<>(
8181
RespEnum.SEARCH_OK,
82-
testCasesService.findAll(projectId, platform, name, moduleIds, pageable, idSort, designerSort, editTimeSort)
82+
testCasesService.findAll(projectId, platform, name, moduleIds, caseAuthorNames,
83+
pageable, idSort, editTimeSort)
8384
);
8485
}
8586

@@ -167,4 +168,19 @@ public RespModel<String> copyTestById(@RequestParam(name = "id") Integer id) {
167168
testCasesService.copyTestById(id);
168169
return new RespModel<>(RespEnum.COPY_OK);
169170
}
171+
172+
@WebAspect
173+
@Operation(summary = "查询用例所有的作者列表", description = "查找对应项目id下对应平台的所有作者列表")
174+
@Parameters(value = {
175+
@Parameter(name = "projectId", description = "项目id"),
176+
@Parameter(name = "platform", description = "平台类型"),
177+
})
178+
@GetMapping("/listAllCaseAuthor")
179+
public RespModel<List<String>> findAllCaseAuthor(@RequestParam(name = "projectId") int projectId,
180+
@RequestParam(name = "platform") int platform) {
181+
return new RespModel<>(
182+
RespEnum.SEARCH_OK,
183+
testCasesService.findAllCaseAuthor(projectId, platform)
184+
);
185+
}
170186
}

sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/TestCasesMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ public interface TestCasesMapper extends BaseMapper<TestCases> {
2222
"where tstc.test_suites_id = #{suiteId} " +
2323
"order by tstc.sort asc")
2424
List<TestCases> listByTestSuitesId(@Param("suiteId") int suiteId);
25+
26+
@Select("select DISTINCT designer from test_cases WHERE project_id= #{projectId} and platform= #{platform}")
27+
List<String> listAllTestCaseAuthor(@Param("projectId") int projectId, @Param("platform") int platform);
2528
}

sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/TestCasesService.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
* @date 2021/8/20 17:51
1616
*/
1717
public interface TestCasesService extends IService<TestCases> {
18-
CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds, Page<TestCases> pageable,
19-
String idSort, String designerSort, String editTimeSort);
18+
CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds,
19+
List<String> caseAuthorNames, Page<TestCases> pageable,
20+
String idSort, String editTimeSort);
2021

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

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

4344
Boolean updateTestCaseModuleByModuleId(Integer module);
45+
46+
/**
47+
* 查询指定项目,指定平台下,所有的用例作者列表集合
48+
*
49+
* @param projectId 项目id
50+
* @param platform 平台
51+
* @return 用例作者列表集合
52+
*/
53+
List<String> findAllCaseAuthor(int projectId, int platform);
4454
}

sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/TestCasesServiceImpl.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,22 @@ public class TestCasesServiceImpl extends SonicServiceImpl<TestCasesMapper, Test
6666
private ModulesMapper modulesMapper;
6767

6868
@Override
69-
public CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds, Page<TestCases> pageable,
70-
String idSort, String designerSort, String editTimeSort) {
69+
public CommentPage<TestCasesDTO> findAll(int projectId, int platform, String name, List<Integer> moduleIds,
70+
List<String> caseAuthorNames,
71+
Page<TestCases> pageable,
72+
String idSort, String editTimeSort) {
7173

7274
LambdaQueryChainWrapper<TestCases> lambdaQuery = lambdaQuery();
7375

7476
lambdaQuery.eq(projectId != 0, TestCases::getProjectId, projectId)
7577
.eq(platform != 0, TestCases::getPlatform, platform)
7678
.in(moduleIds != null && moduleIds.size() > 0, TestCases::getModuleId, moduleIds)
79+
.in(caseAuthorNames != null && caseAuthorNames.size() > 0, TestCases::getDesigner, caseAuthorNames)
7780
.like(!StringUtils.isEmpty(name), TestCases::getName, name)
78-
.orderByDesc(StringUtils.isEmpty(editTimeSort) && StringUtils.isEmpty(idSort) && StringUtils.isEmpty(designerSort),
81+
.orderByDesc(StringUtils.isEmpty(editTimeSort) && StringUtils.isEmpty(idSort),
7982
TestCases::getEditTime)
8083
.orderBy(!StringUtils.isEmpty(editTimeSort), "asc".equals(editTimeSort), TestCases::getEditTime)
81-
.orderBy(!StringUtils.isEmpty(idSort), "asc".equals(idSort), TestCases::getId)
82-
.orderBy(!StringUtils.isEmpty(designerSort), "asc".equals(designerSort), TestCases::getDesigner);
84+
.orderBy(!StringUtils.isEmpty(idSort), "asc".equals(idSort), TestCases::getId);
8385

8486
//写入对应模块信息
8587
Page<TestCases> page = lambdaQuery.page(pageable);
@@ -286,5 +288,10 @@ public Boolean updateTestCaseModuleByModuleId(Integer module) {
286288
}
287289
return true;
288290
}
291+
292+
@Override
293+
public List<String> findAllCaseAuthor(int projectId, int platform) {
294+
return testCasesMapper.listAllTestCaseAuthor(projectId, platform);
295+
}
289296
}
290297

0 commit comments

Comments
 (0)