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*、构建/缓存产物。
This commit is contained in:
135
app/model/aggregation.js
Normal file
135
app/model/aggregation.js
Normal file
@@ -0,0 +1,135 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 聚合报名模型 - Aggregation
|
||||
*
|
||||
* 存储参赛报名聚合信息,关联竞赛、团队和账号。
|
||||
* 表名:aggregation
|
||||
*/
|
||||
|
||||
module.exports = app => {
|
||||
const { STRING, INTEGER, BOOLEAN, ENUM, DATE } = app.Sequelize;
|
||||
|
||||
const Aggregation = app.model.define('aggregation', {
|
||||
// 主键,自增
|
||||
aggregation_uid: {
|
||||
type: INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
comment: '聚合唯一标识',
|
||||
},
|
||||
// 外键:竞赛 ID
|
||||
competition_uid: {
|
||||
type: INTEGER,
|
||||
allowNull: false,
|
||||
comment: '关联竞赛 ID',
|
||||
},
|
||||
// 外键:团队 ID(允许为空:单人参赛/未分组的选手仍可建立聚合报名,
|
||||
// 以便 benke/jiaoshi 作品上传等依赖 aggregation 的流程正常工作)
|
||||
team_uid: {
|
||||
type: INTEGER,
|
||||
allowNull: true,
|
||||
comment: '关联团队 ID',
|
||||
},
|
||||
// 外键:账号 ID
|
||||
account_uid: {
|
||||
type: INTEGER,
|
||||
allowNull: false,
|
||||
comment: '关联账号 ID',
|
||||
},
|
||||
// 身份:队长/队员/指导教师
|
||||
identity: {
|
||||
type: STRING(20),
|
||||
allowNull: false,
|
||||
comment: '身份',
|
||||
},
|
||||
// 是否为报名负责人
|
||||
is_registrant: {
|
||||
type: BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
comment: '是否为报名负责人',
|
||||
},
|
||||
// 报名表文件路径
|
||||
registration_form: {
|
||||
type: STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
comment: '报名表文件路径',
|
||||
},
|
||||
// 盖章报名表文件路径
|
||||
stamped_form: {
|
||||
type: STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
comment: '盖章报名表文件路径',
|
||||
},
|
||||
// 审核状态:pending/approved/rejected
|
||||
audit_status: {
|
||||
type: STRING(20),
|
||||
allowNull: false,
|
||||
defaultValue: 'pending',
|
||||
comment: '审核状态',
|
||||
},
|
||||
// 驳回原因
|
||||
reject_reason: {
|
||||
type: STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
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: 'aggregation',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
indexes: [
|
||||
{
|
||||
fields: ['competition_uid'],
|
||||
},
|
||||
{
|
||||
fields: ['team_uid'],
|
||||
},
|
||||
{
|
||||
fields: ['account_uid'],
|
||||
},
|
||||
{
|
||||
fields: ['audit_status'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// 关联定义
|
||||
Aggregation.associate = function() {
|
||||
app.model.Aggregation.belongsTo(app.model.CompetitionInfo, {
|
||||
foreignKey: 'competition_uid',
|
||||
targetKey: 'competition_uid',
|
||||
as: 'competition',
|
||||
});
|
||||
app.model.Aggregation.belongsTo(app.model.Team, {
|
||||
foreignKey: 'team_uid',
|
||||
targetKey: 'team_uid',
|
||||
as: 'team',
|
||||
});
|
||||
app.model.Aggregation.belongsTo(app.model.Account, {
|
||||
foreignKey: 'account_uid',
|
||||
targetKey: 'uid',
|
||||
as: 'account',
|
||||
});
|
||||
};
|
||||
|
||||
return Aggregation;
|
||||
};
|
||||
Reference in New Issue
Block a user