MCPcopy Create free account
hub / github.com/QuantumNous/new-api / UpdateSubscriptionPreference

Function UpdateSubscriptionPreference

controller/subscription.go:77–98  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

75}
76
77func UpdateSubscriptionPreference(c *gin.Context) {
78 userId := c.GetInt("id")
79 var req BillingPreferenceRequest
80 if err := c.ShouldBindJSON(&req); err != nil {
81 common.ApiErrorMsg(c, "参数错误")
82 return
83 }
84 pref := common.NormalizeBillingPreference(req.BillingPreference)
85
86 user, err := model.GetUserById(userId, true)
87 if err != nil {
88 common.ApiError(c, err)
89 return
90 }
91 current := user.GetSetting()
92 current.BillingPreference = pref
93 if err := model.UpdateUserSetting(user.Id, current); err != nil {
94 common.ApiError(c, err)
95 return
96 }
97 common.ApiSuccess(c, gin.H{"billing_preference": pref})
98}
99
100func SubscriptionRequestBalancePay(c *gin.Context) {
101 if !requirePaymentCompliance(c) {

Callers

nothing calls this directly

Calls 7

ApiErrorMsgFunction · 0.92
GetUserByIdFunction · 0.92
ApiErrorFunction · 0.92
UpdateUserSettingFunction · 0.92
ApiSuccessFunction · 0.92
GetSettingMethod · 0.45

Tested by

no test coverage detected