resource.go 907 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func kv(c *bm.Context) {
  8. c.JSON(webSvc.Kv(c))
  9. }
  10. func cmtbox(c *bm.Context) {
  11. var (
  12. id int64
  13. err error
  14. )
  15. params := c.Request.Form
  16. idStr := params.Get("id")
  17. if id, err = strconv.ParseInt(idStr, 10, 64); err != nil || id <= 0 {
  18. c.JSON(nil, ecode.RequestErr)
  19. return
  20. }
  21. c.JSON(webSvc.CmtBox(c, id))
  22. }
  23. func abServer(c *bm.Context) {
  24. var (
  25. mid int64
  26. buvid string
  27. )
  28. v := new(struct {
  29. Channel string `form:"channel"`
  30. Platform int `form:"platform"`
  31. })
  32. if err := c.Bind(v); err != nil {
  33. return
  34. }
  35. if ck, err := c.Request.Cookie("buvid3"); err == nil {
  36. buvid = ck.Value
  37. }
  38. if buvid == "" {
  39. c.JSON(nil, ecode.RequestErr)
  40. return
  41. }
  42. if midInter, ok := c.Get("mid"); ok {
  43. mid = midInter.(int64)
  44. }
  45. c.JSON(webSvc.AbServer(c, mid, v.Platform, v.Channel, buvid))
  46. }