feedback.go 779 B

12345678910111213141516171819202122232425262728293031323334
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/interface/main/web/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. // Feedback web player feedback.
  10. func (s *Service) Feedback(c context.Context, feedParams *model.Feedback) (err error) {
  11. var location string
  12. if feedParams.Other != "" {
  13. if location, err = s.upload(c, feedParams.Other); err != nil {
  14. log.Error("s.upload error(%v)", err)
  15. err = nil
  16. } else {
  17. feedParams.Content.URL = location
  18. }
  19. }
  20. err = s.dao.Feedback(c, feedParams)
  21. return
  22. }
  23. func (s *Service) upload(c context.Context, Other string) (location string, err error) {
  24. if len(Other) > s.c.Bfs.MaxFileSize {
  25. err = ecode.FeedbackBodyTooLarge
  26. return
  27. }
  28. location, err = s.dao.Upload(c, Other, time.Now().Unix())
  29. return
  30. }