bugfix: 创建清洗任务时修改数据集状态;无法删除已在模板/运行任务的算子

* bugfix: 创建清洗任务时修改数据集状态;无法删除已在模板/运行任务的算子
This commit is contained in:
hhhhsc701
2025-11-27 17:34:53 +08:00
committed by GitHub
parent 91390cace0
commit f1bffdcd61
15 changed files with 46 additions and 15 deletions

View File

@@ -88,6 +88,9 @@ public class OperatorService {
@Transactional
public void deleteOperator(String id) {
if (operatorRepo.operatorInTemplateOrRunning(id)) {
throw BusinessException.of(OperatorErrorCode.OPERATOR_IN_INSTANCE);
}
operatorRepo.deleteOperator(id);
relationRepo.deleteByOperatorId(id);
}

View File

@@ -16,4 +16,6 @@ public interface OperatorRepository extends IRepository<Operator> {
void deleteOperator(String id);
int countOperatorByStar(boolean isStar);
boolean operatorInTemplateOrRunning(String operatorId);
}

View File

@@ -16,7 +16,9 @@ public enum OperatorErrorCode implements ErrorCode {
FIELD_NOT_FOUND("op.0003", "缺少必要的字段"),
SETTINGS_PARSE_FAILED("op.0004", "settings字段解析失败");
SETTINGS_PARSE_FAILED("op.0004", "settings字段解析失败"),
OPERATOR_IN_INSTANCE("op.0005", "算子已被编排在模板或未完成的任务中");
private final String code;
private final String message;

View File

@@ -43,4 +43,9 @@ public class OperatorRepositoryImpl extends CrudRepository<OperatorMapper, Opera
queryWrapper.eq(Operator::getIsStar, isStar);
return Math.toIntExact(mapper.selectCount(queryWrapper));
}
@Override
public boolean operatorInTemplateOrRunning(String operatorId) {
return mapper.operatorInTemplate(operatorId) > 0 && mapper.operatorInUnstopTask(operatorId) > 0;
}
}

View File

@@ -3,7 +3,16 @@ package com.datamate.operator.infrastructure.persistence.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.datamate.operator.domain.model.Operator;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface OperatorMapper extends BaseMapper<Operator> {
@Select("SELECT count(1) FROM t_operator_instance oi JOIN t_clean_template t ON oi.instance_id = t.id " +
"WHERE oi.operator_id = #{operatorId}")
int operatorInTemplate(String operatorId);
@Select("SELECT count(1) FROM t_operator_instance oi JOIN t_clean_task t ON oi.instance_id = t.id " +
"WHERE oi.operator_id = #{operatorId} AND t.status != 'COMPLETED'")
int operatorInUnstopTask(String operatorId);
}