运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。 已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
90 lines
2.0 KiB
JavaScript
90 lines
2.0 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 中职组题库模型 - ZhongzhiQuestion
|
||
*
|
||
* 存储中职组比赛题目,支持单选、多选、判断等多种题型。
|
||
* 表名:zhongzhi_questions
|
||
*/
|
||
|
||
module.exports = app => {
|
||
const { STRING, INTEGER, JSON, DATE } = app.Sequelize;
|
||
|
||
const ZhongzhiQuestion = app.model.define('zhongzhi_question', {
|
||
// 主键,自增
|
||
question_uid: {
|
||
type: INTEGER,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
comment: '题目唯一标识',
|
||
},
|
||
// 题目内容
|
||
question: {
|
||
type: STRING(1000),
|
||
allowNull: false,
|
||
comment: '题目内容',
|
||
},
|
||
// 正确答案
|
||
answer: {
|
||
type: STRING(500),
|
||
allowNull: false,
|
||
comment: '正确答案',
|
||
},
|
||
// 题目类型:single(单选) / multiple(多选) / judge(判断)
|
||
question_type: {
|
||
type: STRING(20),
|
||
allowNull: false,
|
||
comment: '题目类型',
|
||
},
|
||
// 选项(JSON 格式,如 ["A. xxx", "B. xxx", "C. xxx", "D. xxx"])
|
||
options: {
|
||
type: JSON,
|
||
allowNull: true,
|
||
defaultValue: null,
|
||
comment: '选项',
|
||
},
|
||
// 题目分值
|
||
score: {
|
||
type: INTEGER,
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '题目分值',
|
||
},
|
||
// 排序序号
|
||
sort_order: {
|
||
type: INTEGER,
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '排序序号',
|
||
},
|
||
// 记录创建时间
|
||
created_at: {
|
||
type: DATE,
|
||
allowNull: false,
|
||
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
comment: '创建时间',
|
||
},
|
||
// 记录更新时间
|
||
updated_at: {
|
||
type: DATE,
|
||
allowNull: false,
|
||
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
comment: '更新时间',
|
||
},
|
||
}, {
|
||
tableName: 'zhongzhi_questions',
|
||
timestamps: false,
|
||
underscored: true,
|
||
indexes: [
|
||
{
|
||
fields: ['question_type'],
|
||
},
|
||
{
|
||
fields: ['sort_order'],
|
||
},
|
||
],
|
||
});
|
||
|
||
return ZhongzhiQuestion;
|
||
};
|