feedback.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package http
  2. import (
  3. "net/http"
  4. "strconv"
  5. "go-common/app/interface/main/web/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. )
  10. func feedback(c *bm.Context) {
  11. var (
  12. mid, aid, tagID int64
  13. content, buvid string
  14. buvidCk *http.Cookie
  15. midStr interface{}
  16. ok bool
  17. err error
  18. )
  19. params := c.Request.Form
  20. content = params.Get("content")
  21. aidStr := params.Get("aid")
  22. if aidStr != "" {
  23. if aid, err = strconv.ParseInt(aidStr, 10, 64); err != nil {
  24. log.Warn("strconv.ParseInt(%s) err(%d)", aidStr, err)
  25. c.JSON(nil, ecode.RequestErr)
  26. return
  27. }
  28. }
  29. tagIDStr := params.Get("tag_id")
  30. if tagID, err = strconv.ParseInt(tagIDStr, 10, 64); err != nil || tagID < 1 {
  31. log.Warn("strconv.ParseInt(%s) error(%v)", tagIDStr, err)
  32. c.JSON(nil, ecode.RequestErr)
  33. return
  34. }
  35. if !model.CheckFeedTag(tagID) {
  36. log.Warn("tag_id(%d) check fail", tagID)
  37. c.JSON(nil, ecode.RequestErr)
  38. return
  39. }
  40. if buvidCk, err = c.Request.Cookie("buvid3"); err != nil {
  41. log.Warn("buvid3 is nil")
  42. c.JSON(nil, ecode.RequestErr)
  43. return
  44. }
  45. if buvid = buvidCk.Value; buvid == "" {
  46. log.Warn("buvid == nil")
  47. c.JSON(nil, ecode.RequestErr)
  48. return
  49. }
  50. if midStr, ok = c.Get("mid"); ok {
  51. mid = midStr.(int64)
  52. }
  53. browser := params.Get("browser")
  54. version := params.Get("version")
  55. email := params.Get("email")
  56. qq := params.Get("qq")
  57. other := params.Get("other")
  58. feedParams := &model.Feedback{Aid: aid, Mid: mid, TagID: tagID, Buvid: buvid, Browser: browser,
  59. Version: version, Content: &model.Content{Reason: content}, Email: email, QQ: qq, Other: other}
  60. c.JSON(nil, webSvc.Feedback(c, feedParams))
  61. }