complaint.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/openplatform/article/conf"
  5. "go-common/app/interface/openplatform/article/dao"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/net/metadata"
  10. )
  11. func addComplaint(c *bm.Context) {
  12. var (
  13. err error
  14. mid, aid, cid int64
  15. params = c.Request.Form
  16. ip = metadata.String(c, metadata.RemoteIP)
  17. reason, imageUrls string
  18. )
  19. midInter, _ := c.Get("mid")
  20. mid = midInter.(int64)
  21. aidStr := params.Get("aid")
  22. if aid, err = strconv.ParseInt(aidStr, 10, 64); err != nil || aid <= 0 {
  23. c.JSON(nil, ecode.RequestErr)
  24. return
  25. }
  26. cidStr := params.Get("cid")
  27. if cid, err = strconv.ParseInt(cidStr, 10, 64); err != nil || cid <= 0 {
  28. c.JSON(nil, ecode.RequestErr)
  29. return
  30. }
  31. reason = params.Get("reason")
  32. if int64(len([]rune(reason))) > conf.Conf.Article.MaxComplaintReasonLimit {
  33. c.JSON(nil, ecode.RequestErr)
  34. return
  35. }
  36. imageUrls = params.Get("images")
  37. if err = artSrv.AddComplaint(c, aid, mid, cid, reason, imageUrls, ip); err != nil {
  38. dao.PromError("新增投诉")
  39. log.Error("artSrv.AddComplaint(%d,%d,%d, %s, %s) error(%+v)", mid, aid, cid, reason, imageUrls, err)
  40. }
  41. c.JSON(nil, err)
  42. }