web_ad.go 762 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. bm "go-common/library/net/http/blademaster"
  5. "go-common/library/net/metadata"
  6. "strconv"
  7. )
  8. // webAdGameList fn
  9. func webAdGameList(c *bm.Context) {
  10. ip := metadata.String(c, metadata.RemoteIP)
  11. params := c.Request.Form
  12. _, ok := c.Get("mid")
  13. if !ok {
  14. c.JSON(nil, ecode.NoLogin)
  15. return
  16. }
  17. pnStr := params.Get("pn")
  18. psStr := params.Get("ps")
  19. pn, err := strconv.Atoi(pnStr)
  20. if err != nil || pn <= 0 {
  21. pn = 1
  22. }
  23. ps, err := strconv.Atoi(psStr)
  24. if err != nil || ps <= 0 || ps > 20 {
  25. ps = 20
  26. }
  27. keywordStr := params.Get("keyword")
  28. letterStr := params.Get("letter")
  29. data, err := adSvc.GameList(c, keywordStr, letterStr, pn, ps, ip)
  30. if err != nil {
  31. c.JSON(nil, err)
  32. return
  33. }
  34. c.JSON(data, nil)
  35. }