This commit is contained in:
toom1996
2026-09-07 00:01:48 +08:00
parent b049104a0b
commit 74ba700598
31 changed files with 1113 additions and 606 deletions

View File

@ -24,7 +24,7 @@ func NewFavoriteHandler(favs service.FavoriteService) *FavoriteHandler {
// List 当前用户收藏(服务端分页)。
//
// GET /api/v1/auth/favorites?page=1&per_page=24&kind=(per_page 上限 100)
// GET /api/v1/me/favorites?page=1&per_page=24&kind=(per_page 上限 100)
// kind 留空=不限粒度;gallery=只要图集收藏;image=只要单图收藏。
// 成功:200 { data: { items:[...], total, last_page } }
func (h *FavoriteHandler) List(c *gin.Context) {
@ -60,7 +60,7 @@ func (h *FavoriteHandler) List(c *gin.Context) {
// Add 新增收藏(幂等:重复添加不报错)。
//
// POST /api/v1/auth/favorites
// POST /api/v1/me/favorites
// body: { target_type, target_uid, title?, cover?, brand? }
// 成功:200 { data: <FavoriteItem> }
func (h *FavoriteHandler) Add(c *gin.Context) {
@ -84,7 +84,7 @@ func (h *FavoriteHandler) Add(c *gin.Context) {
// Remove 删除收藏。
//
// DELETE /api/v1/auth/favorites/:target_uid
// DELETE /api/v1/me/favorites/:uid
// 成功:200 { data: { ok: true } }
func (h *FavoriteHandler) Remove(c *gin.Context) {
userID, ok := middleware.UserIDFrom(c)
@ -92,7 +92,7 @@ func (h *FavoriteHandler) Remove(c *gin.Context) {
response.Error(c, http.StatusUnauthorized, "unauthorized")
return
}
uid := c.Param("target_uid")
uid := c.Param("uid")
if err := h.favs.Remove(c.Request.Context(), userID, uid); err != nil {
fail(c, err)
return
@ -102,7 +102,7 @@ func (h *FavoriteHandler) Remove(c *gin.Context) {
// Check 批量查询给定 ids 中哪些已收藏(列表页打勾用,与收藏总量解耦)。
//
// POST /api/v1/auth/favorites/check
// POST /api/v1/me/favorites/check
// body: { ids: ["r=...","s=..."] }
// 成功:200 { data: ["r=..."] }(仅返回已收藏的 id)
func (h *FavoriteHandler) Check(c *gin.Context) {