整体优化完善接口与数据权限检查

This commit is contained in:
2026-03-28 14:18:11 +08:00
parent 51c377964d
commit 22cb2d50d3
21 changed files with 161 additions and 98 deletions

View File

@@ -15,10 +15,10 @@ import (
"github.com/gofiber/fiber/v2"
)
// PageChannelsByAdmin 分页查询所有通道
func PageChannelsByAdmin(c *fiber.Ctx) error {
// PageChannelByAdmin 分页查询所有通道
func PageChannelByAdmin(c *fiber.Ctx) error {
// 检查权限
_, err := auth.GetAuthCtx(c).PermitAdmin()
_, err := auth.GetAuthCtx(c).PermitAdmin(core.ScopeChannelRead)
if err != nil {
return err
}
@@ -98,8 +98,8 @@ type PageChannelsByAdminReq struct {
ExpiredAtEnd *time.Time `json:"expired_at_end"`
}
// 分页查询当前用户通道
func ListChannels(c *fiber.Ctx) error {
// ListChannel 分页查询当前用户通道
func ListChannel(c *fiber.Ctx) error {
// 检查权限
authContext, err := auth.GetAuthCtx(c).PermitUser()
if err != nil {
@@ -169,9 +169,15 @@ type ListChannelsReq struct {
ExpireBefore *time.Time `json:"expire_before"`
}
// 创建新通道
// CreateChannel 创建新通道
func CreateChannel(c *fiber.Ctx) error {
// 检查权限
_, err := auth.GetAuthCtx(c).PermitUser()
if err != nil {
return err
}
// 解析参数
req := new(CreateChannelReq)
if err := g.Validator.ParseBody(c, req); err != nil {