138 lines
4.3 KiB
Go
138 lines
4.3 KiB
Go
package web_rechargepackage
|
|
|
|
import (
|
|
"videoweb/pub/common"
|
|
"videoweb/pub/common/srvdef"
|
|
"videoweb/web/service/srv_rechargepackage"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// List 查询购买套餐列表
|
|
// @Tags 套餐管理
|
|
// @Summary 查询购买套餐列表 -- by 王鸣
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body srv_rechargepackage.RechargePackageListReq true "查询参数"
|
|
// @Success 200 {object} srv_rechargepackage.RechargePackageListResp "成功"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/web/recharge/package/list [POST]
|
|
func List(ctx *gin.Context) {
|
|
var req srv_rechargepackage.RechargePackageListReq
|
|
if err := ctx.ShouldBind(&req); err != nil {
|
|
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
|
return
|
|
}
|
|
resp, err := srv_rechargepackage.ListRechargePackage(ctx, &req)
|
|
if err != nil {
|
|
common.ServerJSON(ctx, err.Code, err.Tips)
|
|
return
|
|
}
|
|
common.ServerJSON(ctx, srvdef.Success, resp)
|
|
}
|
|
|
|
// VipList 查询会员畅享套餐选项
|
|
// @Tags 套餐管理
|
|
// @Summary 查询会员畅享套餐选项 -- by 王鸣
|
|
// @Description 只返回 PackageType=1 的启用套餐,字段仅包含 id 和 name,不分页
|
|
// @Produce json
|
|
// @Success 200 {array} srv_rechargepackage.VipPackageOption "成功"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/web/recharge/package/vip/list [POST]
|
|
func VipList(ctx *gin.Context) {
|
|
resp, err := srv_rechargepackage.ListVipPackageOptions(ctx)
|
|
if err != nil {
|
|
common.ServerJSON(ctx, err.Code, err.Tips)
|
|
return
|
|
}
|
|
common.ServerJSON(ctx, srvdef.Success, resp)
|
|
}
|
|
|
|
// Add 新增购买套餐
|
|
// @Tags 套餐管理
|
|
// @Summary 新增购买套餐 -- by 王鸣
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body srv_rechargepackage.RechargePackageAddReq true "新增参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/web/recharge/package/add [POST]
|
|
func Add(ctx *gin.Context) {
|
|
var req srv_rechargepackage.RechargePackageAddReq
|
|
if err := ctx.ShouldBindJSON(&req); err != nil {
|
|
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
|
return
|
|
}
|
|
if err := srv_rechargepackage.AddRechargePackage(ctx, &req); err != nil {
|
|
common.ServerJSON(ctx, err.Code, err.Tips)
|
|
return
|
|
}
|
|
common.ServerJSON(ctx, srvdef.Success, "")
|
|
}
|
|
|
|
// Update 更新购买套餐
|
|
// @Tags 套餐管理
|
|
// @Summary 更新购买套餐 -- by 王鸣
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body srv_rechargepackage.RechargePackageUpdateReq true "更新参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/web/recharge/package/update [POST]
|
|
func Update(ctx *gin.Context) {
|
|
var req srv_rechargepackage.RechargePackageUpdateReq
|
|
if err := ctx.ShouldBindJSON(&req); err != nil {
|
|
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
|
return
|
|
}
|
|
if err := srv_rechargepackage.UpdateRechargePackage(ctx, &req); err != nil {
|
|
common.ServerJSON(ctx, err.Code, err.Tips)
|
|
return
|
|
}
|
|
common.ServerJSON(ctx, srvdef.Success, "")
|
|
}
|
|
|
|
// Delete 删除购买套餐
|
|
// @Tags 套餐管理
|
|
// @Summary 删除购买套餐 -- by 王鸣
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body srv_rechargepackage.RechargePackageDelReq true "删除参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/web/recharge/package/del [POST]
|
|
func Delete(ctx *gin.Context) {
|
|
var req srv_rechargepackage.RechargePackageDelReq
|
|
if err := ctx.ShouldBindJSON(&req); err != nil {
|
|
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
|
return
|
|
}
|
|
if err := srv_rechargepackage.DeleteRechargePackage(ctx, req.Id); err != nil {
|
|
common.ServerJSON(ctx, err.Code, err.Tips)
|
|
return
|
|
}
|
|
common.ServerJSON(ctx, srvdef.Success, "")
|
|
}
|
|
|
|
// SetStatus 单/批量设置购买套餐状态
|
|
// @Tags 套餐管理
|
|
// @Summary 单/批量设置购买套餐状态 -- by 王鸣
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body srv_rechargepackage.RechargePackageStatusSetReq true "设置状态参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/web/recharge/package/status/set [POST]
|
|
func SetStatus(ctx *gin.Context) {
|
|
var req srv_rechargepackage.RechargePackageStatusSetReq
|
|
if err := ctx.ShouldBindJSON(&req); err != nil {
|
|
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
|
return
|
|
}
|
|
if err := srv_rechargepackage.SetRechargePackageStatus(ctx, &req); err != nil {
|
|
common.ServerJSON(ctx, err.Code, err.Tips)
|
|
return
|
|
}
|
|
common.ServerJSON(ctx, srvdef.Success, "")
|
|
}
|