update
This commit is contained in:
@ -24,7 +24,8 @@ func NewFavoriteHandler(favs service.FavoriteService) *FavoriteHandler {
|
||||
|
||||
// List 当前用户收藏(服务端分页)。
|
||||
//
|
||||
// GET /api/v1/auth/favorites?page=1&per_page=24(per_page 上限 100)
|
||||
// GET /api/v1/auth/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) {
|
||||
userID, ok := middleware.UserIDFrom(c)
|
||||
@ -40,7 +41,12 @@ func (h *FavoriteHandler) List(c *gin.Context) {
|
||||
if perPage < 1 || perPage > 100 {
|
||||
perPage = 24
|
||||
}
|
||||
items, total, err := h.favs.ListPaged(c.Request.Context(), userID, page, perPage)
|
||||
kind := c.Query("kind")
|
||||
if kind != "" && kind != dto.FavoriteKindGallery && kind != dto.FavoriteKindImage {
|
||||
response.Error(c, http.StatusBadRequest, "invalid kind")
|
||||
return
|
||||
}
|
||||
items, total, err := h.favs.ListPaged(c.Request.Context(), userID, page, perPage, kind)
|
||||
if err != nil {
|
||||
fail(c, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user