mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: vas for group / storage pack
This commit is contained in:
39
routers/controllers/vas.go
Normal file
39
routers/controllers/vas.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/HFO4/cloudreve/service/vas"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetQuota 获取容量配额信息
|
||||
func GetQuota(c *gin.Context) {
|
||||
var service vas.GeneralVASService
|
||||
if err := c.ShouldBindUri(&service); err == nil {
|
||||
res := service.Quota(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// GetProduct 获取商品信息
|
||||
func GetProduct(c *gin.Context) {
|
||||
var service vas.GeneralVASService
|
||||
if err := c.ShouldBindUri(&service); err == nil {
|
||||
res := service.Products(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// NewOrder 新建支付订单
|
||||
func NewOrder(c *gin.Context) {
|
||||
var service vas.CreateOrderService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Create(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
@@ -354,6 +354,17 @@ func InitMasterRouter() *gin.Engine {
|
||||
tag.DELETE(":id", middleware.HashID(hashid.TagID), controllers.DeleteTag)
|
||||
}
|
||||
|
||||
// 增值服务相关
|
||||
vas := auth.Group("vas")
|
||||
{
|
||||
// 获取容量包及配额信息
|
||||
vas.GET("pack", controllers.GetQuota)
|
||||
// 获取商品信息,同时返回支付信息
|
||||
vas.GET("product", controllers.GetProduct)
|
||||
// 新建支付订单
|
||||
vas.POST("order", controllers.NewOrder)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user