likes.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package http
  2. import (
  3. "go-common/app/admin/main/activity/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func likesList(c *bm.Context) {
  7. arg := new(model.LikesParam)
  8. if err := c.Bind(arg); err != nil {
  9. return
  10. }
  11. c.JSON(actSrv.LikesList(c, arg))
  12. }
  13. func likes(c *bm.Context) {
  14. var args struct {
  15. Sid int64 `form:"sid" validate:"min=1,required"`
  16. Lids []int64 `form:"lids,split" validate:"min=1,max=50,dive,min=1"`
  17. }
  18. if err := c.Bind(&args); err != nil {
  19. return
  20. }
  21. c.JSON(actSrv.Likes(c, args.Sid, args.Lids))
  22. }
  23. func addLike(c *bm.Context) {
  24. args := new(model.AddLikes)
  25. if err := c.Bind(args); err != nil {
  26. return
  27. }
  28. c.JSON(actSrv.AddLike(c, args))
  29. }
  30. func upLike(c *bm.Context) {
  31. args := new(model.UpLike)
  32. if err := c.Bind(args); err != nil {
  33. return
  34. }
  35. username, _ := c.Get("username")
  36. c.JSON(actSrv.UpLike(c, args, username.(string)))
  37. }
  38. func upListContent(c *bm.Context) {
  39. args := new(model.UpReply)
  40. if err := c.Bind(args); err != nil {
  41. return
  42. }
  43. username, _ := c.Get("username")
  44. c.JSON(nil, actSrv.UpLikesState(c, args.IDs, args.State, args.Reply, username.(string)))
  45. }
  46. func upWid(c *bm.Context) {
  47. args := new(model.UpWid)
  48. if err := c.Bind(args); err != nil {
  49. return
  50. }
  51. c.JSON(nil, actSrv.UpWid(c, args))
  52. }
  53. func addPic(c *bm.Context) {
  54. args := new(model.AddPic)
  55. if err := c.Bind(args); err != nil {
  56. return
  57. }
  58. c.JSON(actSrv.AddPicContent(c, args))
  59. }
  60. func batchLikes(c *bm.Context) {
  61. args := new(model.BatchLike)
  62. if err := c.Bind(args); err != nil {
  63. return
  64. }
  65. c.JSON(nil, actSrv.BatchLikes(c, args))
  66. }