fix(接口自动化): 模块同级别排序
This commit is contained in:
parent
1e180af32d
commit
ee27fa0c5e
|
@ -59,4 +59,10 @@ public class ApiModuleController {
|
||||||
public void dragNode(@RequestBody DragModuleRequest node) {
|
public void dragNode(@RequestBody DragModuleRequest node) {
|
||||||
apiModuleService.dragNode(node);
|
apiModuleService.dragNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/pos")
|
||||||
|
public void treeSort(@RequestBody List<String> ids) {
|
||||||
|
apiModuleService.sort(ids);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,4 +59,10 @@ public class ApiScenarioModuleController {
|
||||||
public void dragNode(@RequestBody DragApiScenarioModuleRequest node) {
|
public void dragNode(@RequestBody DragApiScenarioModuleRequest node) {
|
||||||
apiScenarioModuleService.dragNode(node);
|
apiScenarioModuleService.dragNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/pos")
|
||||||
|
public void treeSort(@RequestBody List<String> ids) {
|
||||||
|
apiScenarioModuleService.sort(ids);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.api.service;
|
package io.metersphere.api.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
|
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
|
||||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||||
import io.metersphere.api.dto.definition.ApiModuleDTO;
|
import io.metersphere.api.dto.definition.ApiModuleDTO;
|
||||||
|
@ -12,11 +13,9 @@ import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiModuleMapper;
|
import io.metersphere.base.mapper.ext.ExtApiModuleMapper;
|
||||||
import io.metersphere.commons.constants.TestCaseConstants;
|
import io.metersphere.commons.constants.TestCaseConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.service.NodeTreeService;
|
import io.metersphere.service.NodeTreeService;
|
||||||
import io.metersphere.service.ProjectService;
|
import io.metersphere.service.ProjectService;
|
||||||
import io.metersphere.track.dto.TestCaseNodeDTO;
|
|
||||||
import io.metersphere.track.service.TestPlanApiCaseService;
|
import io.metersphere.track.service.TestPlanApiCaseService;
|
||||||
import io.metersphere.track.service.TestPlanProjectService;
|
import io.metersphere.track.service.TestPlanProjectService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -148,7 +147,19 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
|
|
||||||
private void checkApiModuleExist(ApiModule node) {
|
private void checkApiModuleExist(ApiModule node) {
|
||||||
if (node.getName() != null) {
|
if (node.getName() != null) {
|
||||||
if (selectSameModule(node).size() > 0) {
|
ApiModuleExample example = new ApiModuleExample();
|
||||||
|
ApiModuleExample.Criteria criteria = example.createCriteria();
|
||||||
|
criteria.andNameEqualTo(node.getName())
|
||||||
|
.andProjectIdEqualTo(node.getProjectId());
|
||||||
|
if (StringUtils.isNotBlank(node.getParentId())) {
|
||||||
|
criteria.andParentIdEqualTo(node.getParentId());
|
||||||
|
} else {
|
||||||
|
criteria.andParentIdIsNull();
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(node.getId())) {
|
||||||
|
criteria.andIdNotEqualTo(node.getId());
|
||||||
|
}
|
||||||
|
if (apiModuleMapper.selectByExample(example).size() > 0) {
|
||||||
MSException.throwException(Translator.get("test_case_module_already_exists") + ": " + node.getName());
|
MSException.throwException(Translator.get("test_case_module_already_exists") + ": " + node.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,6 +227,18 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiModuleDTO getNode(String id) {
|
||||||
|
ApiModule module = apiModuleMapper.selectByPrimaryKey(id);
|
||||||
|
ApiModuleDTO dto = JSON.parseObject(JSON.toJSONString(module), ApiModuleDTO.class);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePos(String id, Double pos) {
|
||||||
|
extApiModuleMapper.updatePos(id, pos);
|
||||||
|
}
|
||||||
|
|
||||||
public void dragNode(DragModuleRequest request) {
|
public void dragNode(DragModuleRequest request) {
|
||||||
|
|
||||||
checkApiModuleExist(request);
|
checkApiModuleExist(request);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.api.service;
|
package io.metersphere.api.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||||
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
|
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
|
||||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||||
|
@ -17,7 +18,6 @@ import io.metersphere.service.NodeTreeService;
|
||||||
import io.metersphere.service.ProjectService;
|
import io.metersphere.service.ProjectService;
|
||||||
import io.metersphere.track.service.TestPlanProjectService;
|
import io.metersphere.track.service.TestPlanProjectService;
|
||||||
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
||||||
import io.metersphere.track.service.TestPlanTestCaseService;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
@ -186,6 +186,18 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiScenarioModuleDTO getNode(String id) {
|
||||||
|
ApiScenarioModule module = apiScenarioModuleMapper.selectByPrimaryKey(id);
|
||||||
|
ApiScenarioModuleDTO dto = JSON.parseObject(JSON.toJSONString(module), ApiScenarioModuleDTO.class);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePos(String id, Double pos) {
|
||||||
|
extApiScenarioModuleMapper.updatePos(id, pos);
|
||||||
|
}
|
||||||
|
|
||||||
public void dragNode(DragApiScenarioModuleRequest request) {
|
public void dragNode(DragApiScenarioModuleRequest request) {
|
||||||
|
|
||||||
checkApiScenarioModuleExist(request);
|
checkApiScenarioModuleExist(request);
|
||||||
|
|
|
@ -8,5 +8,8 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ExtApiModuleMapper {
|
public interface ExtApiModuleMapper {
|
||||||
int insertBatch(@Param("records") List<ApiModule> records);
|
int insertBatch(@Param("records") List<ApiModule> records);
|
||||||
|
|
||||||
List<ApiModuleDTO> getNodeTreeByProjectId(@Param("projectId") String projectId, @Param("protocol") String protocol);
|
List<ApiModuleDTO> getNodeTreeByProjectId(@Param("projectId") String projectId, @Param("protocol") String protocol);
|
||||||
|
|
||||||
|
void updatePos(String id, Double pos);
|
||||||
}
|
}
|
|
@ -19,6 +19,10 @@
|
||||||
from api_module
|
from api_module
|
||||||
where api_module.project_id = #{projectId}
|
where api_module.project_id = #{projectId}
|
||||||
and api_module.protocol = #{protocol}
|
and api_module.protocol = #{protocol}
|
||||||
order by create_time asc
|
order by api_module.pos asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="updatePos">
|
||||||
|
update api_module set pos = #{pos} where id = #{id}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
|
@ -7,4 +7,6 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ExtApiScenarioModuleMapper {
|
public interface ExtApiScenarioModuleMapper {
|
||||||
List<ApiScenarioModuleDTO> getNodeTreeByProjectId(@Param("projectId") String projectId);
|
List<ApiScenarioModuleDTO> getNodeTreeByProjectId(@Param("projectId") String projectId);
|
||||||
|
|
||||||
|
void updatePos(String id, Double pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
<include refid="io.metersphere.base.mapper.ApiScenarioModuleMapper.Base_Column_List"/>
|
<include refid="io.metersphere.base.mapper.ApiScenarioModuleMapper.Base_Column_List"/>
|
||||||
from api_scenario_module
|
from api_scenario_module
|
||||||
where api_scenario_module.project_id = #{projectId}
|
where api_scenario_module.project_id = #{projectId}
|
||||||
order by create_time asc
|
order by api_scenario_module.pos asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="updatePos">
|
||||||
|
update api_scenario_module set pos = #{pos} where id = #{id}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
|
@ -0,0 +1,3 @@
|
||||||
|
set @rownum=0;
|
||||||
|
update api_module set pos=(select @rownum := @rownum +1) where pos is null;
|
||||||
|
update api_scenario_module set pos=(select @rownum := @rownum +1) where pos is null;
|
|
@ -154,8 +154,9 @@
|
||||||
},
|
},
|
||||||
drag(param, list) {
|
drag(param, list) {
|
||||||
this.$post("/api/automation/module/drag", param, () => {
|
this.$post("/api/automation/module/drag", param, () => {
|
||||||
// this.$post("/api/module/pos", list); //todo 排序
|
this.$post("/api/automation/module/pos", list, () => {
|
||||||
this.list();
|
this.list();
|
||||||
|
});
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
this.list();
|
this.list();
|
||||||
});
|
});
|
||||||
|
|
|
@ -160,8 +160,9 @@
|
||||||
},
|
},
|
||||||
drag(param, list) {
|
drag(param, list) {
|
||||||
this.$post("/api/module/drag", param, () => {
|
this.$post("/api/module/drag", param, () => {
|
||||||
// this.$post("/api/module/pos", list); //todo 排序
|
this.$post("/api/module/pos", list, () => {
|
||||||
this.list();
|
this.list();
|
||||||
|
});
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
this.list();
|
this.list();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue