1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- module.exports = app => {
- class RptCustomDefine extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'rpt_custom_define';
- }
- async getCustomDefine(tid, sid, rid) {
- const data = await this.getDataByCondition({ tid: tid, sid: sid, rid: rid });
- if (data && data.audit_select) {
- data.audit_select = JSON.parse(data.audit_select);
- }
- return data;
- }
- async addInitialStageData(stage, preStage, transaction) {
- if (!stage || !preStage) {
- throw '标段数据有误';
- }
- const preDatas = await this.getAllDataByCondition({
- where: {sid: preStage.id}
- });
- if (preDatas.length > 0) {
- for (const pd of preDatas) {
- delete pd.id;
- pd.sid = stage.id;
- }
- const result = await transaction.insert(this.tableName, preDatas);
- return result.affectedRows === preDatas.length;
- } else {
- return true;
- }
- }
- }
- return RptCustomDefine;
- };
|