|
|
|
@@ -1,6 +1,8 @@ |
|
|
|
package com.ruoyi.platform.service.impl; |
|
|
|
|
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
|
import com.ruoyi.platform.annotations.CheckDuplicate; |
|
|
|
import com.ruoyi.platform.domain.Dataset; |
|
|
|
import com.ruoyi.platform.domain.Experiment; |
|
|
|
import com.ruoyi.platform.domain.Workflow; |
|
|
|
import com.ruoyi.platform.mapper.WorkflowDao; |
|
|
|
@@ -18,6 +20,7 @@ import org.springframework.data.domain.PageRequest; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
@@ -191,7 +194,34 @@ public class WorkflowServiceImpl implements WorkflowService { |
|
|
|
} |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void checkDeclaredName(Workflow insert) throws Exception { |
|
|
|
List<Workflow> existingWorkflowList = workflowDao.queryByName(insert.getName()); |
|
|
|
|
|
|
|
Workflow existingWorkflow = existingWorkflowList.stream().findFirst().orElse(null); |
|
|
|
if (existingWorkflow != null) { |
|
|
|
// 检查找到的流水线是否与要插入的流水线相同 |
|
|
|
if (insert.getId() != null && insert.getId().equals(existingWorkflow.getId())) { |
|
|
|
// 这是相同的流水线,更新操作中没有重复名称问题 |
|
|
|
return; |
|
|
|
} |
|
|
|
// 现在我们知道还有另一个具有相同名称的流水线 |
|
|
|
Field[] fields = Workflow.class.getDeclaredFields(); |
|
|
|
for (Field field : fields) { |
|
|
|
field.setAccessible(true); // 使私有字段可访问 |
|
|
|
if ("name".equals(field.getName()) && field.isAnnotationPresent(CheckDuplicate.class)) { |
|
|
|
// 如果字段是“name”并且标记了CheckDuplicate注解 |
|
|
|
CheckDuplicate annotation = field.getAnnotation(CheckDuplicate.class); |
|
|
|
throw new Exception("重复的流水线名称: " + insert.getName() + ". " + annotation.message()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |