• java工具类6-错误返回码ErrorCode


    ErrorCode:

    public class ErrorCode {
    
        /**
         * 公共错误码<br/>
         * 码段:10000~10099
         *
         *
         */
        public enum CommonError implements IErrorCode {
            SUCCESS("0", "success"),
            UNKNOWN_ERROR("10000", "未知错误"),
            SYSTEM_ERROR("10001", "系统处理异常"),
            REQUEST_ERROR("10002", "请求地址或参数错误"),
            DB_PROCESS_FAILED("10003", "数据库处理失败"),
            DATA_NOT_FOUND("10004", "数据不存在"),
            PARAM_REQUIRED("10005", "参数必填[%s]"),
            PARAM_ILLEGAL("10006", "参数格式错误[%s]"),
            FILE_PROCESS_ERROR("10007", "文件处理失败"),
            FILE_SAVE_FAILED("10008", "文件保存失败"),
            FILE_GET_FAILED("10009", "文件获取失败"),
            LOGIN_TIMEOUT("10010", "登录超时,请重新登录!"),
            NO_PERMISSION("10011", "无访问权限");
    
            private String code;
            private String msg;
    
            private CommonError(String code, String msg) {
                this.code = code;
                this.msg = msg;
            }
    
            @Override
            public String getCode() {
                return this.code;
            }
    
            @Override
            public String getMsg() {
                return this.msg;
            }
        }
    
        /**
         * 通用业务-系统用户<br/>
         * 码段:10100~10199
         *
         */
        public enum SystemUserError implements IErrorCode {
            USER_NAME_EXISTS("10100", "用户名已存在"),
            USER_NAME_NOT_EXISTS("10101", "用户名不存在"),
            PASSWORD_INCORRECT("10102", "密码错误"),
            LOGIN_FAILED("10103", "登录失败,用户名或密码错误"),
            OLD_PASSWORD_ERROR("10104", "旧密码错误"),;
    
            private String code;
            private String msg;
    
            private SystemUserError(String code, String msg) {
                this.code = code;
                this.msg = msg;
            }
    
            @Override
            public String getCode() {
                return this.code;
            }
    
            @Override
            public String getMsg() {
                return this.msg;
            }
    
        }
    
        /**
         * 具体业务-客户<br/>
         * 码段:20100~20199
         *
         */
        public enum CustomerError implements IErrorCode {
            CUSTOMER_NUMBER_EXISTS("20100", "客户编号已存在"),
            CARD_NUMBER_EXISTS("20101", "证件号码已存在"),;
    
            private String code;
            private String msg;
    
            private CustomerError(String code, String msg) {
                this.code = code;
                this.msg = msg;
            }
    
            @Override
            public String getCode() {
                return this.code;
            }
    
            @Override
            public String getMsg() {
                return this.msg;
            }
    
        }
        
        /**
         * 具体业务-终端<br/>
         * 码段:20200~20299
         *
         */
        public enum EquipmentError implements IErrorCode {
            EQUIPMENT_NUMBER_EXISTS("20200", "终端编号已存在"),;
    
            private String code;
            private String msg;
    
            private EquipmentError(String code, String msg) {
                this.code = code;
                this.msg = msg;
            }
    
            @Override
            public String getCode() {
                return this.code;
            }
    
            @Override
            public String getMsg() {
                return this.msg;
            }
    
        }
    }

    IErrorCode:

    public interface IErrorCode {
        /**
         * 获取错误编码<br/>
         * 
         * @return
         */
        String getCode();
    
        /**
         * 获取错误信息<br/>
         * 
         * @return
         */
        String getMsg();
    
    }
  • 相关阅读:
    试试用有限状态机的思路来定义javascript组件
    利用grunt-contrib-connect和grunt-connect-proxy搭建前后端分离的开发环境
    利用bootstrap的modal组件自定义alert,confirm和modal对话框
    利用轮播原理结合hammer.js实现简洁的滑屏功能
    等高分栏布局小结
    圣杯布局小结
    浏览器缓存知识小结及应用
    基于淘宝弹性布局方案lib-flexible的问题研究
    淘宝弹性布局方案lib-flexible实践
    Js位置与大小(1)——正确理解和运用与尺寸大小相关的DOM属性
  • 原文地址:https://www.cnblogs.com/chong-zuo3322/p/12855304.html
Copyright © 2020-2023  润新知