content: /*
   * 爱组搭，低代码组件化开发平台
   * ------------------------------------------
   * 受知识产权保护，请勿删除版权申明，开发平台不允许做非法网站，后果自负
   */
  package com.aizuda.core.api;
  
  /**
   * <a href="http://aizuda.com">爱组搭</a>低代码组件化开发平台
   * ----------------------------------------
   * REST API 错误码
   *
   * @author 青苗
   * @since 1.1.0
   */
  public enum ApiErrorCode implements IErrorCode {
      /**
       * 失败
       */
      FAILED(-1, "操作失败"),
      /**
       * 票据过期
       */
      TOKEN_EXPIRED(1, "授权票据过期"),
      /**
       * 刷新票据过期
       */
      REFRESH_TOKEN_EXPIRED(2, "刷新票据过期"),
      /**
       * 成功
       */
      SUCCESS(200, "执行成功");
  
      private final long code;
      private final String msg;
  
      ApiErrorCode(final long code, final String msg) {
          this.code = code;
          this.msg = msg;
      }
  
      public static ApiErrorCode fromCode(long code) {
          ApiErrorCode[] ecs = ApiErrorCode.values();
          for (ApiErrorCode ec : ecs) {
              if (ec.getCode() == code) {
                  return ec;
              }
          }
          return SUCCESS;
      }
  
      @Override
      public long getCode() {
          return code;
      }
  
      @Override
      public String getMsg() {
          return msg;
      }
  
      @Override
      public String toString() {
          return String.format(" ErrorCode:{code=%s, msg=%s} ", code, msg);
      }
  }
  