'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);
        }
    };

    return TenderNode;
};