adv.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/admin/main/dm/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. // advList 高级弹幕列表
  9. func advList(c *bm.Context) {
  10. var (
  11. p = c.Request.Form
  12. pn = int64(1)
  13. ps = int64(50)
  14. )
  15. dmInid, err := strconv.ParseInt(p.Get("oid"), 10, 64)
  16. if err != nil || dmInid == 0 {
  17. c.JSON(nil, ecode.RequestErr)
  18. return
  19. }
  20. typ := p.Get("bType")
  21. if typ == "" {
  22. c.JSON(nil, ecode.RequestErr)
  23. return
  24. }
  25. mode := p.Get("mode")
  26. if mode == "" {
  27. c.JSON(nil, ecode.RequestErr)
  28. return
  29. }
  30. if p.Get("pn") != "" {
  31. if pn, err = strconv.ParseInt(p.Get("pn"), 10, 64); err != nil || pn <= 0 {
  32. c.JSON(nil, ecode.RequestErr)
  33. return
  34. }
  35. }
  36. if p.Get("ps") != "" {
  37. if ps, err = strconv.ParseInt(p.Get("ps"), 10, 64); err != nil {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. }
  42. result, total, err := dmSvc.Advances(c, dmInid, typ, mode, pn, ps)
  43. if err != nil {
  44. c.JSON(nil, err)
  45. return
  46. }
  47. pageInfo := &model.PageInfo{
  48. Num: pn,
  49. Size: ps,
  50. Total: total,
  51. }
  52. data := &model.AdvanceRes{
  53. Result: result,
  54. Page: pageInfo,
  55. }
  56. c.JSON(data, nil)
  57. }