// 土地补偿
import mongoose from "mongoose";
const Schema = mongoose.Schema;
const collectionName = 'std_land_libs';
const oprSchema = require('../all_schemas/opr_schema');

const subItem = new Schema({
    // 土地类型
    name: String,
    // 土地补偿标准单价  
    unitPrice: Number,
    // 安置补助标准
    resettlementPrice: Number,

}, { _id: false })

// 地区
const regionSchema = new Schema({
    ID: Number,
    ParentID: Number,
    // 地区名称
    name: String,
    // 地区类型
    type: Number,
    // 街道
    street: String,
    // 耕地开垦单价
    unitPrice: Number,
    subList: { type: [subItem], default: [] },
}, { _id: false });

const modelSchema = {
    ID: String,
    // 标准名称
    libName: String,
    //编办ID
    compilationId: {
        type: String,
        index: true
    },
    compilationName: String,
    regions: { type: [regionSchema], default: [] },
    creator: String,
    createDate: Number,
    recentOpr: [oprSchema]
};

mongoose.model(collectionName, new Schema(modelSchema, { versionKey: false, collection: collectionName }));

