refactor(backend): 将ApiUser模型重命名为Admin并更新相关引用

This commit is contained in:
ylweng
2025-09-19 00:42:14 +08:00
parent 2ada0cb9bc
commit 2d77e83fad
14 changed files with 855 additions and 93 deletions

View File

@@ -86,8 +86,8 @@ const models = {
updatedAt: 'updated_at'
}),
// 为了兼容现有API创建一个简化版的用户模型
ApiUser: sequelize.define('ApiUser', {
// 为了兼容现有API创建一个简化版的管理员模型
Admin: sequelize.define('Admin', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
@@ -119,7 +119,7 @@ const models = {
defaultValue: 'active'
}
}, {
tableName: 'api_users',
tableName: 'admins',
timestamps: true
}),
@@ -196,9 +196,9 @@ const models = {
// 同步数据库模型
const syncModels = async () => {
try {
// 同步API用户表(如果不存在则创建)
await models.ApiUser.sync({ alter: true });
console.log('✅ API用户表同步成功');
// 同步管理员用户表(如果不存在则创建)
await models.Admin.sync({ alter: true });
console.log('✅ 管理员用户表同步成功');
// 同步订单表(如果不存在则创建)
await models.Order.sync({ alter: true });
@@ -214,8 +214,16 @@ const syncModels = async () => {
}
};
// 更新模型引用名称
const exportedModels = {
...models
};
// 确保Admin模型正确导出
exportedModels.Admin = exportedModels.Admin;
module.exports = {
...models,
...exportedModels,
testConnection,
syncModels
};