49 lines
2.2 KiB
Go
49 lines
2.2 KiB
Go
|
|
package routes
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"go.uber.org/zap"
|
||
|
|
|
||
|
|
"tyapi-server/internal/infrastructure/http/handlers"
|
||
|
|
"tyapi-server/internal/shared/interfaces"
|
||
|
|
)
|
||
|
|
|
||
|
|
// UIComponentRoutes UI组件路由
|
||
|
|
type UIComponentRoutes struct {
|
||
|
|
uiComponentHandler *handlers.UIComponentHandler
|
||
|
|
logger *zap.Logger
|
||
|
|
}
|
||
|
|
|
||
|
|
// NewUIComponentRoutes 创建UI组件路由
|
||
|
|
func NewUIComponentRoutes(
|
||
|
|
uiComponentHandler *handlers.UIComponentHandler,
|
||
|
|
logger *zap.Logger,
|
||
|
|
) *UIComponentRoutes {
|
||
|
|
return &UIComponentRoutes{
|
||
|
|
uiComponentHandler: uiComponentHandler,
|
||
|
|
logger: logger,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// RegisterRoutes 注册UI组件路由
|
||
|
|
func (r *UIComponentRoutes) RegisterRoutes(router *gin.RouterGroup, authMiddleware interfaces.Middleware) {
|
||
|
|
uiComponentGroup := router.Group("/ui-components")
|
||
|
|
uiComponentGroup.Use(authMiddleware.Handle())
|
||
|
|
{
|
||
|
|
// UI组件管理
|
||
|
|
uiComponentGroup.POST("", r.uiComponentHandler.CreateUIComponent) // 创建UI组件
|
||
|
|
uiComponentGroup.POST("/create-with-file", r.uiComponentHandler.CreateUIComponentWithFile) // 创建UI组件并上传文件
|
||
|
|
uiComponentGroup.GET("", r.uiComponentHandler.ListUIComponents) // 获取UI组件列表
|
||
|
|
uiComponentGroup.GET("/:id", r.uiComponentHandler.GetUIComponent) // 获取UI组件详情
|
||
|
|
uiComponentGroup.PUT("/:id", r.uiComponentHandler.UpdateUIComponent) // 更新UI组件
|
||
|
|
uiComponentGroup.DELETE("/:id", r.uiComponentHandler.DeleteUIComponent) // 删除UI组件
|
||
|
|
|
||
|
|
// 文件操作
|
||
|
|
uiComponentGroup.POST("/:id/upload", r.uiComponentHandler.UploadUIComponentFile) // 上传UI组件文件
|
||
|
|
uiComponentGroup.POST("/:id/upload-extract", r.uiComponentHandler.UploadAndExtractUIComponentFile) // 上传并解压UI组件文件
|
||
|
|
uiComponentGroup.GET("/:id/folder-content", r.uiComponentHandler.GetUIComponentFolderContent) // 获取UI组件文件夹内容
|
||
|
|
uiComponentGroup.DELETE("/:id/folder", r.uiComponentHandler.DeleteUIComponentFolder) // 删除UI组件文件夹
|
||
|
|
uiComponentGroup.GET("/:id/download", r.uiComponentHandler.DownloadUIComponentFile) // 下载UI组件文件
|
||
|
|
}
|
||
|
|
}
|