Files
competition-website/app/model/account.js
qubiaobiao 2ab0991310 fix(admin): 复核页选择题选项渲染修复 + 阅卷导出 Word + 评分两位小数(R28)
针对测试人员反馈的四项:
1) 复核明细「选择题大量空白」:options 为 text 列存 JSON 字符串,原先被原样透传,
   前端 v-for 对字符串逐字符迭代(op.key/op.text 皆 undefined)⇒ 每字符渲染一行。
   新增 parseOptions()(仅 string 才 JSON.parse,失败降级 null)。
2) 选项与答案不随机:仅题目用 RAND() 抽题,normalizeQuestion 无 shuffle,字母无歧义。
3) 评分精度:DECIMAL(6,1) -> DECIMAL(6,2),migration 026 覆盖 17 列(与 025 同范围),
   lib/decimal_score.js 与 11 个 model 注释同步;汇总收敛 round2(×100/100)。
4) 阅卷导出:GET /api/admin/big-answers/:group/export?ids=
   单选考生 -> 直接 .docx;多位/全部 -> 每位考生单独 .docx 打包 .zip。
   路由为 3 段,注册在 :group 通配段之前。

验证:verify_big_question 51 PASS/1 FAIL(唯一 FAIL=测试人员新数据,非本次改动)、
verify_score_leak_all_channels 24/24、verify_question_no_answer_leak 4/3/0/1。
2026-09-28 15:50:46 +08:00

166 lines
3.7 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';
/**
* 账号模型 - Account
*
* 存储参赛者账号的全部信息,包括个人资料、联系方式和密码等。
* 表名:accounts
*/
module.exports = app => {
const { STRING, INTEGER, BOOLEAN, DATE } = app.Sequelize;
// 分数列统一走共享工厂(DECIMAL(6,2) + Number 兜底,见 app/lib/decimal_score.js)
const decimalScore = require('../lib/decimal_score')(app);
const Account = app.model.define('account', {
// 主键,自增
uid: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '账号唯一标识',
},
// 角色:contestant / admin
role: {
type: STRING(20),
allowNull: false,
defaultValue: 'contestant',
comment: '账号角色',
},
// 中文姓名
name_cn: {
type: STRING(50),
allowNull: false,
comment: '中文姓名',
},
// 英文姓名
name_en: {
type: STRING(100),
allowNull: true,
defaultValue: null,
comment: '英文姓名',
},
// 性别:male / female
gender: {
type: STRING(10),
allowNull: true,
defaultValue: null,
comment: '性别',
},
// 手机号码
phone: {
type: STRING(20),
allowNull: true,
defaultValue: null,
comment: '手机号码',
},
// 电子邮箱
email: {
type: STRING(100),
allowNull: true,
defaultValue: null,
comment: '电子邮箱',
},
// 身份证号,唯一
id_number: {
type: STRING(18),
allowNull: false,
unique: true,
comment: '身份证号',
},
// 登录密码(bcrypt 加盐哈希存储;兼容存量 SHA256 旧哈希,登录成功后透明升级)
password: {
type: STRING(100),
allowNull: false,
comment: '登录密码',
},
// 密码盐值
salt: {
type: STRING(32),
allowNull: false,
comment: '密码盐值',
},
// 职位
position: {
type: STRING(100),
allowNull: true,
defaultValue: null,
comment: '职位',
},
// 专业
major: {
type: STRING(100),
allowNull: true,
defaultValue: null,
comment: '专业',
},
// 国家
country: {
type: STRING(50),
allowNull: true,
defaultValue: null,
comment: '国家',
},
// 地区
region: {
type: STRING(50),
allowNull: true,
defaultValue: null,
comment: '地区',
},
// 机构/单位(中文)
organization_cn: {
type: STRING(200),
allowNull: true,
defaultValue: null,
comment: '机构/单位(中文)',
},
// 机构/单位(英文)
organization_en: {
type: STRING(200),
allowNull: true,
defaultValue: null,
comment: '机构/单位(英文)',
},
// 账号是否已激活
activated: {
type: BOOLEAN,
allowNull: false,
defaultValue: false,
comment: '账号激活状态',
},
// 总分
score: decimalScore('score', '账号总分', { defaultValue: null }),
// 记录创建时间
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: 'accounts',
timestamps: false,
underscored: true,
indexes: [
{
unique: true,
fields: ['id_number'],
},
{
fields: ['role'],
},
],
});
return Account;
};