feat: 互动处理
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package radio
|
||||
|
||||
import (
|
||||
"sundynix-go/model/commom/response"
|
||||
"sundynix-go/model/radio/request"
|
||||
radioRes "sundynix-go/model/radio/response"
|
||||
"sundynix-go/utils/auth"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type VipApi struct{}
|
||||
|
||||
// UpdateVipConfig 更新VIP配置
|
||||
// @Tags VIP管理
|
||||
// @Summary 更新VIP配置
|
||||
// @Accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.UpdateVipConfig true "VIP配置信息"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /vip/config/update [post]
|
||||
func (a *VipApi) UpdateVipConfig(c *gin.Context) {
|
||||
var req request.UpdateVipConfig
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
response.FailWithMsg("参数错误: "+err.Error(), c)
|
||||
return
|
||||
}
|
||||
err = vipService.UpdateVipConfig(req)
|
||||
if err != nil {
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMsg("更新成功", c)
|
||||
}
|
||||
|
||||
// VipConfigDetail 获取VIP配置详情
|
||||
// @Tags VIP管理
|
||||
// @Summary 获取VIP配置详情
|
||||
// @Produce application/json
|
||||
// @Param id query string true "id"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /vip/config/detail [get]
|
||||
func (a *VipApi) VipConfigDetail(c *gin.Context) {
|
||||
vipConfig, err := vipService.VipConfigDetail()
|
||||
if err != nil {
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(vipConfig, c)
|
||||
}
|
||||
|
||||
// VipVip 开通vip
|
||||
// @Tags VIP管理
|
||||
// @Summary 开通vip
|
||||
// @Produce application/json
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /vip/vip [post]
|
||||
func (a *VipApi) VipVip(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
res, no, err := vipService.VipVip(userId)
|
||||
if err != nil {
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(radioRes.PrePayResult{
|
||||
Payments: res,
|
||||
OutTradeNo: no,
|
||||
}, c)
|
||||
}
|
||||
Reference in New Issue
Block a user