feat: 互动处理
This commit is contained in:
+77
-18
@@ -15,10 +15,10 @@ type InteractionApi struct{}
|
||||
// AddHistory 添加收听历史
|
||||
// @Tags 用户互动
|
||||
// @Summary 添加收听历史
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.AddHistory true "收听信息"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/history/add [post]
|
||||
// @Router /history/add [post]
|
||||
func (a *InteractionApi) AddHistory(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.AddHistory
|
||||
@@ -37,13 +37,54 @@ func (a *InteractionApi) AddHistory(c *gin.Context) {
|
||||
response.OkWithMsg("添加成功", c)
|
||||
}
|
||||
|
||||
// DeleteHistory 删除收听历史
|
||||
// @Tags 用户互动
|
||||
// @Summary 删除收听历史
|
||||
// @Produce application/json
|
||||
// @Param id query string true "节目ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /history/delete [post]
|
||||
func (a *InteractionApi) DeleteHistory(c *gin.Context) {
|
||||
var req request.RemoveHistory
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
response.FailWithMsg("参数错误: "+err.Error(), c)
|
||||
return
|
||||
}
|
||||
userId := auth.GetUserId(c)
|
||||
err = interactionService.DeleteHistory(userId, req.ProgramId)
|
||||
if err != nil {
|
||||
global.Logger.Error("删除收听历史失败!", zap.Error(err))
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMsg("删除成功", c)
|
||||
}
|
||||
|
||||
// DeleteAllHistory 删除所有收听历史
|
||||
// @Tags 用户互动
|
||||
// @Summary 删除所有收听历史
|
||||
// @Produce application/json
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /history/deleteAllHistory [get]
|
||||
func (a *InteractionApi) DeleteAllHistory(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
err := interactionService.DeleteAllHistory(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("删除所有收听历史失败!", zap.Error(err))
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMsg("删除成功", c)
|
||||
}
|
||||
|
||||
// GetHistoryList 获取收听历史列表
|
||||
// @Tags 用户互动
|
||||
// @Summary 获取收听历史列表
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.GetHistoryList true "分页查询"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/history/list [post]
|
||||
// @Router /history/list [post]
|
||||
func (a *InteractionApi) GetHistoryList(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.GetHistoryList
|
||||
@@ -70,10 +111,10 @@ func (a *InteractionApi) GetHistoryList(c *gin.Context) {
|
||||
// ToggleLike 切换点赞状态
|
||||
// @Tags 用户互动
|
||||
// @Summary 切换点赞状态
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.ToggleLike true "节目ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/like/toggle [post]
|
||||
// @Router /like/toggle [post]
|
||||
func (a *InteractionApi) ToggleLike(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.ToggleLike
|
||||
@@ -96,10 +137,10 @@ func (a *InteractionApi) ToggleLike(c *gin.Context) {
|
||||
// GetFavoriteList 获取收藏列表
|
||||
// @Tags 用户互动
|
||||
// @Summary 获取收藏列表
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.GetFavoriteList true "分页查询"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/favorite/list [post]
|
||||
// @Router /favorite/list [post]
|
||||
func (a *InteractionApi) GetFavoriteList(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.GetFavoriteList
|
||||
@@ -126,10 +167,10 @@ func (a *InteractionApi) GetFavoriteList(c *gin.Context) {
|
||||
// AddFavorite 添加收藏
|
||||
// @Tags 用户互动
|
||||
// @Summary 添加收藏
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.AddFavorite true "节目ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/favorite/add [post]
|
||||
// @Router /favorite/add [post]
|
||||
func (a *InteractionApi) AddFavorite(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.AddFavorite
|
||||
@@ -151,10 +192,10 @@ func (a *InteractionApi) AddFavorite(c *gin.Context) {
|
||||
// RemoveFavorite 取消收藏
|
||||
// @Tags 用户互动
|
||||
// @Summary 取消收藏
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.RemoveFavorite true "节目ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/favorite/remove [post]
|
||||
// @Router /favorite/remove [post]
|
||||
func (a *InteractionApi) RemoveFavorite(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.RemoveFavorite
|
||||
@@ -173,13 +214,31 @@ func (a *InteractionApi) RemoveFavorite(c *gin.Context) {
|
||||
response.OkWithMsg("取消收藏成功", c)
|
||||
}
|
||||
|
||||
// RemoveAllFavorite 清空所有收藏
|
||||
// @Tags 用户互动
|
||||
// @Summary 清空所有收藏
|
||||
// @Produce application/json
|
||||
// @Param data body request.RemoveFavorite true "节目ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /favorite/removeAll [get]
|
||||
func (a *InteractionApi) RemoveAllFavorite(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
err := interactionService.RemoveAllFavorite(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("清空所有收藏失败!", zap.Error(err))
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMsg("清空所有收藏成功", c)
|
||||
}
|
||||
|
||||
// GetCommentList 获取评论列表
|
||||
// @Tags 用户互动
|
||||
// @Summary 获取评论列表
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.GetCommentList true "分页查询"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/comment/list [post]
|
||||
// @Router /comment/list [post]
|
||||
func (a *InteractionApi) GetCommentList(c *gin.Context) {
|
||||
var req request.GetCommentList
|
||||
err := c.ShouldBindJSON(&req)
|
||||
@@ -205,10 +264,10 @@ func (a *InteractionApi) GetCommentList(c *gin.Context) {
|
||||
// AddComment 添加评论
|
||||
// @Tags 用户互动
|
||||
// @Summary 添加评论
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.AddComment true "评论信息"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/comment/add [post]
|
||||
// @Router /comment/add [post]
|
||||
func (a *InteractionApi) AddComment(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.AddComment
|
||||
@@ -230,10 +289,10 @@ func (a *InteractionApi) AddComment(c *gin.Context) {
|
||||
// DeleteComment 删除评论
|
||||
// @Tags 用户互动
|
||||
// @Summary 删除评论
|
||||
// @Produce json
|
||||
// @Produce application/json
|
||||
// @Param data body request.DeleteComment true "评论ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /radio/comment/delete [post]
|
||||
// @Router /comment/delete [post]
|
||||
func (a *InteractionApi) DeleteComment(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
var req request.DeleteComment
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
common "sundynix-go/model/commom/request"
|
||||
"sundynix-go/model/commom/response"
|
||||
"sundynix-go/model/radio/request"
|
||||
"sundynix-go/utils/auth"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
@@ -55,7 +56,8 @@ func (a *ProgramApi) GetProgramDetail(c *gin.Context) {
|
||||
response.FailWithMsg("参数错误: id不能为空", c)
|
||||
return
|
||||
}
|
||||
program, err := programService.GetProgramById(id)
|
||||
userId := auth.GetUserId(c)
|
||||
program, err := programService.GetProgramById(id, userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("获取节目详情失败!", zap.Error(err))
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
|
||||
Reference in New Issue
Block a user