2024-11-06 10:47:56 +00:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2024-11-06 12:35:16 +00:00
|
|
|
"leafdev.top/Ecosystem/recommender/internal/handler/http"
|
2024-11-06 10:47:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 两种方法都可以
|
|
|
|
//type Api struct {
|
|
|
|
// User *v1.UserController
|
|
|
|
//}
|
|
|
|
|
|
|
|
type Api struct {
|
2024-11-07 10:09:13 +00:00
|
|
|
h *http.Handlers
|
2024-11-06 10:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewApiRoute(
|
2024-11-07 10:09:13 +00:00
|
|
|
h *http.Handlers,
|
2024-11-06 10:47:56 +00:00
|
|
|
) *Api {
|
|
|
|
return &Api{
|
2024-11-07 10:09:13 +00:00
|
|
|
h,
|
2024-11-06 10:47:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Api) InitApiRouter(r *gin.RouterGroup) {
|
2024-11-07 12:00:06 +00:00
|
|
|
r.GET("/applications", a.h.ApplicationController.List)
|
|
|
|
r.POST("/applications", a.h.ApplicationController.Save)
|
|
|
|
r.GET("/application/:application_id/tokens", a.h.ApplicationController.ListToken)
|
|
|
|
r.POST("/application/:application_id/tokens", a.h.ApplicationController.SaveToken)
|
2024-11-06 10:47:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Api) InitNoAuthApiRouter(r *gin.RouterGroup) {
|
|
|
|
|
|
|
|
}
|
2024-11-07 12:00:06 +00:00
|
|
|
|
|
|
|
func (a *Api) InitApplicationApi(r *gin.RouterGroup) {
|
|
|
|
r.GET("/info", a.h.ApplicationApi.Info)
|
2024-11-07 18:25:15 +00:00
|
|
|
r.GET("/posts", a.h.ApplicationPostApi.List)
|
|
|
|
r.POST("/posts", a.h.ApplicationPostApi.Save)
|
|
|
|
r.DELETE("/post/:post_id", a.h.ApplicationPostApi.Delete)
|
|
|
|
r.GET("/post/:post_id", a.h.ApplicationPostApi.Get)
|
|
|
|
|
|
|
|
r.GET("/categories", a.h.ApplicationCategoryApi.List)
|
|
|
|
r.POST("/categories", a.h.ApplicationCategoryApi.Save)
|
|
|
|
r.GET("/categories/:category_id", a.h.ApplicationCategoryApi.Get)
|
|
|
|
r.DELETE("/categories/:category_id", a.h.ApplicationCategoryApi.Delete)
|
2024-11-09 16:11:00 +00:00
|
|
|
|
|
|
|
r.POST("/users/_like", a.h.ApplicationUserApi.Like)
|
|
|
|
r.POST("/users/_dislike", a.h.ApplicationUserApi.Dislike)
|
2024-11-09 19:49:53 +00:00
|
|
|
r.POST("/users/_suggest", a.h.ApplicationUserApi.Suggest)
|
2024-11-07 12:00:06 +00:00
|
|
|
}
|