重构错误处理逻辑,使用 fiber.Error 统一返回错误状态码;统一授权枚举值定义到 auth 包

This commit is contained in:
2025-05-10 13:38:47 +08:00
parent a06655ad29
commit 3140d35a95
9 changed files with 103 additions and 94 deletions

View File

@@ -67,7 +67,7 @@ func (s *channelService) RemoveChannels(ctx context.Context, authCtx *auth.Conte
// 检查权限,如果为用户操作的话,则只能删除自己的通道
for _, channel := range channels {
if authCtx.Payload.Type == auth.PayloadUser && authCtx.Payload.Id != channel.UserID {
return core.ForbiddenErr("无权限访问")
return core.ErrForbidden()
}
}