/**
 * Created by Zhong on 2018/3/22.
 */
/*项目*/
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const deleteSchema = require('../all_schemas/delete_schema');

const collectionName = 'projects';
const shareSchema = new Schema({
    userID: String, //userID
    allowCopy: {type: Boolean, default: false},
    allowCooperate: {type: Boolean, default: false},
    shareDate: String,
}, {versionKey: false, _id: false});
const ProjectSchema = new Schema({
    "isTwoLevel": { type: Boolean, default: false },
    "ID": {type: Number, index: true},
    "ParentID": Number,
    "NextSiblingID": Number,
    "userID": {type:String,index: true},
    "importedByInterface": {type: Boolean, default: false},
    "code": {type: String, default: ''},
    "name": String,
    "projType": String,
    "recentDateTime": Date,
    "createDateTime": Date,
    "compilation": String,
    "deleteInfo": deleteSchema,
    'fullFolder': Array,
    //"shareInfo": [shareSchema],
    "property": {
        type: Schema.Types.Mixed,
        default: {}
    },
    "summaryFees":{
        totalFee: String,
        estimateFee: String,
        safetyFee: String,
        chargeFee: String
    },
    "changeMark":String,// 更新标记  feeRate:费率文件发生了改变，unitFile 单件文件发生了改变
    "remark":String, // 备注
    "fileVer": String,  // 创建时程序版本号
    "lastFileVer": String,  // 最新打开并计算时的程序版本号
    "compareID":Number
});

mongoose.model(collectionName, ProjectSchema, collectionName);