Files
competition-website/app/model/gaozhiQuestion.js

90 lines
1.9 KiB
JavaScript
Raw Normal View History

'use strict';
/**
* 高职组题库模型 - GaozhiQuestion
*
* 存储高职组比赛题目,支持单选、多选、判断等多种题型。
* 表名:gaozhi_questions
*/
module.exports = app => {
const { STRING, INTEGER, JSON, DATE } = app.Sequelize;
const GaozhiQuestion = app.model.define('gaozhi_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 格式)
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: 'gaozhi_questions',
timestamps: false,
underscored: true,
indexes: [
{
fields: ['question_type'],
},
{
fields: ['sort_order'],
},
],
});
return GaozhiQuestion;
};