comment.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package blog_service
  2. import (
  3. "gfast/plugin/blog/model/blog_comment"
  4. )
  5. // 添加
  6. func AddCommentSave(req *blog_comment.AddReq) error {
  7. err := blog_comment.AddSave(req)
  8. if err != nil {
  9. return err
  10. }
  11. if req.CommentPid != 0 {
  12. err = blog_comment.FindSonCommentCount(int(req.ReplyId)) // 每次添加评论都要更新所回复评论的回复数
  13. if err != nil {
  14. return err
  15. }
  16. }
  17. return nil
  18. }
  19. // 删除
  20. func DeleteCommentByIDs(Ids []int) error {
  21. return blog_comment.DeleteByIDs(Ids)
  22. }
  23. //修改
  24. func EditCommentSave(editReq *blog_comment.EditReq) error {
  25. return blog_comment.EditSave(editReq)
  26. }
  27. // 根据ID查询
  28. func GetCommentByID(id int64) (*blog_comment.Entity, error) {
  29. return blog_comment.GetCommentByID(id)
  30. }
  31. // 分页查询
  32. func SelectCommentListByPage(req *blog_comment.SelectPageReq) (total int, page int64, list []*blog_comment.ListEntity, err error) {
  33. blog_comment.FindUserAndLogIds(req)
  34. return blog_comment.SelectListByPage(req)
  35. }
  36. // GetChildren 将分页查出的实体切片中每一个元素的子评论查出来并添加进去
  37. func GetChildren(listEntity []*blog_comment.ListEntity) ([]*blog_comment.ListEntity, error) {
  38. return blog_comment.GetChildren(listEntity)
  39. }