relation.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package http
  2. import (
  3. "time"
  4. "go-common/app/admin/main/relation/model"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func followers(c *bm.Context) {
  8. params := &model.FollowersParam{}
  9. if err := c.Bind(params); err != nil {
  10. return
  11. }
  12. if params.PN <= 0 {
  13. params.PN = 1
  14. }
  15. if params.PS <= 0 {
  16. params.PS = 50
  17. }
  18. params.Order = "mtime"
  19. if params.Sort != "desc" {
  20. params.Sort = "asc"
  21. }
  22. c.JSON(svc.Followers(c, params))
  23. }
  24. func followings(c *bm.Context) {
  25. params := &model.FollowingsParam{}
  26. if err := c.Bind(params); err != nil {
  27. return
  28. }
  29. if params.PN <= 0 {
  30. params.PN = 1
  31. }
  32. if params.PS <= 0 {
  33. params.PS = 50
  34. }
  35. params.Order = "mtime"
  36. if params.Sort != "desc" {
  37. params.Sort = "asc"
  38. }
  39. c.JSON(svc.Followings(c, params))
  40. }
  41. func logs(c *bm.Context) {
  42. params := &model.LogsParam{}
  43. if err := c.Bind(params); err != nil {
  44. return
  45. }
  46. now := time.Now()
  47. from := time.Unix(0, 0)
  48. c.JSON(svc.RelationLog(c, params.Mid, params.Fid, from, now))
  49. }
  50. func stat(ctx *bm.Context) {
  51. params := &model.ArgMid{}
  52. if err := ctx.Bind(params); err != nil {
  53. return
  54. }
  55. ctx.JSON(svc.Stat(ctx, params))
  56. }
  57. func stats(ctx *bm.Context) {
  58. params := &model.ArgMids{}
  59. if err := ctx.Bind(params); err != nil {
  60. return
  61. }
  62. ctx.JSON(svc.Stats(ctx, params))
  63. }