feat(node): add PreViewNodeMultiplier endpoint and response structure
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/perfect-panel/server/internal/logic/admin/system"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
"github.com/perfect-panel/server/pkg/result"
|
||||
)
|
||||
|
||||
// PreView Node Multiplier
|
||||
func PreViewNodeMultiplierHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
|
||||
return func(c *gin.Context) {
|
||||
|
||||
l := system.NewPreViewNodeMultiplierLogic(c.Request.Context(), svcCtx)
|
||||
resp, err := l.PreViewNodeMultiplier()
|
||||
result.HttpResult(c, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -414,6 +414,9 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
|
||||
// Update node config
|
||||
adminSystemGroupRouter.PUT("/node_config", adminSystem.UpdateNodeConfigHandler(serverCtx))
|
||||
|
||||
// PreView Node Multiplier
|
||||
adminSystemGroupRouter.GET("/node_multiplier/preview", adminSystem.PreViewNodeMultiplierHandler(serverCtx))
|
||||
|
||||
// get Privacy Policy Config
|
||||
adminSystemGroupRouter.GET("/privacy", adminSystem.GetPrivacyPolicyConfigHandler(serverCtx))
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
"github.com/perfect-panel/server/internal/types"
|
||||
"github.com/perfect-panel/server/pkg/logger"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PreViewNodeMultiplierLogic struct {
|
||||
logger.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// PreView Node Multiplier
|
||||
func NewPreViewNodeMultiplierLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PreViewNodeMultiplierLogic {
|
||||
return &PreViewNodeMultiplierLogic{
|
||||
Logger: logger.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *PreViewNodeMultiplierLogic) PreViewNodeMultiplier() (resp *types.PreViewNodeMultiplierResponse, err error) {
|
||||
now := time.Now()
|
||||
ratio := l.svcCtx.NodeMultiplierManager.GetMultiplier(now)
|
||||
return &types.PreViewNodeMultiplierResponse{
|
||||
Ratio: ratio,
|
||||
CurrentTime: now.Format("2006-01-02 15:04:05"),
|
||||
}, nil
|
||||
}
|
||||
@@ -1429,6 +1429,11 @@ type PreUnsubscribeResponse struct {
|
||||
DeductionAmount int64 `json:"deduction_amount"`
|
||||
}
|
||||
|
||||
type PreViewNodeMultiplierResponse struct {
|
||||
CurrentTime string `json:"current_time"`
|
||||
Ratio float32 `json:"ratio"`
|
||||
}
|
||||
|
||||
type PreviewSubscribeTemplateRequest struct {
|
||||
Id int64 `form:"id"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user