refactor(功能用例): 移动模块到回收站用例也移动

This commit is contained in:
guoyuqi 2023-11-01 18:42:32 +08:00 committed by Craftsman
parent 45cdc8cc36
commit b62c7c271b
5 changed files with 16 additions and 17 deletions

View File

@ -19,4 +19,6 @@ public interface ExtFunctionalCaseMapper {
List<FunctionalCaseVersionDTO> getFunctionalCaseByRefId(@Param("refId") String refId);
List<String> getFunctionalCaseIds(@Param("projectId") String projectId);
void removeToTrashByModuleIds(@Param("moduleIds") List<String> deleteIds);
}

View File

@ -56,4 +56,11 @@
WHERE
project_id = #{projectId}
</select>
<update id="removeToTrashByModuleIds" parameterType="java.lang.String">
UPDATE functional_case SET deleted = true WHERE module_id IN
<foreach collection="moduleIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>

View File

@ -1,6 +1,5 @@
package io.metersphere.functional.mapper;
import io.metersphere.functional.domain.FunctionalCaseModule;
import io.metersphere.project.dto.NodeSortQueryParam;
import io.metersphere.system.dto.sdk.BaseModule;
import io.metersphere.system.dto.sdk.BaseTreeNode;
@ -11,26 +10,14 @@ import java.util.List;
public interface ExtFunctionalCaseModuleMapper {
List<BaseTreeNode> selectBaseByProjectId(String projectId);
List<BaseTreeNode> selectIdAndParentIdByProjectId(String projectId);
List<String> selectChildrenIdsByParentIds(@Param("ids") List<String> deleteIds);
List<String> selectChildrenIdsSortByPos(String parentId);
void removeToTrashByIds(@Param("ids") List<String> deleteId);
void removeToTrashByIds(@Param("ids") List<String> deleteIds);
Long getMaxPosByParentId(String parentId);
List<String> selectIdsByProjectId(String projectId);
FunctionalCaseModule getLastModuleByParentId(String id);
FunctionalCaseModule getNextModuleInParentId(@Param("parentId") String parentId, @Param("pos") long pos);
FunctionalCaseModule getPreviousModuleInParentId(@Param("parentId") String parentId, @Param("pos") long pos);
String selectNameById(String moduleId);
BaseModule selectBaseModuleById(String dragNodeId);
BaseModule selectModuleByParentIdAndPosOperator(NodeSortQueryParam nodeSortQueryParam);

View File

@ -41,12 +41,12 @@
#{id}
</foreach>
</select>
<delete id="removeToTrashByIds" parameterType="java.lang.String">
<update id="removeToTrashByIds" parameterType="java.lang.String">
UPDATE functional_case_module SET deleted = true WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
<select id="getMaxPosByParentId" resultType="java.lang.Long">
SELECT max(pos) FROM functional_case_module
WHERE parent_id = #{0}

View File

@ -9,6 +9,7 @@ package io.metersphere.functional.service;
import io.metersphere.functional.domain.FunctionalCaseModule;
import io.metersphere.functional.domain.FunctionalCaseModuleExample;
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
import io.metersphere.functional.mapper.ExtFunctionalCaseModuleMapper;
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
import io.metersphere.functional.request.FunctionalCaseModuleCreateRequest;
@ -44,6 +45,8 @@ public class FunctionalCaseModuleService extends ModuleTreeService {
private SqlSessionFactory sqlSessionFactory;
@Resource
private ExtFunctionalCaseModuleMapper extFunctionalCaseModuleMapper;
@Resource
private ExtFunctionalCaseMapper extFunctionalCaseMapper;
public List<BaseTreeNode> getTree(String projectId) {
List<BaseTreeNode> fileModuleList = extFunctionalCaseModuleMapper.selectBaseByProjectId(projectId);
@ -110,7 +113,7 @@ public class FunctionalCaseModuleService extends ModuleTreeService {
if (CollectionUtils.isEmpty(deleteIds)) {
return;
}
//TODO批量移动case到回收站
extFunctionalCaseMapper.removeToTrashByModuleIds(deleteIds);
extFunctionalCaseModuleMapper.removeToTrashByIds(deleteIds);
List<String> childrenIds = extFunctionalCaseModuleMapper.selectChildrenIdsByParentIds(deleteIds);
if (CollectionUtils.isNotEmpty(childrenIds)) {