This commit is contained in:
toom1996
2026-09-02 21:51:35 +08:00
parent 2562fc4aaa
commit 1fd9c48f58
22 changed files with 908 additions and 30 deletions

View File

@ -20,6 +20,8 @@ type Options struct {
Brand *handler.BrandHandler
StreetSnap *handler.StreetSnapHandler
Auth *handler.AuthHandler
Favorite *handler.FavoriteHandler
History *handler.HistoryHandler
Health *handler.HealthHandler
SSG *handler.SSGHandler
}
@ -81,9 +83,20 @@ func New(opt Options) *gin.Engine {
auth.POST("/logout", opt.Auth.Logout)
// 全设备登出 / 踢下线:吊销该用户全部 refresh token
auth.POST("/logout-all", opt.Auth.LogoutAll)
// 取当前用户(需 Bearer)
auth.GET("/me", middleware.Auth(opt.JWT), opt.Auth.Me)
}
// 取当前用户(需 Bearer)
auth.GET("/me", middleware.Auth(opt.JWT), opt.Auth.Me)
// 收藏(需 Bearer):列表 / 新增 / 删除
auth.GET("/favorites", middleware.Auth(opt.JWT), opt.Favorite.List)
auth.POST("/favorites", middleware.Auth(opt.JWT), opt.Favorite.Add)
auth.DELETE("/favorites/:target_uid", middleware.Auth(opt.JWT), opt.Favorite.Remove)
// 批量校验:列表页把当前可见 id 发来,问哪些已收藏(与收藏总量解耦,10万也常数级)
auth.POST("/favorites/check", middleware.Auth(opt.JWT), opt.Favorite.Check)
// 浏览历史(需 Bearer):分页列表(可按 kind 过滤)/ 记录 / 删除 / 清空
auth.GET("/history", middleware.Auth(opt.JWT), opt.History.List)
auth.POST("/history", middleware.Auth(opt.JWT), opt.History.Record)
auth.DELETE("/history/:target_uid", middleware.Auth(opt.JWT), opt.History.Remove)
auth.DELETE("/history", middleware.Auth(opt.JWT), opt.History.Clear)
}
}
return r