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

@@ -5,7 +5,7 @@ const Joi = require('joi')
const router = express.Router()
// 引入数据库模型
const { ApiUser } = require('../models')
const { Admin } = require('../models')
// 引入认证中间件
const { authenticateJWT } = require('../middleware/auth')
@@ -118,9 +118,9 @@ router.post('/login', async (req, res) => {
const { username, password } = value
// 查找用户
const user = await ApiUser.findOne({
const user = await Admin.findOne({
where: {
[ApiUser.sequelize.Op.or]: [
[Admin.sequelize.Op.or]: [
{ username },
{ email: username }
]
@@ -218,7 +218,7 @@ router.get('/me', authenticateJWT, async (req, res) => {
const userId = req.user.id
// 根据ID查找用户
const user = await ApiUser.findByPk(userId, {
const user = await Admin.findByPk(userId, {
attributes: {
exclude: ['password_hash'] // 排除密码哈希等敏感信息
}