|
@@ -3,17 +3,33 @@ const Schema = require('mongoose').Schema;
|
|
const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
|
|
|
|
|
|
|
|
|
+// 选项详情
|
|
|
|
+const optionInfo = new Schema({
|
|
|
|
+ number: { type: String, required: false, maxLength: 200 }, // 序号
|
|
|
|
+ opname: { type: String, required: false, maxLength: 200 }, // 名称
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+// 问卷题
|
|
|
|
+const questionInfo = {
|
|
|
|
+ type: { type: String, required: true, maxLength: 200 }, // 类型,0-单选,1-多选,2-问答
|
|
|
|
+ topic: { type: String, required: true, maxLength: 500 }, // 题目
|
|
|
|
+ status: { type: String, required: false, maxLength: 200 }, // 状态,0-弃用,1-正常
|
|
|
|
+ option: { type: [ optionInfo ], select: true }, // 选项
|
|
|
|
+};
|
|
|
|
+
|
|
// 问卷表
|
|
// 问卷表
|
|
const QuestionnaireSchema = {
|
|
const QuestionnaireSchema = {
|
|
name: { type: String, required: true, maxLength: 200 }, // 问卷名称
|
|
name: { type: String, required: true, maxLength: 200 }, // 问卷名称
|
|
num: { type: String, required: true, maxLength: 200 }, // 序号
|
|
num: { type: String, required: true, maxLength: 200 }, // 序号
|
|
type: { type: String, required: true, maxLength: 200 }, // 类型,0-常用问卷,1-非常用问卷,2-教师问卷
|
|
type: { type: String, required: true, maxLength: 200 }, // 类型,0-常用问卷,1-非常用问卷,2-教师问卷
|
|
- question: [ String ], // 问题code
|
|
|
|
|
|
+ status: { type: String, required: true, maxLength: 200, default: '0' }, // 状态,0-草稿,1-发布,2-禁用
|
|
|
|
+ question: { type: [ questionInfo ], required: false, select: true }, // 问卷
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
const schema = new Schema(QuestionnaireSchema, { toJSON: { virtuals: true } });
|
|
const schema = new Schema(QuestionnaireSchema, { toJSON: { virtuals: true } });
|
|
schema.index({ id: 1 });
|
|
schema.index({ id: 1 });
|
|
|
|
+schema.index({ type: 1 });
|
|
schema.plugin(metaPlugin);
|
|
schema.plugin(metaPlugin);
|
|
|
|
|
|
module.exports = app => {
|
|
module.exports = app => {
|