实现批次检查接口 & 修复白银接口 url 二次编码问题
This commit is contained in:
@@ -15,17 +15,7 @@ import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type ListResourceShortReq struct {
|
||||
core.PageReq
|
||||
ResourceNo *string `json:"resource_no"`
|
||||
Active *bool `json:"active"`
|
||||
Type *int `json:"type"`
|
||||
CreateAfter *time.Time `json:"create_after"`
|
||||
CreateBefore *time.Time `json:"create_before"`
|
||||
ExpireAfter *time.Time `json:"expire_after"`
|
||||
ExpireBefore *time.Time `json:"expire_before"`
|
||||
}
|
||||
|
||||
// ListResourceShort 分页短效套餐
|
||||
func ListResourceShort(c *fiber.Ctx) error {
|
||||
// 检查权限
|
||||
authCtx, err := auth.GetAuthCtx(c).PermitUser()
|
||||
@@ -96,7 +86,7 @@ func ListResourceShort(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
type ListResourceLongReq struct {
|
||||
type ListResourceShortReq struct {
|
||||
core.PageReq
|
||||
ResourceNo *string `json:"resource_no"`
|
||||
Active *bool `json:"active"`
|
||||
@@ -107,6 +97,7 @@ type ListResourceLongReq struct {
|
||||
ExpireBefore *time.Time `json:"expire_before"`
|
||||
}
|
||||
|
||||
// ListResourceLong 分页长效套餐
|
||||
func ListResourceLong(c *fiber.Ctx) error {
|
||||
// 检查权限
|
||||
authCtx, err := auth.GetAuthCtx(c).PermitUser()
|
||||
@@ -177,9 +168,18 @@ func ListResourceLong(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
type AllResourceReq struct {
|
||||
type ListResourceLongReq struct {
|
||||
core.PageReq
|
||||
ResourceNo *string `json:"resource_no"`
|
||||
Active *bool `json:"active"`
|
||||
Type *int `json:"type"`
|
||||
CreateAfter *time.Time `json:"create_after"`
|
||||
CreateBefore *time.Time `json:"create_before"`
|
||||
ExpireAfter *time.Time `json:"expire_after"`
|
||||
ExpireBefore *time.Time `json:"expire_before"`
|
||||
}
|
||||
|
||||
// AllActiveResource 所有可用套餐
|
||||
func AllActiveResource(c *fiber.Ctx) error {
|
||||
// 检查权限
|
||||
authCtx, err := auth.GetAuthCtx(c).PermitUser()
|
||||
@@ -235,23 +235,10 @@ func AllActiveResource(c *fiber.Ctx) error {
|
||||
return c.JSON(resources)
|
||||
}
|
||||
|
||||
type StatisticPersonalResp struct {
|
||||
Short StatisticShort `json:"short"`
|
||||
Long StatisticLong `json:"long"`
|
||||
}
|
||||
|
||||
type StatisticShort struct {
|
||||
ResourceCount int `json:"resource_count"`
|
||||
ResourceQuotaSum int `json:"resource_quota_sum"`
|
||||
ResourceDailyFreeSum int `json:"resource_daily_free_sum"`
|
||||
}
|
||||
|
||||
type StatisticLong struct {
|
||||
ResourceCount int `json:"resource_count"`
|
||||
ResourceQuotaSum int `json:"resource_quota_sum"`
|
||||
ResourceDailyFreeSum int `json:"resource_daily_free_sum"`
|
||||
type AllResourceReq struct {
|
||||
}
|
||||
|
||||
// StatisticResourceFree 统计每日可用
|
||||
func StatisticResourceFree(c *fiber.Ctx) error {
|
||||
// 检查权限
|
||||
authCtx, err := auth.GetAuthCtx(c).PermitUser()
|
||||
@@ -334,17 +321,24 @@ func StatisticResourceFree(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
type StatisticResourceUsageReq struct {
|
||||
ResourceNo *string `json:"resource_no"`
|
||||
TimeAfter *time.Time `json:"time_after"`
|
||||
TimeBefore *time.Time `json:"time_before"`
|
||||
type StatisticPersonalResp struct {
|
||||
Short StatisticShort `json:"short"`
|
||||
Long StatisticLong `json:"long"`
|
||||
}
|
||||
|
||||
type StatisticResourceUsageResp []struct {
|
||||
Date time.Time `json:"date"`
|
||||
Count int `json:"count"`
|
||||
type StatisticShort struct {
|
||||
ResourceCount int `json:"resource_count"`
|
||||
ResourceQuotaSum int `json:"resource_quota_sum"`
|
||||
ResourceDailyFreeSum int `json:"resource_daily_free_sum"`
|
||||
}
|
||||
|
||||
type StatisticLong struct {
|
||||
ResourceCount int `json:"resource_count"`
|
||||
ResourceQuotaSum int `json:"resource_quota_sum"`
|
||||
ResourceDailyFreeSum int `json:"resource_daily_free_sum"`
|
||||
}
|
||||
|
||||
// StatisticResourceUsage 统计每日用量
|
||||
func StatisticResourceUsage(c *fiber.Ctx) error {
|
||||
// 检查权限
|
||||
authCtx, err := auth.GetAuthCtx(c).PermitUser()
|
||||
@@ -402,10 +396,18 @@ func StatisticResourceUsage(c *fiber.Ctx) error {
|
||||
return c.JSON(data)
|
||||
}
|
||||
|
||||
type CreateResourceReq struct {
|
||||
*s.CreateResourceData
|
||||
type StatisticResourceUsageReq struct {
|
||||
ResourceNo *string `json:"resource_no"`
|
||||
TimeAfter *time.Time `json:"time_after"`
|
||||
TimeBefore *time.Time `json:"time_before"`
|
||||
}
|
||||
|
||||
type StatisticResourceUsageResp []struct {
|
||||
Date time.Time `json:"date"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
// CreateResource 创建套餐
|
||||
func CreateResource(c *fiber.Ctx) error {
|
||||
|
||||
// 检查权限
|
||||
@@ -429,6 +431,11 @@ func CreateResource(c *fiber.Ctx) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type CreateResourceReq struct {
|
||||
*s.CreateResourceData
|
||||
}
|
||||
|
||||
// ResourcePrice 套餐价格
|
||||
func ResourcePrice(c *fiber.Ctx) error {
|
||||
// 检查权限
|
||||
_, err := auth.GetAuthCtx(c).PermitSecretClient()
|
||||
@@ -447,7 +454,17 @@ func ResourcePrice(c *fiber.Ctx) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(fiber.Map{
|
||||
"price": amount.StringFixed(2),
|
||||
|
||||
// 计算折扣
|
||||
return c.JSON(ResourcePriceResp{
|
||||
Price: amount.StringFixed(2),
|
||||
Discounted: 1,
|
||||
DiscountedPrice: amount.StringFixed(2),
|
||||
})
|
||||
}
|
||||
|
||||
type ResourcePriceResp struct {
|
||||
Price string `json:"price"`
|
||||
Discounted float32 `json:"discounted"`
|
||||
DiscountedPrice string `json:"discounted_price"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user