feat(module): add GetModuleConfig handler and logic for module configuration retrieval
This commit is contained in:
parent
87b743a2a2
commit
cb5bf5aae3
18
internal/handler/admin/system/getModuleConfigHandler.go
Normal file
18
internal/handler/admin/system/getModuleConfigHandler.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetModuleConfigHandler Get Module Config
|
||||||
|
func GetModuleConfigHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
|
||||||
|
l := system.NewGetModuleConfigLogic(c.Request.Context(), svcCtx)
|
||||||
|
resp, err := l.GetModuleConfig()
|
||||||
|
result.HttpResult(c, resp, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -408,6 +408,9 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
|
|||||||
// Update invite config
|
// Update invite config
|
||||||
adminSystemGroupRouter.PUT("/invite_config", adminSystem.UpdateInviteConfigHandler(serverCtx))
|
adminSystemGroupRouter.PUT("/invite_config", adminSystem.UpdateInviteConfigHandler(serverCtx))
|
||||||
|
|
||||||
|
// Get Module Config
|
||||||
|
adminSystemGroupRouter.GET("/module", adminSystem.GetModuleConfigHandler(serverCtx))
|
||||||
|
|
||||||
// Get node config
|
// Get node config
|
||||||
adminSystemGroupRouter.GET("/node_config", adminSystem.GetNodeConfigHandler(serverCtx))
|
adminSystemGroupRouter.GET("/node_config", adminSystem.GetNodeConfigHandler(serverCtx))
|
||||||
|
|
||||||
@ -822,9 +825,6 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
|
|||||||
// Reset User Subscribe Token
|
// Reset User Subscribe Token
|
||||||
publicUserGroupRouter.PUT("/subscribe_token", publicUser.ResetUserSubscribeTokenHandler(serverCtx))
|
publicUserGroupRouter.PUT("/subscribe_token", publicUser.ResetUserSubscribeTokenHandler(serverCtx))
|
||||||
|
|
||||||
// Update User Subscribe Note
|
|
||||||
publicUserGroupRouter.PUT("/subscribe_note", publicUser.UpdateUserSubscribeNoteHandler(serverCtx))
|
|
||||||
|
|
||||||
// Unbind Device
|
// Unbind Device
|
||||||
publicUserGroupRouter.PUT("/unbind_device", publicUser.UnbindDeviceHandler(serverCtx))
|
publicUserGroupRouter.PUT("/unbind_device", publicUser.UnbindDeviceHandler(serverCtx))
|
||||||
|
|
||||||
|
|||||||
41
internal/logic/admin/system/getModuleConfigLogic.go
Normal file
41
internal/logic/admin/system/getModuleConfigLogic.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/perfect-panel/server/internal/svc"
|
||||||
|
"github.com/perfect-panel/server/internal/types"
|
||||||
|
"github.com/perfect-panel/server/pkg/constant"
|
||||||
|
"github.com/perfect-panel/server/pkg/logger"
|
||||||
|
"github.com/perfect-panel/server/pkg/xerr"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetModuleConfigLogic struct {
|
||||||
|
logger.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Module Config
|
||||||
|
func NewGetModuleConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetModuleConfigLogic {
|
||||||
|
return &GetModuleConfigLogic{
|
||||||
|
Logger: logger.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetModuleConfigLogic) GetModuleConfig() (resp *types.ModuleConfig, err error) {
|
||||||
|
value, exists := os.LookupEnv("SECRET_KEY")
|
||||||
|
if !exists {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.ERROR), " SECRET_KEY not set in environment variables")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.ModuleConfig{
|
||||||
|
Secret: value,
|
||||||
|
ServiceName: constant.ServiceName,
|
||||||
|
ServiceVersion: constant.Version,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
@ -1221,6 +1221,12 @@ type MobileAuthenticateConfig struct {
|
|||||||
Whitelist []string `json:"whitelist"`
|
Whitelist []string `json:"whitelist"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ModuleConfig struct {
|
||||||
|
Secret string `json:"secret"` // 通讯密钥
|
||||||
|
ServiceName string `json:"service_name"` // 服务名称
|
||||||
|
ServiceVersion string `json:"service_version"` // 服务版本
|
||||||
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@ -1804,11 +1810,6 @@ type ResetUserSubscribeTokenRequest struct {
|
|||||||
UserSubscribeId int64 `json:"user_subscribe_id"`
|
UserSubscribeId int64 `json:"user_subscribe_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateUserSubscribeNoteRequest struct {
|
|
||||||
UserSubscribeId int64 `json:"user_subscribe_id" validate:"required"`
|
|
||||||
Note string `json:"note" validate:"max=500"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RevenueStatisticsResponse struct {
|
type RevenueStatisticsResponse struct {
|
||||||
Today OrdersStatistics `json:"today"`
|
Today OrdersStatistics `json:"today"`
|
||||||
Monthly OrdersStatistics `json:"monthly"`
|
Monthly OrdersStatistics `json:"monthly"`
|
||||||
@ -2581,7 +2582,6 @@ type UserSubscribe struct {
|
|||||||
Upload int64 `json:"upload"`
|
Upload int64 `json:"upload"`
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Status uint8 `json:"status"`
|
Status uint8 `json:"status"`
|
||||||
Note string `json:"note"`
|
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at"`
|
UpdatedAt int64 `json:"updated_at"`
|
||||||
}
|
}
|
||||||
@ -2601,7 +2601,6 @@ type UserSubscribeDetail struct {
|
|||||||
Upload int64 `json:"upload"`
|
Upload int64 `json:"upload"`
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Status uint8 `json:"status"`
|
Status uint8 `json:"status"`
|
||||||
Note string `json:"note"`
|
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at"`
|
UpdatedAt int64 `json:"updated_at"`
|
||||||
}
|
}
|
||||||
@ -2620,7 +2619,6 @@ type UserSubscribeInfo struct {
|
|||||||
Upload int64 `json:"upload"`
|
Upload int64 `json:"upload"`
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Status uint8 `json:"status"`
|
Status uint8 `json:"status"`
|
||||||
Note string `json:"note"`
|
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at"`
|
UpdatedAt int64 `json:"updated_at"`
|
||||||
IsTryOut bool `json:"is_try_out"`
|
IsTryOut bool `json:"is_try_out"`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user