feat: 互动处理
This commit is contained in:
@@ -21,6 +21,10 @@ type InteractionApi struct{}
|
||||
// @Router /history/add [post]
|
||||
func (a *InteractionApi) AddHistory(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.AddHistory
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
@@ -52,6 +56,10 @@ func (a *InteractionApi) DeleteHistory(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
err = interactionService.DeleteHistory(userId, req.ProgramId)
|
||||
if err != nil {
|
||||
global.Logger.Error("删除收听历史失败!", zap.Error(err))
|
||||
@@ -69,6 +77,10 @@ func (a *InteractionApi) DeleteHistory(c *gin.Context) {
|
||||
// @Router /history/deleteAllHistory [get]
|
||||
func (a *InteractionApi) DeleteAllHistory(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
err := interactionService.DeleteAllHistory(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("删除所有收听历史失败!", zap.Error(err))
|
||||
@@ -87,6 +99,10 @@ func (a *InteractionApi) DeleteAllHistory(c *gin.Context) {
|
||||
// @Router /history/list [post]
|
||||
func (a *InteractionApi) GetHistoryList(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.GetHistoryList
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
@@ -117,6 +133,10 @@ func (a *InteractionApi) GetHistoryList(c *gin.Context) {
|
||||
// @Router /like/toggle [post]
|
||||
func (a *InteractionApi) ToggleLike(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.ToggleLike
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
@@ -143,6 +163,10 @@ func (a *InteractionApi) ToggleLike(c *gin.Context) {
|
||||
// @Router /favorite/list [post]
|
||||
func (a *InteractionApi) GetFavoriteList(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.GetFavoriteList
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
@@ -173,6 +197,10 @@ func (a *InteractionApi) GetFavoriteList(c *gin.Context) {
|
||||
// @Router /favorite/add [post]
|
||||
func (a *InteractionApi) AddFavorite(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.AddFavorite
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
@@ -198,6 +226,10 @@ func (a *InteractionApi) AddFavorite(c *gin.Context) {
|
||||
// @Router /favorite/remove [post]
|
||||
func (a *InteractionApi) RemoveFavorite(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.RemoveFavorite
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
@@ -223,6 +255,10 @@ func (a *InteractionApi) RemoveFavorite(c *gin.Context) {
|
||||
// @Router /favorite/removeAll [get]
|
||||
func (a *InteractionApi) RemoveAllFavorite(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
err := interactionService.RemoveAllFavorite(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("清空所有收藏失败!", zap.Error(err))
|
||||
@@ -270,6 +306,10 @@ func (a *InteractionApi) GetCommentList(c *gin.Context) {
|
||||
// @Router /comment/add [post]
|
||||
func (a *InteractionApi) AddComment(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.AddComment
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
@@ -295,6 +335,10 @@ func (a *InteractionApi) AddComment(c *gin.Context) {
|
||||
// @Router /comment/delete [post]
|
||||
func (a *InteractionApi) DeleteComment(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
var req request.DeleteComment
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user