'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 班级信息表 const classInfo = new Schema({ name: { type: String, required: false, maxLength: 200 }, // 名称 number: { type: String, required: false, maxLength: 200 }, // 人数 type: { type: String, required: false, maxLength: 200 }, // 类型-0正常,1特殊,2,3创业班 headteacherid: { type: String, required: false, maxLength: 200 }, // 班主任id hasclass: { type: String, required: false, maxLength: 200 }, // 是否生成班级: 0未生成;1已生成 }); // 批次信息表 const batchInfo = new Schema({ batch: { type: String, required: false, maxLength: 200 }, // 批次 class: { type: [ classInfo ], required: false, select: true }, // 班级数 startdate: { type: String, required: false, maxLength: 200 }, // 开始日期 enddate: { type: String, required: false, maxLength: 200 }, // 结束日期 // type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊 // name: { type: String, required: false, maxLength: 200 }, // 名称 // number: { type: String, required: false, maxLength: 200 }, // 人数 color: { type: String, required: false, maxLength: 200 }, // 颜色 }); // 学校班级人数信息表 const classNumInfo = new Schema({ name: { type: String, required: false, maxLength: 200 }, // 名称 number: { type: String, required: false, maxLength: 200 }, // 人数 code: { type: String, required: false, maxLength: 200 }, // 班级code }); // 学校信息表 const schInfo = new Schema({ code: { type: String, required: false, maxLength: 200 }, // 学校code classnum: { type: [ classNumInfo ], select: true }, // 班级人数 num: { type: String, required: false, maxLength: 200 }, // 总人数 }); // 期信息表 const termInfo = new Schema({ term: { type: String, required: false, maxLength: 200 }, // 期数 classnum: { type: String, required: false, maxLength: 200 }, // 班级数 batchnum: { type: [ batchInfo ], select: true }, // 批 reteacher: { type: String, required: false, maxLength: 2000 }, // 督导教师 }); // 节假日信息表 const festivalInfo = new Schema({ begindate: { type: String, required: false, maxLength: 200 }, // 开始日期 finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期 name: { type: String, required: false, maxLength: 200 }, // 名称 }); // 备注信息表 const remarkInfo = new Schema({ month: { type: String, required: false, maxLength: 20 }, // 月份 class: { type: String, required: false, maxLength: 200 }, // 班级 number: { type: String, required: false, maxLength: 200 }, // 数量 }); // 培训计划表 const TrainplanSchema = { planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id year: { type: String, required: true, maxLength: 200 }, // 年份 title: { type: String, required: true, maxLength: 500 }, // 标题 status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-筹备中,1-发布,2-结束 termnum: { type: [ termInfo ], select: true }, // 期 remark: { type: [ remarkInfo ], select: true }, // 备注 school: { type: [ schInfo ], select: true }, // 学校 festivals: { type: [ festivalInfo ], select: true }, // 节假日 }; const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Trainplan', schema, 'trainplan'); };