package com.ankaibei.workFlow.webadmin.ankaibei.enums;

/**
 * @ClassName: AgentCodeEnum
 * @author:
 * @date: 2019/10/01
 * @Copyright: 2019
 */
public enum CodeEnum {
    //根据业务逻辑往下排
    OK("200", "请求成功"),
    PARAM_IS_NULL("202", "参数为空"),
    NO_DATA("203", "无数据"),
    FAIL("204", "失败"),
    ACCOUNT_NO_PASSWORD_ERROR("205", "用户名或密码错误"),
    MULTIPLE_DUPLICATE_ACCOUNTS_ARE_FOUND("206", "查询到多个重复账号"),
    TNE_PROJECT_TEAM_NAME_ALREADY_EXISTS("207", "项目组名称已存在"),
    THE_JOB_ID_ALREADY_EXISTS("208", "工号已存在"),
    PHONE_ALREADY_EXISTS("209", "手机号已存在"),
    TNE_PROJECT_NAME_ALREADY_EXISTS("210", "项目名称已存在"),
    PLEASE_LOG_IN_AGAIN("211", "请重新登陆"),
    PROJECT_TEAM_HAS_BEEN_ESTABLISHED_FOR_THE_PROJECT("212", "该项目已成立项目组"),
    TASK_ALREADY_EXISTS("213", "任务名称已存在"),
    DATA_VALIDATED_FAILED("90052","数据验证失败，请核对！"),
    ;


    private final String code;
    private final String reason;

    CodeEnum(final String statusCode, final String reasonPhrase) {
        this.code = statusCode;
        this.reason = reasonPhrase;
    }

    /**
     * Convert a numerical status code into the corresponding Status
     *
     * @param statusCode the numerical status code
     * @return the matching Status or null is no matching Status is defined
     */
    public static CodeEnum fromCode(final String statusCode) {
        for (CodeEnum s : CodeEnum.values()) {
            if (s.code.equals(statusCode)) {
                return s;
            }
        }
        return null;
    }

    /**
     * Get the associated status code
     *
     * @return the status code
     */
    public String getCode() {
        return code;
    }

    /**
     * Get the reason phrase
     *
     * @return the reason phrase
     */
    @Override
    public String toString() {
        return reason;
    }
}
