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 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)