refactor(功能用例): 去掉删除用例判断版本逻辑&去掉部分异步注解

This commit is contained in:
WangXu10 2023-12-08 10:39:15 +08:00 committed by f2c-ci-robot[bot]
parent bc09af34bb
commit 12894f88fe
6 changed files with 28 additions and 28 deletions

View File

@ -151,7 +151,7 @@ public class FunctionalCaseCommentService {
}
}
@Async
public void sendNotice(FunctionalCaseCommentRequest functionalCaseCommentRequest, String userId, FunctionalCaseDTO functionalCaseDTO) {
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
String template = defaultTemplateMap.get(NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK + "_" + functionalCaseCommentRequest.getEvent());

View File

@ -33,6 +33,7 @@ import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@ -359,28 +360,24 @@ public class FunctionalCaseService {
List<String> refId = extFunctionalCaseMapper.getRefIds(ids, false);
extFunctionalCaseMapper.batchDelete(refId, userId);
} else {
//列表删除 需要判断是否存在多个版本问题
doDelete(ids, userId);
}
}
private void doDelete(List<String> ids, String userId) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
FunctionalCaseMapper caseMapper = sqlSession.getMapper(FunctionalCaseMapper.class);
ids.forEach(id -> {
List<FunctionalCaseVersionDTO> versionDTOList = getFunctionalCaseVersion(id);
if (versionDTOList.size() > 1) {
String projectId = versionDTOList.get(0).getProjectId();
deleteFunctionalCaseService.deleteFunctionalCaseResource(Collections.singletonList(id), projectId);
} else {
//只有一个版本 直接放入回收站
doDelete(id, userId);
}
});
}
}
private void doDelete(String id, String userId) {
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setDeleted(true);
functionalCase.setId(id);
functionalCase.setDeleteUser(userId);
functionalCase.setDeleteTime(System.currentTimeMillis());
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
caseMapper.updateByPrimaryKeySelective(functionalCase);
});
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
}
@ -463,6 +460,7 @@ public class FunctionalCaseService {
* @param request request
* @param userId userId
*/
@Async
public void batchCopyFunctionalCase(FunctionalCaseBatchMoveRequest request, String userId) {
List<String> ids = doSelectIds(request, request.getProjectId());
if (CollectionUtils.isNotEmpty(ids)) {

View File

@ -58,7 +58,7 @@ public class FunctionalCaseTrashService {
extFunctionalCaseMapper.recoverCase(ids,userId,System.currentTimeMillis());
}
@Async
public void delCustomFields(List<String> ids) {
doDeleteCustomFields(ids);
}
@ -83,7 +83,7 @@ public class FunctionalCaseTrashService {
}
}
@Async
public void delCustomFieldsByRefIds(List<String> refIds) {
FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample();
functionalCaseExample.createCriteria().andRefIdIn(refIds);

View File

@ -85,7 +85,7 @@ public class ReviewFunctionalCaseService {
}
}
@Async
public void sendNotice(List<String> relatedUsers, String userId,ReviewFunctionalCaseRequest request, String task, String event) {
CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(request.getReviewId());
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(request.getCaseId());

View File

@ -46,6 +46,9 @@ public class SystemParameterService {
@Resource
BaseSystemParameterMapper baseSystemParameterMapper;
private static final String DEFAULT_LOG_TIME = "6D";
private static final String DEFAULT_HISTORY_TIME = "10";
public void saveBaseInfo(List<SystemParameter> parameters) {
SystemParameterExample example = new SystemParameterExample();
parameters.forEach(param -> {
@ -273,9 +276,8 @@ public class SystemParameterService {
}
public void editLogConfig(List<SystemParameter> systemParameter) {
systemParameter.forEach(parameter ->{
systemParameter.forEach(parameter -> {
SystemParameterExample example = new SystemParameterExample();
example.createCriteria().andParamKeyEqualTo(parameter.getParamKey());
if (systemParameterMapper.countByExample(example) > 0) {
@ -314,9 +316,9 @@ public class SystemParameterService {
if (CollectionUtils.isNotEmpty(paramList)) {
paramList.forEach(param -> {
if (StringUtils.equals(param.getParamKey(), ParamConstants.CleanConfig.OPERATION_LOG.getValue())) {
configDTO.setOperationLog(param.getParamValue());
configDTO.setOperationLog(StringUtils.defaultIfBlank(param.getParamValue(), DEFAULT_LOG_TIME));
} else if (StringUtils.equals(param.getParamKey(), ParamConstants.CleanConfig.OPERATION_HISTORY.getValue())) {
configDTO.setOperationHistory(param.getParamValue());
configDTO.setOperationHistory(StringUtils.defaultIfBlank(param.getParamValue(), DEFAULT_HISTORY_TIME));
}
});
}

View File

@ -97,7 +97,7 @@ public class SystemParameterControllerTests extends BaseTest {
}
@Test
@Order(3)
@Order(4)
public void testGetEmailInfo() throws Exception {
this.requestGet(EMAIL_INFO_URL);
requestGetPermissionTest(PermissionConstants.SYSTEM_PARAMETER_SETTING_BASE_READ, EMAIL_INFO_URL);
@ -105,7 +105,7 @@ public class SystemParameterControllerTests extends BaseTest {
@Test
@Order(4)
@Order(3)
public void testEditEmailInfo() throws Exception {
List<SystemParameter> systemParameters = new ArrayList<>() {{