/**
 * Created by Mai on 2017/9/14.
 */

let mongoose = require("mongoose");
let baseModel = require('./base_model');
let collectionName = 'proj_setting';

class projSettingModel extends baseModel {

    constructor() {
        super(mongoose.model(collectionName));
        this.collectionName = collectionName;
    }

    getData (projectID, callback) {
        this.model.findOne({"projectID": projectID}, '-_id', function (err, result) {
            if (!err) {
                let data = JSON.parse(JSON.stringify(result));
/*                if (!data.billsCalcMode) {
                    data.billsCalcMode = settingConst.billsCalcMode.rationContent;
                }
                if (!data.zanguCalcType) {
                    data.zanguCalcType = settingConst.zanguCalcType.common;
                }
                data.settingConst = settingConst;*/
                callback(0, collectionName, data);
            } else {
                callback(1, '查询数据失败。', null);
            }
        });
    };

    save (user_id, data, callback) {
        this.model.update({"projectID": data.projectID}, data, callback);
    };
}

module.exports = new projSettingModel();