Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbbbbbbbbba committed May 4, 2023
1 parent 3f1e522 commit 3b44810
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions server/services/user_like_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (s *userLikeService) TopicLike(userId int64, topicId int64) error {
return err
}
// 更新点赞数
return tx.Exec("update t_topic set like_count = like_count + 1 where id = ?", topicId).Error
return repositories.TopicRepository.UpdateColumn(tx, topicId, "like_count", gorm.Expr("like_count + 1"))
}); err != nil {
return err
}
Expand All @@ -118,7 +118,6 @@ func (s *userLikeService) TopicLike(userId int64, topicId int64) error {
EntityId: topicId,
EntityType: constants.EntityTopic,
})

return nil
}

Expand All @@ -144,7 +143,6 @@ func (s *userLikeService) TopicUnLike(userId int64, topicId int64) error {
EntityId: topicId,
EntityType: constants.EntityTopic,
})

return nil
}

Expand All @@ -158,7 +156,7 @@ func (s *userLikeService) ArticleLike(userId int64, articleId int64) error {
return err
}
// 更新点赞数
return repositories.ArticleRepository.UpdateColumn(tx, articleId, "like_count", gorm.Expr("like_count - 1"))
return repositories.ArticleRepository.UpdateColumn(tx, articleId, "like_count", gorm.Expr("like_count + 1"))
}); err != nil {
return err
}
Expand Down Expand Up @@ -194,7 +192,6 @@ func (s *userLikeService) ArticleUnLike(userId int64, articleId int64) error {
EntityId: articleId,
EntityType: constants.EntityArticle,
})

return nil
}

Expand All @@ -221,7 +218,6 @@ func (s *userLikeService) CommentLike(userId int64, commentId int64) error {
EntityId: commentId,
EntityType: constants.EntityComment,
})

return nil
}

Expand All @@ -248,7 +244,6 @@ func (s *userLikeService) CommentUnLike(userId int64, commentId int64) error {
EntityId: commentId,
EntityType: constants.EntityComment,
})

return nil
}

Expand Down

0 comments on commit 3b44810

Please sign in to comment.