模版新增修改关联的相关实现
This commit is contained in:
@@ -6,6 +6,13 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 示例模块 1-001-000-000 ==========
|
||||
ErrorCode TMPL_TP_NOT_EXISTS = new ErrorCode(1_027_000_500, "模板分类不存在");
|
||||
ErrorCode TMPL_FLD_NOT_EXISTS = new ErrorCode(1_027_000_501, "模板字段不存在");
|
||||
ErrorCode TMPL_FLD_CODE_EXISTS = new ErrorCode(1_027_000_502, "字段编码已存在");
|
||||
ErrorCode TMPL_ITM_NOT_EXISTS = new ErrorCode(1_027_000_503, "模板条款不存在");
|
||||
ErrorCode TEMPLATE_INSTANCE_NOT_EXISTS = new ErrorCode(1_027_000_504, "模板实例不存在");
|
||||
ErrorCode TMPL_TP_SATUS_ERROR = new ErrorCode(1_027_000_506, "状态变更失败");
|
||||
ErrorCode TMPL_TP_DEl_ERROR = new ErrorCode(1_027_000_507, "模版分类删除失败");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.tmpltp.enums;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 状态枚举类,定义所有可能的状态及合法的状态转换
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
// 定义所有状态及对应的合法转换目标状态
|
||||
STATUS_1("1", new HashSet<String>() {{
|
||||
add("2");
|
||||
add("4");
|
||||
}}),
|
||||
STATUS_2("2", new HashSet<String>() {{
|
||||
add("3");
|
||||
}}),
|
||||
STATUS_3("3", new HashSet<String>() {{
|
||||
add("4");
|
||||
add("2");
|
||||
}}),
|
||||
STATUS_4("4", new HashSet<>()); // 没有合法的转换目标
|
||||
|
||||
private final String code;
|
||||
private final Set<String> allowedTransitions;
|
||||
|
||||
StatusEnum(String code, Set<String> allowedTransitions) {
|
||||
this.code = code;
|
||||
this.allowedTransitions = allowedTransitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态码获取对应的枚举实例
|
||||
*/
|
||||
public static StatusEnum fromCode(String code) {
|
||||
for (StatusEnum status : values()) {
|
||||
if (status.code.equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验状态转换是否合法
|
||||
*/
|
||||
public boolean isTransitionAllowed(String targetStatus) {
|
||||
return allowedTransitions.contains(targetStatus);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user