plat_followup_comment.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package plat
  2. import (
  3. "context"
  4. "dashoo.cn/opms_libary/myerrors"
  5. "github.com/gogf/gf/frame/g"
  6. "github.com/gogf/gf/util/gconv"
  7. "dashoo.cn/micro/app/dao/plat"
  8. model "dashoo.cn/micro/app/model/plat"
  9. "dashoo.cn/micro/app/service"
  10. )
  11. type followupCommentService struct {
  12. *service.ContextService
  13. Dao *plat.PlatFollowupCommentDao
  14. }
  15. func NewFollowupCommentService(ctx context.Context) (svc *followupCommentService, err error) {
  16. svc = new(followupCommentService)
  17. if svc.ContextService, err = svc.Init(ctx); err != nil {
  18. return nil, err
  19. }
  20. svc.Dao = plat.NewPlatFollowupCommentDao(svc.Tenant)
  21. return svc, nil
  22. }
  23. // 跟进记录留言信息列表
  24. func (s *followupCommentService) GetList(req *model.SearchPlatFollowupCommentReq) (total int, followupCommentList []*model.PlatFollowupComment, err error) {
  25. followupCommentModel := s.Dao.M
  26. if req.FollowId != "" {
  27. followupCommentModel = followupCommentModel.Where("follow_id", req.FollowId)
  28. }
  29. if req.Pid != "" {
  30. followupCommentModel = followupCommentModel.Where("pid", req.Pid)
  31. }
  32. total, err = followupCommentModel.Count()
  33. if err != nil {
  34. g.Log().Error(err)
  35. err = myerrors.DbError("获取总行数失败。")
  36. return
  37. }
  38. err = followupCommentModel.Order("created_time DESC").Scan(&followupCommentList)
  39. return
  40. }
  41. // 添加信息
  42. func (s *followupCommentService) Create(req *model.AddPlatFollowupCommentReq) (err error) {
  43. platFollowupComment := new(model.PlatFollowupComment)
  44. if err = gconv.Struct(req, platFollowupComment); err != nil {
  45. return
  46. }
  47. // 填充创建信息
  48. service.SetCreatedInfo(platFollowupComment, s.GetCxtUserId(), s.GetCxtUserName())
  49. // 填充更新信息
  50. //service.SetUpdatedInfo(platFollowupComment, s.GetCxtUserId(), s.GetCxtUserName())
  51. _, err = s.Dao.Insert(platFollowupComment)
  52. if err != nil {
  53. return
  54. }
  55. return
  56. }