123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /**
- * 编办业务逻辑
- *
- * @author CaiAoLin
- * @date 2017/8/16
- * @version
- */
- import BaseModel from "../../common/base/base_model";
- import mongoose from "mongoose";
- class CompilationModel extends BaseModel {
- /**
- * 构造函数
- *
- * @return {void}
- */
- constructor() {
- let parent = super();
- parent.model = mongoose.model('compilation');
- parent.init();
- }
- /**
- * 获取编办列表
- *
- * @return {Promise}
- */
- async getList() {
- // 筛选字段
- let field = {_id: 1, name: 1, is_release: 1, description: 1, categoryID: 1};
- let compilationData = await this.findDataByCondition({name: {$ne: ''}, is_release: true}, field, false);
- return compilationData === null ? [] : compilationData;
- }
- /**
- * 根据id获取可用的编办数据
- *
- * @param {String} id
- * @return {Promise}
- */
- async getCompilationById(id) {
- let condition = {_id: id, is_release: true};
- let compilationData = await this.findDataByCondition(condition);
- if (!compilationData || compilationData.bill_valuation === undefined) {
- return compilationData;
- }
- if (compilationData.bill_valuation.length > 0) {
- let enableValuation = [];
- for (let index in compilationData.bill_valuation) {
- if (compilationData.bill_valuation[index].enable) {
- enableValuation.push(compilationData.bill_valuation[index]);
- }
- }
- compilationData.bill_valuation = enableValuation;
- }
- if (compilationData.ration_valuation.length > 0) {
- let enableValuation = [];
- for (let index in compilationData.ration_valuation) {
- if (compilationData.ration_valuation[index].enable) {
- enableValuation.push(compilationData.bill_valuation[index]);
- }
- }
- compilationData.ration_valuation = enableValuation;
- }
- return compilationData;
- }
- }
- export default CompilationModel;
|