You've already forked DataMate
bugfix: 创建清洗任务时修改数据集状态;无法删除已在模板/运行任务的算子
* bugfix: 创建清洗任务时修改数据集状态;无法删除已在模板/运行任务的算子
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -16,4 +16,6 @@ public interface OperatorRepository extends IRepository<Operator> {
|
||||
void deleteOperator(String id);
|
||||
|
||||
int countOperatorByStar(boolean isStar);
|
||||
|
||||
boolean operatorInTemplateOrRunning(String operatorId);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user