Re-migrate code

This commit is contained in:
2026-03-02 12:57:07 +08:00
parent 6070df659a
commit 4f18028a7b
7 changed files with 99 additions and 11 deletions

View File

@@ -125,7 +125,7 @@ func (s *AuthService) ValidateUser(username, password string) (models.User, erro
var user models.User
err := database.DB.Where("username = ?", username).First(&user).Error
if err != nil {
return models.User{}, errors.New("用户名或密码错误")
return models.User{}, errors.New("用户名或密码不正确")
}
return user, nil
}
@@ -149,6 +149,9 @@ func (c *AuthController) Login(ctx *gin.Context) {
}
```
- Use `ErrorResponse` for API errors so messages are user-friendly and consistent.
- Do not leak raw DB/stack errors to clients; log internal details and return safe messages.
### Response Format
**Success response**:
```json
@@ -158,6 +161,8 @@ func (c *AuthController) Login(ctx *gin.Context) {
}
```
Some endpoints also return Node-compatible top-level keys (e.g. `serial`, `serials`, `pagination`) to preserve frontend compatibility.
**Error response**:
```json
{