feat(工作台): 增加批量取消关注功能

--user=郭雨琦
--bug=1015281
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015281
This commit is contained in:
guoyuqi 2022-07-25 17:16:32 +08:00 committed by xiaomeinvG
parent dca129de0f
commit 6aadd379f6
4 changed files with 25 additions and 1 deletions

View File

@ -26,4 +26,9 @@ public class ApiBatchRequest extends ApiDefinitionWithBLOBs {
*/ */
private boolean appendTag = false; private boolean appendTag = false;
private ApiDefinitionRequest condition; private ApiDefinitionRequest condition;
/**
* 关注
*/
private String follow;
} }

View File

@ -54,4 +54,8 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs {
*/ */
private boolean appendTag = false; private boolean appendTag = false;
/**
* 关注
*/
private String follow;
} }

View File

@ -1789,6 +1789,9 @@ public class ApiDefinitionService {
} }
public void editApiByParam(ApiBatchRequest request) { public void editApiByParam(ApiBatchRequest request) {
if (request == null) {
return;
}
if (StringUtils.equals("tags", request.getType())) { if (StringUtils.equals("tags", request.getType())) {
this.batchEditDefinitionTags(request); this.batchEditDefinitionTags(request);
return; return;
@ -1800,7 +1803,7 @@ public class ApiDefinitionService {
definitionWithBLOBs.setUpdateTime(System.currentTimeMillis()); definitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
ServiceUtils.getSelectAllIds(request, request.getCondition(), ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiDefinitionMapper.selectIds(query)); (query) -> extApiDefinitionMapper.selectIds(query));
if (request != null && (request.getIds() != null || !request.getIds().isEmpty())) { if (CollectionUtils.isNotEmpty(request.getIds())) {
request.getIds().forEach(apiId -> { request.getIds().forEach(apiId -> {
ApiDefinitionWithBLOBs api = apiDefinitionMapper.selectByPrimaryKey(apiId); ApiDefinitionWithBLOBs api = apiDefinitionMapper.selectByPrimaryKey(apiId);
if (api == null) { if (api == null) {
@ -1831,6 +1834,11 @@ public class ApiDefinitionService {
apiDefinitionRequest.setVersionId(api.getVersionId()); apiDefinitionRequest.setVersionId(api.getVersionId());
checkNameExist(apiDefinitionRequest, false); checkNameExist(apiDefinitionRequest, false);
}); });
if (StringUtils.isNotEmpty(request.getFollow())) {
if (StringUtils.equals(request.getFollow(), "cancel")) {
this.deleteFollows(request.getIds());
}
}
} }
apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, getBatchExample(request)); apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, getBatchExample(request));
} }

View File

@ -793,6 +793,13 @@ public class ApiTestCaseService {
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
} }
} }
if (StringUtils.isNotEmpty(request.getFollow())) {
if (StringUtils.equals(request.getFollow(), "cancel")) {
ApiTestCaseFollowExample apiTestCaseFollowExample = new ApiTestCaseFollowExample();
apiTestCaseFollowExample.createCriteria().andCaseIdIn(ids);
apiTestCaseFollowMapper.deleteByExample(apiTestCaseFollowExample);
}
}
} }
private void batchEditTags(ApiTestBatchRequest request, List<String> ids) { private void batchEditTags(ApiTestBatchRequest request, List<String> ids) {