like.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/web/model"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func like(c *bm.Context) {
  8. var (
  9. mid int64
  10. err error
  11. )
  12. v := new(struct {
  13. Aid int64 `form:"aid" validate:"min=1,required"`
  14. Like int8 `form:"like" validate:"min=1,max=4,required"`
  15. })
  16. if err = c.Bind(v); err != nil {
  17. return
  18. }
  19. midStr, _ := c.Get("mid")
  20. mid = midStr.(int64)
  21. upperID, err := webSvc.Like(c, v.Aid, mid, v.Like)
  22. c.JSON(nil, err)
  23. if err == nil && webSvc.CheatInfoc != nil {
  24. webSvc.CheatInfoc.InfoAntiCheat2(c, strconv.FormatInt(upperID, 10), strconv.FormatInt(v.Aid, 10), strconv.FormatInt(mid, 10), strconv.FormatInt(v.Aid, 10), "av", model.LikeType[v.Like], "")
  25. }
  26. }
  27. func likeTriple(c *bm.Context) {
  28. var (
  29. mid int64
  30. actTriple = "triplelike"
  31. err error
  32. )
  33. v := new(struct {
  34. Aid int64 `form:"aid" validate:"min=1,required"`
  35. })
  36. if err = c.Bind(v); err != nil {
  37. return
  38. }
  39. midStr, _ := c.Get("mid")
  40. mid = midStr.(int64)
  41. triple, err := webSvc.LikeTriple(c, v.Aid, mid)
  42. c.JSON(triple, err)
  43. if err != nil {
  44. return
  45. }
  46. if err == nil && webSvc.CheatInfoc != nil && triple.Anticheat {
  47. webSvc.CheatInfoc.InfoAntiCheat2(c, strconv.FormatInt(triple.UpID, 10), strconv.FormatInt(v.Aid, 10), strconv.FormatInt(mid, 10), strconv.FormatInt(v.Aid, 10), "av", actTriple, "")
  48. }
  49. }
  50. func hasLike(c *bm.Context) {
  51. var (
  52. mid int64
  53. )
  54. v := new(struct {
  55. Aid int64 `form:"aid" validate:"min=1,required"`
  56. })
  57. if err := c.Bind(v); err != nil {
  58. return
  59. }
  60. midStr, _ := c.Get("mid")
  61. mid = midStr.(int64)
  62. c.JSON(webSvc.HasLike(c, v.Aid, mid))
  63. }