package cn.estsh.i3plus.pojo.base.enumutil;

/**
 * @Description : 系统资源匹配，此枚举中所有的值都需要持久化在资源表中，并且不能删除
 * @Reference :
 * @Author : alwaysfrin
 * @CreateDate : 2018-09-12 14:32
 * @Modify:
 **/
public class ResourceEnumUtil {

    /**
     * 异常对应
     */
    public enum EXCEPTION {
        NOT_NULL("10001", "不为空"),
        NEED_NULL("10002", "需要为空"),
        NEED_TRUE("10003", "需要为True"),
        NEED_FALSE("10004", "需要为False"),
        LOWER_NUM("10005", "小于最小值"),
        OVER_NUM("10006", "大于最大值"),
        NUM_NOT_EQUAL("10007", "字符值不相同"),
        STRING_NOT_EQUAL("10008", "数字值不相同"),
        OVER_SIZE("10009", "长度超出"),
        NOT_ZERO("10010", "不能为0"),
        CLOUD_CRAP("10011", "无法使用服务");

        private String code;
        private String description;

        EXCEPTION(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }


    /**
     * 消息对应
     */
    public enum MESSAGE {
        SUCCESS("20001", "成功"),
        FAIL("20002", "失败"),
        EMPTY("20003", "数据不存在");

        private String code;
        private String description;

        MESSAGE(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }
}
