package com.njcn.enums.app;

/**
 * @author hongawen
 * @date: 2019/10/17 14:07
 *
 * 用户返回标识枚举
 */
public enum UserCodeEnum {


    LOGIN_SUCCESS(10002,"登录成功"),
    LOGIN_FAIL(10003,"登录失败"),
    LOGIN_WRONG_PWD(10004,"用户名密码错误"),
    LOGIN_LOCKED(10005,"用户被锁定"),
    KEY_WRONG(10006,"登录密码/验证码为空"),
    PHONE_WRONG(10007,"手机号非法"),
    DEVCODE_WRONG(10008,"设备码非法"),
    CODE_WRONG(10009,"验证码为空"),
    USERID_WRONG(10010,"用户索引非法"),
    PASSWORD_WRONG(10011,"密码非法"),
    REGIST_SUCCESS(10012,"注册成功"),
    REGIST_FAIL(10013,"注册失败"),
    REGIST_PHONE_FAIL(10014,"该号码已注册"),
    SETPWD_SUCCESS(10015,"设置密码成功"),
    SETPWD_FAIL(10016,"设置密码失败"),
    RESETPWD_SUCCESS(10017,"重置密码成功"),
    RESETPWD_FAIL(10018,"重置密码失败"),
    REFERRAL_CODE_ERROR(10019,"推荐码非法"),
    UPDATE_ROLE_SUCCESS(10020,"角色升级成功"),
    UPDATE_ROLE_FAIL(10021,"角色升级失败"),
    CODE_TYPE_ERROR(10022,"验证码类型非法"),
    SEND_CODE_SUCCESS(10023,"验证码发送成功"),
    SEND_CODE_FAIL(10024,"验证码发送失败"),
    CODE_ERROR(10025,"验证码错误"),
    REST_PHONE_SUCCESS(10026,"重置手机号成功"),
    REST_PHONE_FAIL(10027,"重置手机号失败"),
    NO_APPINFOSET(10028,"用户无消息配置"),
    SET_INFO_SUCCESS(10029,"用户设置消息成功"),
    SET_INFO_FAIL(10030,"用户设置消息失败"),

    NO_USER(10031,"用户不存在"),
    NO_MAIN_USER(10032,"用户缺失系统账户"),
    NO_USER_SETTING(10033,"用户缺失配置信息"),
    GET_MESSAGE_SUCCESS(10034,"获取消息配置成功"),
    GET_MESSAGE_FAIL(10035,"获取消息配置失败"),
    MESSAGE_CODE_RIGHT(10036,"验证码正确"),
    MESSAGE_CODE_WRONG(10037,"验证码错误"),

    NO_USER_FOCUS(10038,"无用户关注"),
    EVENT_MSG_SUCCESS(10039,"暂态消息推送成功"),
    EVENT_MSG_FAIL(10040,"暂态消息推送失败"),
    REPEAT_EVENT_INFO(10041,"该事件已推送"),

    STEADY_MSG_SUCCESS(10039,"稳态消息推送成功"),
    STEADY_MSG_FAIL(10040,"稳态消息推送失败"),

    INVALID_PARAMETER(10041,"参数非法"),

    DEVICE_MSG_SUCCESS(10039,"终端消息推送成功"),
    DEVICE_MSG_FAIL(10040,"终端消息推送失败"),

    ;

    private int code;

    private String msg;

    UserCodeEnum(int code,String msg){
        this.code=code;
        this.msg=msg;
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }

    public static String getMsgByCode(int code){
        for (UserCodeEnum userCodeEnum : UserCodeEnum.values()) {
            if (userCodeEnum.code==code) {
                return userCodeEnum.msg;
            }
        }
        return "";
    }


    public static int getCodeByMsg(String msg){
        for (UserCodeEnum userCodeEnum : UserCodeEnum.values()) {
            if (userCodeEnum.msg.equalsIgnoreCase(msg)) {
                return userCodeEnum.code;
            }
        }
        return 0;
    }
}
