/**
 * Created by Zhong on 2017/8/22.
 */
import mongoose from "mongoose";

let Schema = mongoose.Schema;
let gjlComponentSchema = mongoose.Schema(
    {
        ID: Number,
        consumeAmt: Number
    },
    {_id: false},
    {versionKey: false}
);
//补充工料机跟用户和编办绑定
let complementaryGljSchema = new Schema({
    userId: Number,
    compilationId: String,
    ID: Number,
    code: String,
    name: String,
    specs: String,
    unit: String,
    basePrice: String,
    gljClass: Number,
    gljType: Number,
    shortName: String,
    component: [gjlComponentSchema]
}, {versionKey: false});

//标准工料机
let stdGljSchema = new Schema({
    deleted: Boolean,
    repositoryId: Number,
    ID: Number,
    code: String,
    name: String,
    specs: String,
    basePrice: Number,
    gljClass: Number,
    gljType: Number,
    shortName: String,
    unit: String,
    component: [gjlComponentSchema]
},{versionKey: false});

//标准工料机分类树
let gljClassSchema = mongoose.Schema({
    repositoryId: Number,
    ID: Number,
    ParentID: Number,
    NextSiblingID: Number,
    Name: String,
    deleted: Boolean
}, {versionKey: false});

let complementaryGljModel = mongoose.model('complementary_glj_lib', complementaryGljSchema, 'complementary_glj_lib');
let stdGljModel = mongoose.model('std_glj_lib_gljList', stdGljSchema, 'std_glj_lib_gljList');
let gljClassModel = mongoose.model('std_glj_lib_gljClass', gljClassSchema, 'std_glj_lib_gljClass');

export {complementaryGljModel, stdGljModel, gljClassModel};