report.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package http
  2. import (
  3. "strconv"
  4. "time"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. // viewArchive get archive info.
  10. func arcReport(c *bm.Context) {
  11. params := c.Request.Form
  12. midStr := params.Get("mid")
  13. aidStr := params.Get("aid")
  14. tpStr := params.Get("type")
  15. reason := params.Get("reason")
  16. pics := params.Get("pics")
  17. // check params
  18. mid, err := strconv.ParseInt(midStr, 10, 64)
  19. if err != nil {
  20. log.Error("strconv.ParseInt(%s) error(%v)", midStr, err)
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. aid, err := strconv.ParseInt(aidStr, 10, 64)
  25. if err != nil {
  26. log.Error("strconv.ParseInt(%s) error(%v)", aidStr, err)
  27. c.JSON(nil, ecode.RequestErr)
  28. return
  29. }
  30. tp, err := strconv.ParseInt(tpStr, 10, 64)
  31. if err != nil {
  32. log.Error("strconv.ParseInt(%s) error(%v)", tpStr, err)
  33. c.JSON(nil, ecode.RequestErr)
  34. return
  35. }
  36. if tp < 0 || tp > 9 {
  37. log.Error("type(%d) or question empty error(%v)", tp, err)
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. err = vdpSvc.ArcReport(c, mid, aid, int8(tp), reason, pics, time.Now())
  42. if err != nil {
  43. log.Error(" vdpSvc.ArcReport(%d,%d,%d,%s,%s) error(%v)", mid, aid, int8(tp), reason, pics, err)
  44. c.JSON(nil, ecode.RequestErr)
  45. return
  46. }
  47. c.JSON(nil, nil)
  48. }