cld_model.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. /**
  3. * cld接口模型
  4. *
  5. * @author EllisRan.
  6. * @date 2018/9/25
  7. * @version
  8. */
  9. const Request = require("request");
  10. const BaseModel = require("../../common/base/base_model");
  11. class CLDModel extends BaseModel {
  12. CLDUrl = 'http://cld.smartcost.com.cn';
  13. /**
  14. * 获取办事处人员信息
  15. *
  16. * @param cid
  17. * @return {Promise}
  18. */
  19. async getCategoryStaff(cid) {
  20. let postData = {
  21. url: this.CLDUrl + '/api/building/category/staff/' + cid,
  22. encoding: 'utf8'
  23. };
  24. return new Promise(function (resolve, reject) {
  25. try {
  26. // 请求接口
  27. Request.post(postData, function (err, postResponse, body) {
  28. if (err) {
  29. throw '请求错误';
  30. }
  31. if (postResponse.statusCode !== 200) {
  32. throw 'CLD通讯失败!';
  33. }
  34. resolve(body);
  35. });
  36. } catch (error) {
  37. reject([]);
  38. }
  39. });
  40. }
  41. }
  42. module.exports = CLDModel;