1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 'use strict';
- /**
- * 标段 -- 指标节点业务类
- *
- * @author Mai
- * @date 2018/4/25
- * @version
- */
- module.exports = app => {
- class TenderNode extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局context
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'tender_node';
- }
- async search (tenderId, keyword) {
- const searchKey = '%' + keyword + '%';
- const sql = 'Select * From ??' +
- ' where `lib_id` = ' + tenderId + ' and (`name` like ? or code like ?)';
- const sqlParam = [this.tableName, searchKey, searchKey];
- return await this.db.query(sql, sqlParam);
- }
- async searchClass (tenderId, indexClass, className) {
- if (indexClass === this.app.nodeConst.indexClass.dy) {
- const sql = 'Select * From ' + this.tableName +
- ' Where `lib_id` = ? and `index_class` = ? and `class_name` = ?';
- const sqlParam = [tenderId, indexClass, className];
- console.log(this.db.format(sql, sqlParam));
- return await this.db.query(sql, sqlParam);
- } else {
- const sql = 'Select * From ' + this.tableName +
- ' Where `lib_id` = ? and `index_class` = ?';
- const sqlParam = [tenderId, indexClass];
- console.log(this.db.format(sql, sqlParam));
- return await this.db.query(sql, sqlParam);
- }
- }
- };
- return TenderNode;
- };
|