111498a65f
- Removed schema_json from article templates and related queries. - Updated brand service to include website field in requests and responses. - Simplified template wizard view by eliminating unused schema fields and related logic. - Added tests for ark text format handling. - Created migrations for dropping schema_json and adding website to brands.
99 lines
4.1 KiB
Go
99 lines
4.1 KiB
Go
package transport
|
|
|
|
import (
|
|
"github.com/geo-platform/tenant-api/internal/bootstrap"
|
|
"github.com/geo-platform/tenant-api/internal/shared/auth"
|
|
"github.com/geo-platform/tenant-api/internal/shared/middleware"
|
|
)
|
|
|
|
func RegisterRoutes(app *bootstrap.App) {
|
|
authAPI := app.Engine.Group("/api/auth")
|
|
authHandler := NewAuthHandler(app)
|
|
authAPI.POST("/login", authHandler.Login)
|
|
authAPI.POST("/refresh", authHandler.Refresh)
|
|
|
|
protected := app.Engine.Group("/api")
|
|
protected.Use(auth.Middleware(app.JWT, app.Sessions))
|
|
protected.Use(middleware.TenantScope())
|
|
|
|
protected.GET("/auth/me", authHandler.Me)
|
|
protected.POST("/auth/logout", authHandler.Logout)
|
|
|
|
workspace := protected.Group("/tenant/workspace")
|
|
wsHandler := NewWorkspaceHandler(app)
|
|
workspace.GET("/overview", wsHandler.Overview)
|
|
workspace.GET("/recent-articles", wsHandler.RecentArticles)
|
|
workspace.GET("/quota-summary", wsHandler.QuotaSummary)
|
|
workspace.GET("/template-cards", wsHandler.TemplateCards)
|
|
|
|
templates := protected.Group("/tenant/templates")
|
|
tplHandler := NewTemplateHandler(app)
|
|
templates.GET("", tplHandler.List)
|
|
templates.GET("/:id", tplHandler.Detail)
|
|
templates.POST("/:id/drafts", tplHandler.SaveDraft)
|
|
templates.POST("/:id/analyze-tasks", tplHandler.CreateAnalyzeTask)
|
|
templates.GET("/:id/analyze_task_result", tplHandler.GetAnalyzeTaskResult)
|
|
templates.POST("/:id/title-tasks", tplHandler.CreateTitleTask)
|
|
templates.GET("/:id/gen_title_task_result", tplHandler.GetTitleTaskResult)
|
|
templates.POST("/:id/outline-tasks", tplHandler.CreateOutlineTask)
|
|
templates.GET("/:id/gen_outline_task_result", tplHandler.GetOutlineTaskResult)
|
|
templates.POST("/:id/generate", tplHandler.Generate)
|
|
|
|
articles := protected.Group("/tenant/articles")
|
|
artHandler := NewArticleHandler(app)
|
|
articles.GET("", artHandler.List)
|
|
articles.POST("/generate-from-rule", artHandler.GenerateFromRule)
|
|
articles.GET("/:id", artHandler.Detail)
|
|
articles.PUT("/:id", artHandler.Update)
|
|
articles.GET("/:id/stream", artHandler.Stream)
|
|
articles.GET("/:id/versions", artHandler.Versions)
|
|
articles.DELETE("/:id", artHandler.Delete)
|
|
|
|
brands := protected.Group("/tenant/brands")
|
|
brandHandler := NewBrandHandler(app)
|
|
brands.GET("", brandHandler.List)
|
|
brands.POST("", brandHandler.Create)
|
|
brands.GET("/:id", brandHandler.Detail)
|
|
brands.PUT("/:id", brandHandler.Update)
|
|
brands.DELETE("/:id", brandHandler.Delete)
|
|
brands.GET("/:id/keywords", brandHandler.ListKeywords)
|
|
brands.POST("/:id/keywords", brandHandler.CreateKeyword)
|
|
brands.PUT("/:id/keywords/:kid", brandHandler.UpdateKeyword)
|
|
brands.DELETE("/:id/keywords/:kid", brandHandler.DeleteKeyword)
|
|
brands.GET("/:id/questions", brandHandler.ListQuestions)
|
|
brands.POST("/:id/questions", brandHandler.CreateQuestion)
|
|
brands.PUT("/:id/questions/:qid", brandHandler.UpdateQuestion)
|
|
brands.DELETE("/:id/questions/:qid", brandHandler.DeleteQuestion)
|
|
brands.GET("/:id/question-versions", brandHandler.ListQuestionVersions)
|
|
brands.GET("/:id/competitors", brandHandler.ListCompetitors)
|
|
brands.POST("/:id/competitors", brandHandler.CreateCompetitor)
|
|
brands.PUT("/:id/competitors/:cid", brandHandler.UpdateCompetitor)
|
|
brands.DELETE("/:id/competitors/:cid", brandHandler.DeleteCompetitor)
|
|
|
|
// Prompt Rules
|
|
promptRules := protected.Group("/tenant/prompt-rules")
|
|
prHandler := NewPromptRuleHandler(app)
|
|
promptRules.GET("", prHandler.List)
|
|
promptRules.GET("/simple", prHandler.ListSimple)
|
|
promptRules.POST("", prHandler.Create)
|
|
promptRules.GET("/:id", prHandler.Detail)
|
|
promptRules.PUT("/:id", prHandler.Update)
|
|
promptRules.DELETE("/:id", prHandler.Delete)
|
|
promptRules.PUT("/:id/status", prHandler.ToggleStatus)
|
|
// Prompt Rule Groups
|
|
promptRules.GET("/groups", prHandler.ListGroups)
|
|
promptRules.POST("/groups", prHandler.CreateGroup)
|
|
promptRules.PUT("/groups/:gid", prHandler.UpdateGroup)
|
|
promptRules.DELETE("/groups/:gid", prHandler.DeleteGroup)
|
|
|
|
// Schedule Tasks
|
|
schedules := protected.Group("/tenant/schedules")
|
|
schHandler := NewScheduleTaskHandler(app)
|
|
schedules.GET("", schHandler.List)
|
|
schedules.POST("", schHandler.Create)
|
|
schedules.GET("/:id", schHandler.Detail)
|
|
schedules.PUT("/:id", schHandler.Update)
|
|
schedules.DELETE("/:id", schHandler.Delete)
|
|
schedules.PUT("/:id/status", schHandler.ToggleStatus)
|
|
}
|