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

116 lines
2.6 KiB
JavaScript
Raw Normal View History

'use strict';
/**
* 本科组作品提交模型 - BenkeSubmission
*
* 存储本科组参赛选手的作品提交记录,包括文件信息和评分。
* 表名:benke_submissions
*/
module.exports = app => {
const { STRING, INTEGER, DATE } = app.Sequelize;
const BenkeSubmission = app.model.define('benke_submission', {
// 主键 ID,自增
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '提交记录唯一标识',
},
// 外键:关联聚合报名 ID
aggregation_uid: {
type: INTEGER,
allowNull: false,
comment: '关联聚合报名 ID',
},
// 文件类型:word(文档)/ ppt(演示文稿)
file_type: {
type: STRING(20),
allowNull: true,
defaultValue: null,
comment: '文件类型 word/ppt',
},
// 作品名称
work_name: {
type: STRING(200),
allowNull: false,
comment: '作品名称',
},
// 文件存储路径
file_path: {
type: STRING(500),
allowNull: false,
comment: '文件存储路径',
},
// 文件原始名称
file_name: {
type: STRING(200),
allowNull: false,
comment: '文件原始名称',
},
// 文件大小(字节)
file_size: {
type: INTEGER,
allowNull: true,
defaultValue: null,
comment: '文件大小(字节)',
},
// 文件 MD5
file_md5: {
type: STRING(32),
allowNull: true,
defaultValue: null,
comment: '文件 MD5',
},
// 上传时间
upload_time: {
type: DATE,
allowNull: false,
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '上传时间',
},
// 评分
score: {
type: INTEGER,
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: 'benke_submissions',
timestamps: false,
underscored: true,
indexes: [
{
fields: ['aggregation_uid'],
},
],
});
// 关联定义
BenkeSubmission.associate = function() {
app.model.BenkeSubmission.belongsTo(app.model.Aggregation, {
foreignKey: 'aggregation_uid',
targetKey: 'aggregation_uid',
as: 'aggregation',
});
};
return BenkeSubmission;
};