feat: 渠道类型接口
This commit is contained in:
22
internal/handler/common_handler.go
Normal file
22
internal/handler/common_handler.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"gpt-load/internal/channel"
|
||||
"gpt-load/internal/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// CommonHandler handles common, non-grouped requests.
|
||||
type CommonHandler struct{}
|
||||
|
||||
// NewCommonHandler creates a new CommonHandler.
|
||||
func NewCommonHandler() *CommonHandler {
|
||||
return &CommonHandler{}
|
||||
}
|
||||
|
||||
// GetChannelTypes returns a list of available channel types.
|
||||
func (h *CommonHandler) GetChannelTypes(c *gin.Context) {
|
||||
channelTypes := channel.GetChannels()
|
||||
response.Success(c, channelTypes)
|
||||
}
|
@@ -23,6 +23,7 @@ type Server struct {
|
||||
KeyManualValidationService *services.KeyManualValidationService
|
||||
TaskService *services.TaskService
|
||||
KeyService *services.KeyService
|
||||
CommonHandler *CommonHandler
|
||||
}
|
||||
|
||||
// NewServer creates a new handler instance
|
||||
@@ -43,6 +44,7 @@ func NewServer(
|
||||
KeyManualValidationService: keyManualValidationService,
|
||||
TaskService: taskService,
|
||||
KeyService: keyService,
|
||||
CommonHandler: NewCommonHandler(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -99,6 +99,8 @@ func registerPublicAPIRoutes(api *gin.RouterGroup, serverHandler *handler.Server
|
||||
|
||||
// registerProtectedAPIRoutes 认证API路由
|
||||
func registerProtectedAPIRoutes(api *gin.RouterGroup, serverHandler *handler.Server, logCleanupHandler *handler.LogCleanupHandler) {
|
||||
api.GET("/channel-types", serverHandler.CommonHandler.GetChannelTypes)
|
||||
|
||||
groups := api.Group("/groups")
|
||||
{
|
||||
groups.POST("", serverHandler.CreateGroup)
|
||||
|
Reference in New Issue
Block a user