update
This commit is contained in:
@ -94,7 +94,7 @@ func (h *ArticleHandler) Detail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
detail, err := h.articles.Detail(c.Request.Context(), strconv.FormatUint(uint64(numeric), 10), parseLocale(c))
|
||||
detail, err := h.articles.Detail(c.Request.Context(), strconv.FormatUint(uint64(numeric), 10), parseLocale(c), middleware.IsVIP(middleware.TierFrom(c)))
|
||||
if err != nil {
|
||||
fail(c, err)
|
||||
return
|
||||
|
||||
@ -23,7 +23,7 @@ func NewAuthHandler(auth service.AuthService) *AuthHandler {
|
||||
|
||||
// Me 当前登录用户,需 Authorization: Bearer <token>。
|
||||
//
|
||||
// GET /api/auth/me
|
||||
// GET /api/v1/me(旧别名 /api/v1/auth/me 已废弃)
|
||||
// 成功:200 { user }
|
||||
func (h *AuthHandler) Me(c *gin.Context) {
|
||||
userID, ok := middleware.UserIDFrom(c)
|
||||
@ -86,7 +86,7 @@ func (h *AuthHandler) Refresh(c *gin.Context) {
|
||||
|
||||
// Logout 吊销当前 refresh token(单设备登出)。
|
||||
//
|
||||
// POST /api/auth/logout
|
||||
// DELETE /api/v1/auth/sessions/current(旧别名 POST /api/v1/auth/logout 已废弃)
|
||||
// body: { refresh_token }
|
||||
// 成功:200 { ok: true }
|
||||
func (h *AuthHandler) Logout(c *gin.Context) {
|
||||
@ -105,7 +105,7 @@ func (h *AuthHandler) Logout(c *gin.Context) {
|
||||
|
||||
// LogoutAll 吊销当前用户全部 refresh token(踢下线 / 全设备登出)。
|
||||
//
|
||||
// POST /api/auth/logout-all
|
||||
// DELETE /api/v1/auth/sessions(旧别名 POST /api/v1/auth/logout-all 已废弃)
|
||||
// body: { refresh_token }
|
||||
// 成功:200 { revoked: <受影响行数> }
|
||||
func (h *AuthHandler) LogoutAll(c *gin.Context) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -24,7 +24,7 @@ func NewHistoryHandler(hist service.HistoryService) *HistoryHandler {
|
||||
|
||||
// List 当前用户浏览历史(服务端分页)。
|
||||
//
|
||||
// GET /api/v1/auth/history?page=1&per_page=24
|
||||
// GET /api/v1/me/history?page=1&per_page=24
|
||||
// 成功:200 { data: { items:[...], total, last_page } }
|
||||
func (h *HistoryHandler) List(c *gin.Context) {
|
||||
userID, ok := middleware.UserIDFrom(c)
|
||||
@ -54,7 +54,7 @@ func (h *HistoryHandler) List(c *gin.Context) {
|
||||
|
||||
// Record 记录一次浏览(点开文章详情;upsert:同文章刷新时间,不新增行)。
|
||||
//
|
||||
// POST /api/v1/auth/history
|
||||
// POST /api/v1/me/history
|
||||
// body: { target_uid } // 带 r=/s= 前缀的对外编码串
|
||||
// 成功:200 { data: { ok: true } }
|
||||
func (h *HistoryHandler) Record(c *gin.Context) {
|
||||
@ -77,7 +77,7 @@ func (h *HistoryHandler) Record(c *gin.Context) {
|
||||
|
||||
// Remove 删除一条历史。
|
||||
//
|
||||
// DELETE /api/v1/auth/history/:target_uid
|
||||
// DELETE /api/v1/me/history/:uid
|
||||
// 成功:200 { data: { ok: true } }
|
||||
func (h *HistoryHandler) Remove(c *gin.Context) {
|
||||
userID, ok := middleware.UserIDFrom(c)
|
||||
@ -85,7 +85,7 @@ func (h *HistoryHandler) Remove(c *gin.Context) {
|
||||
response.Error(c, http.StatusUnauthorized, "unauthorized")
|
||||
return
|
||||
}
|
||||
uid := c.Param("target_uid")
|
||||
uid := c.Param("uid")
|
||||
if err := h.hist.Remove(c.Request.Context(), userID, uid); err != nil {
|
||||
fail(c, err)
|
||||
return
|
||||
@ -95,7 +95,7 @@ func (h *HistoryHandler) Remove(c *gin.Context) {
|
||||
|
||||
// Clear 清空当前用户全部历史。
|
||||
//
|
||||
// DELETE /api/v1/auth/history
|
||||
// DELETE /api/v1/me/history
|
||||
// 成功:200 { data: { ok: true } }
|
||||
func (h *HistoryHandler) Clear(c *gin.Context) {
|
||||
userID, ok := middleware.UserIDFrom(c)
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"fashionapi/internal/dto"
|
||||
"fashionapi/internal/middleware"
|
||||
"fashionapi/internal/pkg/hashid"
|
||||
"fashionapi/internal/pkg/response"
|
||||
"fashionapi/internal/service"
|
||||
@ -78,7 +79,7 @@ func (h *StreetSnapHandler) Detail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
detail, err := h.svc.Detail(c.Request.Context(), strconv.FormatUint(uint64(numeric), 10))
|
||||
detail, err := h.svc.Detail(c.Request.Context(), strconv.FormatUint(uint64(numeric), 10), middleware.IsVIP(middleware.TierFrom(c)))
|
||||
if err != nil {
|
||||
fail(c, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user