var system = require("../../system")
var settings = require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BigDataCtl {
  constructor() {
    //this.appS=system.getObject("service.appSve");
    this.appKey = "9d9bcbb6a82f44dbbdb185afe28032bc";
    this.companynamesearchApi = "https://bigdata.gongsibao.com/api/gsbicsearch/companynamesearch";
    this.restClient = system.getObject("util.restClient");
  }
  async companySuggest(queryobj, qobj, req) {
    if (!qobj.name || !qobj.name.trim()) {
      return system.getResult2([], null);
    }

    var params = {
      "appKey": this.appKey,
      "companyName": qobj.name.trim()
    }

    let rs = await this.restClient.execPost(params, this.companynamesearchApi);
    if(rs && rs.stdout) {
      var obj = JSON.parse(rs.stdout) || {};
      if(obj.data && obj.data.list) {
        return system.getResult2(obj.data.list, null);
      }
    }
    return system.getResult2([], null);
  }
}
module.exports = BigDataCtl;