var System = require("../../system");
var settings = require("../../../config/settings");
const ApiBase = require("../api.base");
const logCtl = System.getObject("web.oplogCtl");
class TmtransactionApi extends ApiBase {
  constructor() {
    super();
    this.trademarktransactionSve = System.getObject("service.trademarktransactionSve");
    this.companyS = System.getObject("service.companySve");
    this.utilstmtasktradeSve = System.getObject("service.utilstmtasktradeSve");
  };
  //获取某类型的交易商标 post
  async findByTmType(obj){
    if(!obj.company_id){
      //获取当前域名
      var hostname = "jiaoyi.gongsibao.com";
      // console.log("xccccccccccccccccccccccccccccccccccccccc", hostname);
      //按照hostname去查找公司站点信息
      var companytmp = await this.companyS.findOne({ domainname: hostname, isEnabled: true });
      if(companytmp){
        obj.company_id=companytmp.id;
      }
    }
    try {
      return this.trademarktransactionSve.findByTmType(obj);
    } catch (error) {
      return {code:-200,msg:"操作失败"};
    }
  }

  async tmAuditData() {//商标交易录入es
    try {
      var kk = await this.utilstmtasktradeSve.opAuditData();
      console.log(kk, "kk...................");
      return kk;
    } catch (e) {
      //日志记录
      logCtl.error({
        optitle: "test_tmAuditData错误",
        op: "/igirl-web/app/base/api/impl/testApi.js",
        content: "error：" + JSON.stringify(e.stack),
        clientIp: ""
      });
      console.log(e.stack, "ttttttttt...............");
    }
  }
}
module.exports = TmtransactionApi;
