From 50784c10ee4b82020e0427601acf46f2185c18cd Mon Sep 17 00:00:00 2001 From: CaIon Date: Thu, 18 Jun 2026 17:15:05 +0800 Subject: [PATCH] feat(api): change subscription product options and catalog endpoints to use GET method --- controller/topup_waffo_pancake.go | 19 +++++-------------- router/api-router.go | 4 ++-- web/default/src/features/subscriptions/api.ts | 2 +- .../integrations/waffo-pancake-api.ts | 4 ++-- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/controller/topup_waffo_pancake.go b/controller/topup_waffo_pancake.go index cd8b0d66..beb73ebe 100644 --- a/controller/topup_waffo_pancake.go +++ b/controller/topup_waffo_pancake.go @@ -103,11 +103,6 @@ func getWaffoPancakeBuyerEmail(user *model.User) string { // the body and fall back to persisted creds when the body is blank (see // resolveWaffoPancakeAdminCreds). Only SaveWaffoPancake writes to OptionMap. -type waffoPancakeCredsRequest struct { - MerchantID string `json:"merchant_id"` - PrivateKey string `json:"private_key"` -} - type saveWaffoPancakeRequest struct { MerchantID string `json:"merchant_id"` PrivateKey string `json:"private_key"` @@ -221,15 +216,11 @@ func CreateWaffoPancakePair(c *gin.Context) { // Doubles as a credential probe (a successful 200 proves the resolved creds // authenticate). See resolveWaffoPancakeAdminCreds for credential resolution. func ListWaffoPancakeCatalog(c *gin.Context) { - var req waffoPancakeCredsRequest - // An empty body means "use persisted creds"; only fail on malformed JSON. - if c.Request.ContentLength > 0 { - if err := c.ShouldBindJSON(&req); err != nil { - c.JSON(http.StatusOK, gin.H{"message": "error", "data": "参数错误"}) - return - } - } - merchantID, privateKey := resolveWaffoPancakeAdminCreds(req.MerchantID, req.PrivateKey) + // Missing query creds mean "use persisted creds". + merchantID, privateKey := resolveWaffoPancakeAdminCreds( + strings.TrimSpace(c.Query("merchant_id")), + strings.TrimSpace(c.Query("private_key")), + ) if merchantID == "" || privateKey == "" { c.JSON(http.StatusOK, gin.H{"message": "error", "data": "Waffo Pancake 凭证未配置"}) return diff --git a/router/api-router.go b/router/api-router.go index baf7cda2..7221bd14 100644 --- a/router/api-router.go +++ b/router/api-router.go @@ -191,11 +191,11 @@ func SetApiRouter(router *gin.Engine) { optionRoute.DELETE("/channel_affinity_cache", controller.ClearChannelAffinityCache) optionRoute.POST("/rest_model_ratio", controller.ResetModelRatio) optionRoute.POST("/migrate_console_setting", controller.MigrateConsoleSetting) // 用于迁移检测的旧键,下个版本会删除 - optionRoute.POST("/waffo-pancake/catalog", controller.ListWaffoPancakeCatalog) + optionRoute.GET("/waffo-pancake/catalog", controller.ListWaffoPancakeCatalog) optionRoute.POST("/waffo-pancake/pair", controller.CreateWaffoPancakePair) optionRoute.POST("/waffo-pancake/save", controller.SaveWaffoPancake) optionRoute.POST("/waffo-pancake/subscription-product", controller.CreateWaffoPancakeSubscriptionProduct) - optionRoute.POST("/waffo-pancake/subscription-product-options", controller.ListWaffoPancakeSubscriptionProductOptions) + optionRoute.GET("/waffo-pancake/subscription-product-options", controller.ListWaffoPancakeSubscriptionProductOptions) } // Custom OAuth provider management (root only) diff --git a/web/default/src/features/subscriptions/api.ts b/web/default/src/features/subscriptions/api.ts index fd5423fb..08347cba 100644 --- a/web/default/src/features/subscriptions/api.ts +++ b/web/default/src/features/subscriptions/api.ts @@ -159,7 +159,7 @@ export async function listWaffoPancakeSubscriptionProductOptions(): Promise< products: { id: string; name: string; status: string }[] }> > { - const res = await api.post( + const res = await api.get( '/api/option/waffo-pancake/subscription-product-options' ) return res.data diff --git a/web/default/src/features/system-settings/integrations/waffo-pancake-api.ts b/web/default/src/features/system-settings/integrations/waffo-pancake-api.ts index f0a6e115..3f0667fd 100644 --- a/web/default/src/features/system-settings/integrations/waffo-pancake-api.ts +++ b/web/default/src/features/system-settings/integrations/waffo-pancake-api.ts @@ -64,9 +64,9 @@ export async function listWaffoPancakeCatalog( merchantID: string, privateKey: string ): Promise { - const res = await api.post( + const res = await api.get( '/api/option/waffo-pancake/catalog', - { merchant_id: merchantID, private_key: privateKey } + { params: { merchant_id: merchantID, private_key: privateKey } } ) return res.data }