rank.go 789 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package http
  2. import (
  3. "strconv"
  4. artmdl "go-common/app/interface/openplatform/article/model"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/metadata"
  7. )
  8. func rankCategories(c *bm.Context) {
  9. c.JSON(artSrv.RankCategories(c), nil)
  10. }
  11. func ranks(c *bm.Context) {
  12. var (
  13. request = c.Request
  14. params = request.Form
  15. cid, mid int64
  16. )
  17. cid, _ = strconv.ParseInt(params.Get("cid"), 10, 64)
  18. if midInter, ok := c.Get("mid"); ok {
  19. mid = midInter.(int64)
  20. }
  21. data, note, err := artSrv.Ranks(c, cid, mid, metadata.String(c, metadata.RemoteIP))
  22. if err != nil {
  23. c.JSON(nil, err)
  24. return
  25. }
  26. if data == nil {
  27. data = []*artmdl.RankMeta{}
  28. }
  29. res := make(map[string]interface{})
  30. res["data"] = data
  31. res["note"] = note
  32. res["message"] = "ok"
  33. c.JSONMap(res, nil)
  34. }