杜洪波
2026-03-24 616ca0caf25685efec6094686f01c0413f869af9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.product.saas.config;
 
import java.text.DecimalFormat;
import java.text.Format;
 
import com.product.common.enums.IEnum;
import com.product.common.enums.ModuleEnum;
import com.product.core.config.Global;
import com.product.util.BaseUtil;
 
public enum SaasCode implements IEnum{
 
    // 租户申请
    TENANT_APPLY_VALID_UNIT_HAS_APPLY("租户单位已经用于申请", 1),
    TENANT_APPLY_VALID_PHONE_HAS_APPLY("租户手机号已经用于申请", 2),
    TENANT_APPLY_VALID_UNIT_AND_PHONE_HAS_APPLY("租户单位和手机号已经用于申请", 3),
    TENANT_APPLY_VALID_INFO_FAIL("租户申请信息验证失败:", 4),
    TENANT_AAPLY_INFO_GET_FAIL("租户申请信息请求失败:", 5),
    TENANT_AAPLY_INFO_SUBMIT_FAIL("租户申请信息提交失败:", 6),
    TENANT_AAPLY_INFO_FLOW_TASK_ERROR("租户申请信息流程数据不存在", 7),
    TENANT_AAPLY_INFO_CANCEL_FAIL("租户申请信息撤消失败:", 8),
    TENANT_APPLY_LICENSE_DATA_NO_EXIST("租户申请License数据不存在", 9),
    TENANT_APPLY_LICENSE_FILE_NO_EXIST("租户申请License文件不存在", 10),
    TENANT_APPLY_LICENSE_FILE_COPY_FAIL("租户申请License文件COPY失败", 11),
    
    // 租户信息
    TENANT_INFO_GET_LIST_FAIL("租户信息列表查询失败", 12),
    ;
    
    private String text;
    private int value;
 
    private SaasCode(String text, int value) {
        this.text = text;
        this.value = value;
    }
 
    public String getText() {
        try {
            //使用正则匹配text中的特殊表达式以{&开头,&}结尾,获取到其中的内容
            String regex = "\\{&(.+?)&\\}";
            String result = this.text;
            if (this.text.matches(regex)) {
                result = this.text.replaceAll(regex, "$1");
            }
            String defaultValue = null;
            //截取result中以(开头,)结尾的内容
            if (result.contains("(") && result.contains(")")) {
                defaultValue = result.substring(0, result.indexOf("("));
            }
            //去掉result中 (开头,)结尾的内容 包含括号
            result = result.replaceAll("\\(.*?\\)", "");
            //获取系统配置中的值
            return BaseUtil.ifNull(Global.getSystemConfig(result, defaultValue), text);
        } catch (Exception e) {
            return text;
        }
    }
 
    public String getValue() {
        Format format = new DecimalFormat("000");
        return ModuleEnum.SAAS.getValue() + format.format(this.value);
    }
}