Files
competition-website/app/model/gaozhiQuestion.js
WorkBuddy a303cf2d53 chore: 后端首次基线提交
运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。
已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
2026-08-17 12:25:42 +08:00

90 lines
1.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'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;
};