fix(用户): 修复删除用户软删除钩子

避免软删除钩子类型断言失败导致 500\n删除无记录时返回未找到错误并记录日志
This commit is contained in:
yangjianbo
2025-12-29 16:57:50 +08:00
parent 5584709ac9
commit 4dab18a94f
3 changed files with 14 additions and 7 deletions

View File

@@ -366,7 +366,11 @@ func (s *adminServiceImpl) DeleteUser(ctx context.Context, id int64) error {
if user.Role == "admin" {
return errors.New("cannot delete admin user")
}
return s.userRepo.Delete(ctx, id)
if err := s.userRepo.Delete(ctx, id); err != nil {
log.Printf("delete user failed: user_id=%d err=%v", id, err)
return err
}
return nil
}
func (s *adminServiceImpl) UpdateUserBalance(ctx context.Context, userID int64, balance float64, operation string, notes string) (*User, error) {