1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 'use strict';
- /**
- * 标段项目模板数据模型
- *
- * @author CaiAoLin
- * @date 2017/12/1
- * @version
- */
- module.exports = app => {
- class TenderNodeTemplate extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'tender_node_template';
- }
- /**
- * 获取模板数据
- *
- * @param {Boolean} isCache - 是否使用缓存
- * @return {Array} - 返回模板数据
- */
- async getData(isCache = true) {
- const cacheKey = 'tenderTPL';
- const data = await this.cache.get(cacheKey);
- if (data !== null && !isCache) {
- return JSON.parse(data);
- }
- // 获取所有数据
- const templateData = await this.db.select(this.tableName);
- if (templateData.length <= 0) {
- return [];
- }
- this.cache.set(cacheKey, JSON.stringify(templateData), 'EX', app.config.cacheTime);
- return templateData;
- }
- }
- return TenderNodeTemplate;
- };
|