"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.queryParams = exports.getIsCompanyOKREmpty = exports.getEssay = exports["default"] = void 0;

var _axios = _interopRequireDefault(require("axios"));

var _requestV = require("../../../utils/request-v1");

var _BSGlobal$tenantInfo, _BSGlobal$loginUserIn;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

// @ts-ignore
var tenantId = BSGlobal && ((_BSGlobal$tenantInfo = BSGlobal.tenantInfo) === null || _BSGlobal$tenantInfo === void 0 ? void 0 : _BSGlobal$tenantInfo.Id) || 0; // @ts-ignore

var userId = BSGlobal && ((_BSGlobal$loginUserIn = BSGlobal.loginUserInfo) === null || _BSGlobal$loginUserIn === void 0 ? void 0 : _BSGlobal$loginUserIn.Id) || 0; // 对象转 queryParams

var queryParams = function queryParams() {
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var queryStr = "?";

  for (var key in params) {
    if (params.hasOwnProperty(key)) {
      queryStr += "".concat(key, "=").concat(params[key], "&");
    }
  }

  return queryStr.length === 1 ? "" : queryStr.slice(0, -1);
};

exports.queryParams = queryParams;

var _default = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ComponentId) {
    var componentUrl, res;
    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            componentUrl = (0, _requestV.getApiUrl)("okr/home/component ");
            _context.next = 3;
            return _axios["default"].post(componentUrl, {
              ComponentId: ComponentId
            });

          case 3:
            res = _context.sent;

            if (!(res.data.Code === 1)) {
              _context.next = 6;
              break;
            }

            return _context.abrupt("return", res.data.Data.componentsDataModels);

          case 6:
            return _context.abrupt("return", []);

          case 7:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));

  return function (_x) {
    return _ref.apply(this, arguments);
  };
}(); // //获取词云的接口
// export const getWordsApi = () => {
//   const WordsUrl = getApiUrl('wordCloud/get')
//   return `${WordsUrl}?num=250`
// }
// 获取文章的接口


exports["default"] = _default;

var getEssay = /*#__PURE__*/function () {
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
    var typeId,
        EssayUrl,
        res,
        _args2 = arguments;
    return regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            typeId = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
            EssayUrl = (0, _requestV.getApiUrl)("okrTemplate/article");
            _context2.next = 4;
            return _axios["default"].get(EssayUrl + queryParams({
              labelId: typeId,
              pageNum: 0,
              pageSize: 0
            }));

          case 4:
            res = _context2.sent;
            return _context2.abrupt("return", res.data.Data);

          case 6:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));

  return function getEssay() {
    return _ref2.apply(this, arguments);
  };
}();

exports.getEssay = getEssay;

var getIsCompanyOKREmpty = /*#__PURE__*/function () {
  var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
    var OKREmptyUrl, res;
    return regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            OKREmptyUrl = (0, _requestV.getApiUrl)("okr/map/exist");
            _context3.next = 3;
            return _axios["default"].get(OKREmptyUrl);

          case 3:
            res = _context3.sent;
            return _context3.abrupt("return", res.data.Data);

          case 5:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));

  return function getIsCompanyOKREmpty() {
    return _ref3.apply(this, arguments);
  };
}();

exports.getIsCompanyOKREmpty = getIsCompanyOKREmpty;