"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getUserInfo = exports.getSecurityCheckRecordPage = void 0;

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _utils = require("@vtx/utils");

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

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return 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); }); }; }

var getUserInfo = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(id) {
    var res;
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return _utils.request.get('/cloud/gas/api/v1/gasUser/get', {
              data: {
                id: id
              }
            });

          case 2:
            res = _context.sent;

            if (!((res === null || res === void 0 ? void 0 : res.result) === 0)) {
              _context.next = 5;
              break;
            }

            return _context.abrupt("return", res === null || res === void 0 ? void 0 : res.data);

          case 5:
            return _context.abrupt("return", {});

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

  return function getUserInfo(_x) {
    return _ref.apply(this, arguments);
  };
}();

exports.getUserInfo = getUserInfo;

var getSecurityCheckRecordPage = function getSecurityCheckRecordPage(id, dataSearch) {
  return /*#__PURE__*/function () {
    var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref2) {
      var current, pageSize, body, list, total, res, _res$data;

      return _regenerator["default"].wrap(function _callee2$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              current = _ref2.current, pageSize = _ref2.pageSize;
              body = _objectSpread(_objectSpread({
                page: current - 1,
                size: pageSize
              }, dataSearch), {}, {
                gasUserId: id
              });
              list = [];
              total = 0;
              _context2.next = 6;
              return _utils.request.get("/cloud/gas/api/v1/homeSecurityCheckRecord/page", {
                body: body
              });

            case 6:
              res = _context2.sent;

              if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
                if (Array.isArray((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.rows)) {
                  list = res.data.rows.map(function (item) {
                    return _objectSpread(_objectSpread({}, item), {}, {
                      key: item.id
                    });
                  });
                  total = res.data.total;
                }
              }

              return _context2.abrupt("return", {
                list: list,
                total: total
              });

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

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

exports.getSecurityCheckRecordPage = getSecurityCheckRecordPage;
//# sourceMappingURL=api.js.map
