1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 批次信息表
- const batchInfo = new Schema({
- batch: { type: String, required: false, maxLength: 200 }, // 批次
- class: { type: String, required: false, maxLength: 200 }, // 班级数
- 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 schInfo = new Schema({
- schid: { type: String, required: false, maxLength: 200 }, // 学校id
- 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 }, // 批
- school: { type: [ schInfo ], select: true }, // 学校
- });
- // 节假日信息表
- 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 TrainplanSchema = {
- 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 }, // 期
- 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');
- };
|