wechat.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package http
  2. import (
  3. "go-common/app/interface/main/web/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func wxHot(c *bm.Context) {
  7. v := new(struct {
  8. Pn int `form:"pn" default:"1" validate:"min=1"`
  9. Ps int `form:"ps" default:"100" validate:"min=1"`
  10. })
  11. if err := c.Bind(v); err != nil {
  12. return
  13. }
  14. list, count, err := webSvc.WxHot(c, v.Pn, v.Ps)
  15. if err != nil {
  16. c.JSON(nil, err)
  17. return
  18. }
  19. data := make(map[string]interface{}, 2)
  20. page := map[string]int{
  21. "pn": v.Pn,
  22. "ps": v.Ps,
  23. "count": count,
  24. }
  25. data["data"] = list
  26. data["page"] = page
  27. c.JSONMap(data, nil)
  28. }
  29. func wxSearchAll(c *bm.Context) {
  30. var (
  31. mid int64
  32. buvid string
  33. err error
  34. )
  35. v := new(model.SearchAllArg)
  36. if err = c.Bind(v); err != nil {
  37. return
  38. }
  39. if v.Pn <= 0 {
  40. v.Pn = 1
  41. }
  42. if ck, err := c.Request.Cookie("buvid3"); err == nil {
  43. buvid = ck.Value
  44. }
  45. if midInter, ok := c.Get("mid"); ok {
  46. mid = midInter.(int64)
  47. }
  48. c.JSON(webSvc.SearchAll(c, mid, v, buvid, c.Request.Header.Get("User-Agent"), model.WxSearchType))
  49. }