tender_node.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. /**
  3. * 标段 -- 指标节点业务类
  4. *
  5. * @author Mai
  6. * @date 2018/4/25
  7. * @version
  8. */
  9. module.exports = app => {
  10. class TenderNode extends app.BaseService {
  11. /**
  12. * 构造函数
  13. *
  14. * @param {Object} ctx - egg全局context
  15. * @return {void}
  16. */
  17. constructor(ctx) {
  18. super(ctx);
  19. this.tableName = 'tender_node';
  20. }
  21. async search (tenderId, keyword) {
  22. const searchKey = '%' + keyword + '%';
  23. const sql = 'Select * From ??' +
  24. ' where `lib_id` = ' + tenderId + ' and (`name` like ? or code like ?)';
  25. const sqlParam = [this.tableName, searchKey, searchKey];
  26. return await this.db.query(sql, sqlParam);
  27. }
  28. async searchClass (tenderId, indexClass, className) {
  29. if (indexClass === this.app.nodeConst.indexClass.dy) {
  30. const sql = 'Select * From ' + this.tableName +
  31. ' Where `lib_id` = ? and `index_class` = ? and `class_name` = ?';
  32. const sqlParam = [tenderId, indexClass, className];
  33. console.log(this.db.format(sql, sqlParam));
  34. return await this.db.query(sql, sqlParam);
  35. } else {
  36. const sql = 'Select * From ' + this.tableName +
  37. ' Where `lib_id` = ? and `index_class` = ?';
  38. const sqlParam = [tenderId, indexClass];
  39. console.log(this.db.format(sql, sqlParam));
  40. return await this.db.query(sql, sqlParam);
  41. }
  42. }
  43. };
  44. return TenderNode;
  45. };