弃用自定义错误函数,直接使用 fiber.Err;更新 README.md 文档

This commit is contained in:
2025-05-15 10:24:02 +08:00
parent 661616dfc3
commit f5396ce9d8
5 changed files with 4 additions and 69 deletions

View File

@@ -5,13 +5,13 @@ import (
"database/sql"
"errors"
"fmt"
"github.com/gofiber/fiber/v2"
"log/slog"
"math"
"math/rand/v2"
"platform/pkg/env"
"platform/pkg/u"
"platform/web/auth"
"platform/web/core"
channel2 "platform/web/domains/channel"
proxy2 "platform/web/domains/proxy"
g "platform/web/globals"
@@ -65,7 +65,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.ErrForbidden()
return fiber.NewError(fiber.StatusForbidden)
}
}