var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class RejAPI extends APIBase {
  constructor() {
    super()
    this.cagentcbSve = system.getObject("service.reportcb.cagentcbSve");
  }

  async getRejDataCb (pobj, q, req) {
    try {
      let a = 'TESTAGENTCB'
      let result = await this.cagentcbSve.getRejData();
      if (result.count) {
        result.code = 200
        result.msg = "数据获取成功"
      } else {
        result.code = 201
        result.msg = "无数据"
      }
      return result
    } catch (error) {
      console.log('get err')
      console.log(error)
      return {
        code: -1,
        msg: error.message
      }
    }
  }

  async changeStatusCb (pobj, q, req) {
    try {
      await this.cagentcbSve.changeStatus(pobj)
      return {
        code: 200,
        msg: "处理提报进度成功"
      }
    } catch (error) {
      console.log('change err')
      console.log(error)
      return {
        code: -1,
        msg: error.message
      }
    }
  }

  async pushBcStatus (pobj, q, req) {
    try {
      this.cagentcbSve.saveBcData(pobj)
      return {
        code: 200,
        msg: "商标局状态处理成功"
      }
    } catch (error) {
      console.log('bc err')
      console.log(error)
      return {
        code: -1,
        msg: error.message
      }
    }
  }

  async initBcStatusForTest (pobj, q, req) {
    try {
      await this.cagentcbSve.initStatus()
      return {
        code: 200,
        msg: "重置成功"
      }
    } catch (error) {
      console.log('init err ')
      console.log(error)
      return {
        code: -1,
        msg: error.message
      }
    }
  }

  classDesc () {
    return {
      groupName: "auth",
      groupDesc: "认证相关的包",
      name: "AccessAuthAPI",
      desc: "关于认证的类",
      exam: `
             post  http://p.apps.com/api/auth/accessAuth/getAccessKey
             {
                appKey:xxxxx,
                secret:yyyyyy
             }
         `,
    };
  }
  methodDescs () {
    return [
      {
        methodDesc: "生成访问token,访问地址：http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
        methodName: "getAccessKey",
        paramdescs: [
          {
            paramDesc: "访问appkey",
            paramName: "appkey",
            paramType: "string",
            defaultValue: "",
          },
          {
            paramDesc: "访问secret",
            paramName: "secret",
            paramType: "string",
            defaultValue: "",
          }
        ],
        rtnTypeDesc: "返回JSON对象字符串",
        rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
      },
    ];
  }
  exam () {
    return ``
  }
}
module.exports = RejAPI;
