archive.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/service/main/archive/model/archive"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/xstr"
  9. )
  10. // arcInfo write the archive data.
  11. func arcInfo(c *bm.Context) {
  12. var (
  13. err error
  14. aid int64
  15. )
  16. params := c.Request.Form
  17. aidStr := params.Get("aid")
  18. // check params
  19. aid, err = strconv.ParseInt(aidStr, 10, 64)
  20. if err != nil {
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. c.JSON(arcSvc.Archive3(c, aid))
  25. }
  26. // archives write the archives data.
  27. func archives(c *bm.Context) {
  28. params := c.Request.Form
  29. aidsStr := params.Get("aids")
  30. // check params
  31. aids, err := xstr.SplitInts(aidsStr)
  32. if err != nil {
  33. log.Error("query aids(%s) split error(%v)", aidsStr, err)
  34. c.JSON(nil, ecode.RequestErr)
  35. return
  36. }
  37. if params.Get("appkey") == "fb06a25c6338edbc" && len(aids) > 50 {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. if len(aids) > 50 {
  42. log.Error("Too many Args aids(%d) caller(%s)", len(aids), params.Get("appkey"))
  43. }
  44. c.JSON(arcSvc.Archives3(c, aids))
  45. }
  46. // archivesWithPlayer write the archives data.
  47. func archivesWithPlayer(c *bm.Context) {
  48. params := c.Request.Form
  49. aidsStr := params.Get("aids")
  50. qnStr := params.Get("qn")
  51. pt := params.Get("platform")
  52. ip := params.Get("ip")
  53. fnver, _ := strconv.Atoi(params.Get("fnver"))
  54. fnval, _ := strconv.Atoi(params.Get("fnval"))
  55. forceHost, _ := strconv.Atoi(params.Get("force_host"))
  56. session := params.Get("session")
  57. containsPGC, _ := strconv.Atoi(params.Get("contains_pgc"))
  58. build, _ := strconv.Atoi(params.Get("build"))
  59. // check params
  60. aids, err := xstr.SplitInts(aidsStr)
  61. if err != nil {
  62. log.Error("query aids(%s) split error(%v)", aidsStr, err)
  63. c.JSON(nil, ecode.RequestErr)
  64. return
  65. }
  66. if len(aids) > 50 {
  67. c.JSON(nil, ecode.RequestErr)
  68. return
  69. }
  70. qn, _ := strconv.Atoi(qnStr)
  71. c.JSON(arcSvc.ArchivesWithPlayer(c, &archive.ArgPlayer{
  72. Aids: aids,
  73. Qn: qn,
  74. Platform: pt,
  75. Build: build,
  76. RealIP: ip,
  77. Fnval: fnval,
  78. Fnver: fnver,
  79. Session: session,
  80. ForceHost: forceHost,
  81. }, containsPGC == 1))
  82. }
  83. func typelist(c *bm.Context) {
  84. c.JSON(arcSvc.AllTypes(c), nil)
  85. }
  86. func maxAID(c *bm.Context) {
  87. c.JSON(arcSvc.MaxAID(c))
  88. }