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

57 lines
1.3 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';
/**
* 管理员模型 - Admin
*
* 存储后台管理员账号信息,管理员通过用户名和密码进行登录。
*/
module.exports = app => {
const { STRING, INTEGER, DATE } = app.Sequelize;
const Admin = app.model.define('admin', {
// 主键 ID,自增
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '管理员唯一标识',
},
// 管理员用户名,唯一
username: {
type: STRING(50),
allowNull: false,
unique: true,
comment: '管理员用户名',
},
// 管理员密码(明文存储,生产环境应使用 bcrypt 加密)
password: {
type: STRING(100),
allowNull: false,
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: 'admins',
// 时间戳字段
timestamps: false,
// 下划线命名
underscored: true,
});
return Admin;
};