feat(api): change subscription product options and catalog endpoints to use GET method
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -64,9 +64,9 @@ export async function listWaffoPancakeCatalog(
|
||||
merchantID: string,
|
||||
privateKey: string
|
||||
): Promise<CatalogResponse> {
|
||||
const res = await api.post<CatalogResponse>(
|
||||
const res = await api.get<CatalogResponse>(
|
||||
'/api/option/waffo-pancake/catalog',
|
||||
{ merchant_id: merchantID, private_key: privateKey }
|
||||
{ params: { merchant_id: merchantID, private_key: privateKey } }
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user