You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.6 KiB
113 lines
2.6 KiB
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"laic-backend/common"
|
|
"laic-backend/service"
|
|
"laic-backend/vo"
|
|
)
|
|
|
|
func GetPlatformResourcePool(c *gin.Context) {
|
|
data, e := service.DefaultPlatformBillingService.GetPool()
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OKWithData(c, data)
|
|
}
|
|
|
|
func CreatePlatformPurchase(c *gin.Context) {
|
|
var req vo.PlatformPurchaseCreateReq
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
common.FailWithBindError(c, common.ErrParam, err)
|
|
return
|
|
}
|
|
data, e := service.DefaultPlatformBillingService.CreatePurchase(common.GetUserId(c), &req)
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OKWithData(c, data)
|
|
}
|
|
|
|
func GetPlatformPurchasePage(c *gin.Context) {
|
|
var req vo.PlatformPurchasePageReq
|
|
bindPage(c, &req.Pagination)
|
|
_ = c.ShouldBindQuery(&req)
|
|
data, e := service.DefaultPlatformBillingService.GetPurchasePage(&req)
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OKWithData(c, data)
|
|
}
|
|
|
|
func GetTrafficPackagePage(c *gin.Context) {
|
|
var req vo.TrafficPackagePageReq
|
|
bindPage(c, &req.Pagination)
|
|
_ = c.ShouldBindQuery(&req)
|
|
data, e := service.DefaultPlatformBillingService.GetPackagePage(&req)
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OKWithData(c, data)
|
|
}
|
|
|
|
func CreateTrafficPackage(c *gin.Context) {
|
|
var req vo.TrafficPackageCreateReq
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
common.FailWithBindError(c, common.ErrParam, err)
|
|
return
|
|
}
|
|
data, e := service.DefaultPlatformBillingService.CreatePackage(&req)
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OKWithData(c, data)
|
|
}
|
|
|
|
func UpdateTrafficPackage(c *gin.Context) {
|
|
id, e := parseID(c)
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
var req vo.TrafficPackageUpdateReq
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
common.FailWithBindError(c, common.ErrParam, err)
|
|
return
|
|
}
|
|
if e := service.DefaultPlatformBillingService.UpdatePackage(id, &req); e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OK(c)
|
|
}
|
|
|
|
func DeleteTrafficPackage(c *gin.Context) {
|
|
id, e := parseID(c)
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
if e := service.DefaultPlatformBillingService.DisablePackage(id); e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OK(c)
|
|
}
|
|
|
|
func GetTrafficLedgerPage(c *gin.Context) {
|
|
var req vo.TrafficLedgerPageReq
|
|
bindPage(c, &req.Pagination)
|
|
_ = c.ShouldBindQuery(&req)
|
|
data, e := service.DefaultPlatformBillingService.GetLedgerPage(&req)
|
|
if e != nil {
|
|
common.FailWithBusiError(c, e)
|
|
return
|
|
}
|
|
common.OKWithData(c, data)
|
|
}
|
|
|