Просмотр исходного кода

fix: 流水线名称不允许重复

370774330@qq.com 5 лет назад
Родитель
Сommit
6f88a12935

+ 3 - 0
web/src/main/java/cn/seecoder/web/dao/pipeline/PipelineMapper.java

@@ -23,6 +23,9 @@ public interface PipelineMapper {
     @Select("select * from pipeline where id = #{id}")
     PipelinePO selectById(Integer id);
 
+    @Select("select * from pipeline where name = #{name} and project_id = #{projectId}")
+    PipelinePO selectByNameAndProjectId(@Param("name") String name,@Param("projectId") Integer projectId);
+
     @Select("select * from pipeline where project_id = #{id}")
     List<PipelinePO> selectByProjectId(Integer id);
 

+ 3 - 0
web/src/main/java/cn/seecoder/web/service/impl/pipeline/PipelineServiceImpl.java

@@ -97,6 +97,9 @@ public class PipelineServiceImpl implements PipelineService {
     @Override
     public void createPipelineConfig(PipelineCreateVO pipelineCreateVO) throws ServiceException {
         //projectAuthentication(pipelineCreateVO.getProjectId());
+        if (pipelineMapper.selectByNameAndProjectId(pipelineCreateVO.getName(), pipelineCreateVO.getProjectId())!=null){
+            throw new ServiceException("流水线名称已存在,请更换名称。");
+        }
         PipelinePO pipeline;
         try {
             pipeline = PipelinePO.builder()