Files
wx_service/internal/routes/admin_routes.go
T

117 lines
5.1 KiB
Go

package routes
import (
"github.com/gin-gonic/gin"
adminhandler "wx_service/internal/admin"
marketinghandler "wx_service/internal/marketing/handler"
)
func registerAdminRoutes(
router *gin.Engine,
handler *adminhandler.Handler,
categoryHandler *marketinghandler.CategoryHandler,
templateHandler *marketinghandler.TemplateHandler,
downloadHandler *marketinghandler.DownloadHandler,
) {
if handler == nil {
return
}
admin := router.Group("/api/admin")
{
admin.POST("/login", handler.Login)
protected := admin.Group("")
protected.Use(handler.AuthMiddleware())
{
protected.GET("/profile", handler.Profile)
protected.POST("/logout", handler.Logout)
protected.GET("/stats/overview", handler.StatsOverview)
protected.GET("/stats/mini-programs", handler.StatsMiniPrograms)
protected.GET("/stats/user-growth", handler.StatsUserGrowth)
protected.GET("/mini-programs", handler.ListMiniPrograms)
protected.GET("/mini-programs/:id", handler.GetMiniProgram)
protected.GET("/mini-programs/:id/stats", handler.GetMiniProgramStats)
protected.POST("/mini-programs", handler.CreateMiniProgram)
protected.PUT("/mini-programs/:id", handler.UpdateMiniProgram)
protected.DELETE("/mini-programs/:id", handler.DeleteMiniProgram)
protected.GET("/users", handler.ListUsers)
protected.GET("/users/:id", handler.GetUserDetail)
protected.GET("/settings", handler.GetSettings)
protected.PUT("/settings/profile", handler.UpdateProfile)
protected.GET("/settings/system", handler.GetSystemConfig)
protected.PUT("/settings/system", handler.UpdateSystemConfig)
protected.PUT("/settings/password", handler.UpdatePassword)
protected.GET("/watermark/video-parse-logs", handler.ListVideoParseLogs)
protected.GET("/watermark/video-parse-unlocks", handler.ListVideoParseUnlocks)
protected.GET("/watermark/video-download-failures", handler.ListVideoDownloadFailures)
// 戒烟小程序(fa_smoke)后台管理接口。
protected.GET("/smoke/logs", handler.ListSmokeLogs)
protected.GET("/smoke/logs/:id", handler.GetSmokeLog)
protected.POST("/smoke/logs", handler.CreateSmokeLog)
protected.PUT("/smoke/logs/:id", handler.UpdateSmokeLog)
protected.DELETE("/smoke/logs/:id", handler.DeleteSmokeLog)
protected.GET("/smoke/profiles", handler.ListSmokeProfiles)
protected.GET("/smoke/profiles/:id", handler.GetSmokeProfile)
protected.POST("/smoke/profiles", handler.CreateSmokeProfile)
protected.PUT("/smoke/profiles/:id", handler.UpdateSmokeProfile)
protected.DELETE("/smoke/profiles/:id", handler.DeleteSmokeProfile)
protected.GET("/smoke/ai-advices", handler.ListSmokeAIAdvices)
protected.GET("/smoke/ai-advices/:id", handler.GetSmokeAIAdvice)
protected.POST("/smoke/ai-advices", handler.CreateSmokeAIAdvice)
protected.PUT("/smoke/ai-advices/:id", handler.UpdateSmokeAIAdvice)
protected.DELETE("/smoke/ai-advices/:id", handler.DeleteSmokeAIAdvice)
protected.GET("/smoke/ai-unlocks", handler.ListSmokeAIUnlocks)
protected.GET("/smoke/ai-unlocks/:id", handler.GetSmokeAIUnlock)
protected.POST("/smoke/ai-unlocks", handler.CreateSmokeAIUnlock)
protected.PUT("/smoke/ai-unlocks/:id", handler.UpdateSmokeAIUnlock)
protected.DELETE("/smoke/ai-unlocks/:id", handler.DeleteSmokeAIUnlock)
protected.GET("/smoke/ai-next-smokes", handler.ListSmokeAINexts)
protected.GET("/smoke/ai-next-smokes/:id", handler.GetSmokeAINext)
protected.POST("/smoke/ai-next-smokes", handler.CreateSmokeAINext)
protected.PUT("/smoke/ai-next-smokes/:id", handler.UpdateSmokeAINext)
protected.DELETE("/smoke/ai-next-smokes/:id", handler.DeleteSmokeAINext)
protected.GET("/smoke/motivation-quotes", handler.ListSmokeMotivations)
protected.GET("/smoke/motivation-quotes/:id", handler.GetSmokeMotivation)
protected.POST("/smoke/motivation-quotes", handler.CreateSmokeMotivation)
protected.PUT("/smoke/motivation-quotes/:id", handler.UpdateSmokeMotivation)
protected.DELETE("/smoke/motivation-quotes/:id", handler.DeleteSmokeMotivation)
protected.GET("/memberships/overview", handler.MembershipOverview)
protected.GET("/memberships/redeem-codes", handler.ListMembershipRedeemCodes)
protected.POST("/memberships/redeem-codes", handler.CreateMembershipRedeemCodes)
protected.POST("/memberships/redeem-codes/:id/status", handler.UpdateMembershipRedeemCodeStatus)
if categoryHandler != nil && templateHandler != nil && downloadHandler != nil {
marketing := protected.Group("/marketing")
{
marketing.GET("/categories", categoryHandler.AdminList)
marketing.POST("/categories", categoryHandler.AdminCreate)
marketing.PUT("/categories/:id", categoryHandler.AdminUpdate)
marketing.DELETE("/categories/:id", categoryHandler.AdminDelete)
marketing.GET("/templates", templateHandler.AdminList)
marketing.POST("/templates", templateHandler.AdminCreate)
marketing.PUT("/templates/:id", templateHandler.AdminUpdate)
marketing.DELETE("/templates/:id", templateHandler.AdminDelete)
marketing.GET("/stats", downloadHandler.AdminStats)
marketing.POST("/upload/qiniu/token", downloadHandler.AdminQiniuToken)
}
}
}
}
}