package com.cool.store.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 *  * 通用错误返回处理，后续全部将使用这个返回，请遵守以下规范。
 *  * 1.枚举名必须要大写。
 *  * 2.枚举中包含属性：code,msg,en(英文尽量写)
 *  * 3.code的命名以系统模块划分，前三位为模块划分。逐级细分。（7位数字先到先取原则，细化不浪费）
 * @author zhangchenbiao
 * @FileName: ErrorCodeEnum
 * @Description: 返回响应状态和文案枚举
 * @date 2023-05-19 04:30
 */
public enum ErrorCodeEnum {

    /**
     * 000000 未知错误
     */
    UNKNOWN(000000, "未知错误", null),
    /**
     * 2000001 token与当前登录企业不匹配
     */
    TOKEN_ERROR(2000001,"请求异常，与当前登录企业不匹配",null),
    FAIL(400000, "FAIL", null),
    ACCESS_TOKEN_INVALID(400005, "Invalid token", null),
    PARAMS_VALIDATE_ERROR(400003, "参数校验失败！", null),
    LOGIN_ERROR(400004, "登录失败", null),
    ENTERPRISE_INIT(400006, "企业正在初始化，请稍后访问！",null),
    NOT_AUTH(400007, "暂无权限，请联系管理员！", null),
    USER_FREEZE(1021019,"账号被冻结，请联系管理员",null),
    ENTERPRISE_NOT_EXIST(1021020,"企业不存在",null),
    USER_NOT_EXIST(1021021,"用户不存在",null),
    USER_WAIT_AUDIT(1021018,"账号审核中，请联系企业管理员",null),
    OPERATION_OVER_TIME(1021019, "您的操作过于频繁,休息一下~", null),
    GET_APP_SECRET_ERROR(1021020, "获取secret异常", null),
    WX_SERVICE_ERROR(1021021, "调用微信服务异常", null),
    SESSION_KEY_ERROR(1021022, "sessionKey过期", null),
    GET_WECHAT_USER_INFO_FAIL(1021023,"获取小程序用户信息失败", null),
    FEISHU_SERVICE_ERROR(1021024,"飞书服务调用异常", null),
    USER_GROUP_NAME_EXIST(1021076, "用户分组名称已存在", null),
    USER_GROUP_NOT_EXIST(1021077, "用户分组不存在", null),
    GET_INFO_ERROR(1021078, "获取信息异常", null),
    GET_PHONENUMBER_INFO_ERROR(1021079, "手机号归属地获取异常", null),
    IDENTITY_CARD_PARSE_FAIL(1021080, "身份证解析失败", null),
    WECHAT_BIND_OTHER_MOBILE(1021081, "该微信已绑定其它手机号，请核对", null),
    PARAMS_REQUIRED(400002, "参数缺失！", null),
    DATA_CONVERT_ERROR(400002, "日期转换异常！", null),
    PARENT_NODE_NOT_EXIST(400002, "父节点不存在", null),


    LINE_ID_IS_NOT_EXIST(500001, "线索信息不存在！", null),
    WORK_FLOW_STAGE_PASS_ERROR(500002, "通过错误，非对应阶段！", null),
    PARTNER_USER_NOT_EXIST(500003, "加盟商用户信息不存在！", null),
    ZONE_NOT_EXIST(500004, "战区不存在！", null),
    PARTNER_BASEINFO_NOT_EXIST(500005, "基本信息不存在！", null),
    INTENT_INFO_NOT_EXIST(500006, "意向信息不存在！", null),
    INTENT_AREA_NOT_BING_ZONE(500007, "意向区域没有绑定战区 分配招商经理失败！", null),
    PUBLIC_LINE_NOT_OPERATE(500008, "公海线索不允许操作！", null),
    PARTNER_BASE_INFO_NOT_EXIST(500009, "加盟商信息不存在！", null),

    INTERVIEW_ENTER_FAIL(1021101, "进入面试间失败", null),
    DINGDING_USER_NOT_EXIST(1021102, "用户钉钉信息不存在，无法发起资质审核！", null),
    INTERVIEW_NOT_EXIST(1021103, "面试信息不存在！", null),
    INTERVIEW_AND_PARTNER_ID_IS_NULL(1021104, "加盟商用户ID&线索ID和面试官ID不能同时为空！", null),
    INTERVIEW_PLAN_IS_NULL(1021105, "未查询到相关面试安排！", null),
    DATE_PARAMS_IS_ERROR(1021106, "日期参数错误！", null),
    INTERVIEW_PLAN_NOT_EXIST(1021107, "面试计划不存在！", null),
    FEISHU_DELETE_SCHEDULE_ERROR(1021108, "删除原面试安排失败！", null),
    CREATE_CALENDAR_EVENT_FAIL(1021109, "创建面试安排失败！", null),
    FEISHU_UPDATE_SCHEDULE_ERROR(1021110, "修改面试安排失败！", null),
    INTERVIEW_STATUS_ERROR(1021111, "当前面试状态不允许该操作！", null),
    INTERVIEW_PLAN_ALREADY_EXIST(1021112, "面试计划已存在，请勿重复申请！", null),
    INTERVIEW_LINE_ID_IS_NULL(1021113, "线索id为空！", null),
    INTERVIEW_INTERVIEW_TIME_IS_UNUSABLE(1021114, "当前预约时间不可用，请和线索用户协商其他时间后确定预约时间\n面试人：{0} 手机号：{1}", null),
    INTERVIEW_PARTNER_NOT_EXIST(1021115, "线索下的加盟商不存在！", null),
    ROOM_STATUS_ERROR(10211156, "当前面试房间状态不允许进行该操作！", null),
    CONTENT_DUPLICATED(10211200, "动态标题重复！", null),
    SIGN_FAIL(600000, "验签失败", null),
    GET_ACCESSTOKEN_ERROR(600001, "获取小程序TOKEN错误！", null),
    NEW_MOBILE_HAS_EXIST(600002,"加盟商用户信息已存在",null),
    INSPECTION_USER_OCCUPY(600002,"当前稽核人已经配置其他战区",null),
    INSPECTION_INFO_NOT_EXIST(600005, "稽核信息不存在！", null),
    OPEN_AREA_NULL(600006,"归属地区不能为空",null),
    ;



    protected static final Map<Integer, ErrorCodeEnum> map = Arrays.stream(values()).collect(
            Collectors.toMap(ErrorCodeEnum::getCode, Function.identity(), (a, b)->a));
    private int code;

    private String message;
    private String en;

    ErrorCodeEnum(int code, String message, String en) {
        this.code = code;
        this.message = message;
        this.en=en;
    }


    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErrorCodeEnum getByCode(Integer code) {
        return map.get(code);
    }


}
