Files
junhong_cmp_fiber/internal/routes/asset_auto_renewal.go
break 398a5e4282
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
fix(路由): 修正套餐真流量预警与资产自动续费的超管/平台 gate 作用域
Fiber 组中间件按路径前缀生效,两处 gate 挂在空路径组上实际落到 /api/admin 前缀,
注册顺序在其之后的后台接口对代理与企业账号一律返回 403(含代理充值、代理自充
支付方式与订单等)。gate 改为挂在各自功能路径组上,代理与企业仅被拒绝这两组功能入口。
2026-09-17 17:49:33 +08:00

46 lines
2.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package routes
import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/constants"
"github.com/break/junhong_cmp_fiber/pkg/errors"
"github.com/break/junhong_cmp_fiber/pkg/middleware"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
// registerAssetAutoRenewalRoutes 注册资产钱包自动续费配置的读写路由。
// 沿用超管/平台路由组级 gate 先例:代理、企业与个人客户账号一律 403无任何读取或修改入口。
// gate 必须挂在功能路径组上Fiber 的组中间件按路径前缀生效,挂在空路径组上会落到
// /api/admin 前缀,从而拦截该层其余全部接口。
func registerAssetAutoRenewalRoutes(router fiber.Router, handler *admin.AssetAutoRenewalConfigHandler, doc *openapi.Generator, basePath string) {
group := router.Group("/asset-auto-renewal-config", func(c *fiber.Ctx) error {
userType := middleware.GetUserTypeFromContext(c.UserContext())
if userType != constants.UserTypeSuperAdmin && userType != constants.UserTypePlatform {
return errors.New(errors.CodeForbidden, constants.PlatformManagementForbiddenMessage)
}
return c.Next()
})
path := basePath + "/asset-auto-renewal-config"
Register(group, doc, path, "GET", "", handler.GetConfig, RouteSpec{
Summary: "查询资产钱包自动续费配置",
Description: "返回唯一一份全局配置的总开关、适用范围、指定主套餐集合、到期前天数与配置版本;仅超级管理员与平台账号可访问",
Tags: []string{"资产钱包"},
Output: new(dto.AssetAutoRenewalConfigResponse),
Auth: true,
})
Register(group, doc, path, "PUT", "", handler.UpdateConfig, RouteSpec{
Summary: "保存资产钱包自动续费配置",
Description: "指定范围时集合必须非空且只能选择当前可售主套餐;保存记录操作者与前后值快照并递增配置版本,只影响后续扫描",
Tags: []string{"资产钱包"},
Body: new(dto.UpdateAssetAutoRenewalConfigRequest),
Output: new(dto.AssetAutoRenewalConfigResponse),
Auth: true,
})
}