Files
competition-website/app/model/examQuestion.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

84 lines
1.8 KiB
JavaScript
Raw 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';
/**
* 试卷题目模型 - ExamQuestion
*
* 存储各参赛组别的试卷题目,按组别区分,支持排序。
* 表名:exam_questions
*/
module.exports = app => {
const { STRING, TEXT, INTEGER, DATE } = app.Sequelize;
const ExamQuestion = app.model.define('exam_question', {
// 主键 ID,自增
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '题目唯一标识',
},
// 所属组别:zhongzhi/gaozhi/benke/jiaoshi
group: {
type: STRING(20),
allowNull: false,
comment: '题目所属组别',
validate: {
isIn: [['zhongzhi', 'gaozhi', 'benke', 'jiaoshi']],
},
},
// 题目标题
title: {
type: STRING(200),
allowNull: false,
comment: '题目标题',
},
// 题目详细内容/描述
content: {
type: TEXT,
allowNull: false,
comment: '题目内容描述',
},
// 题目分值
score: {
type: INTEGER,
allowNull: false,
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: 'exam_questions',
timestamps: false,
underscored: true,
indexes: [
{
fields: ['group'],
},
{
fields: ['group', 'sort_order'],
},
],
});
return ExamQuestion;
};