like.go 589 B

123456789101112131415161718192021222324252627
  1. package like
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "hongze/hongze_yb/controller/response"
  5. "hongze/hongze_yb/models/request/like"
  6. likeService "hongze/hongze_yb/services/like"
  7. userService "hongze/hongze_yb/services/user"
  8. )
  9. // SetLike 点赞设置
  10. func SetLike(c *gin.Context) {
  11. var req like.ReqLike
  12. if c.ShouldBind(&req) != nil {
  13. response.Fail("参数异常", c)
  14. return
  15. }
  16. userinfo := userService.GetInfoByClaims(c)
  17. data, err := likeService.SetLike(userinfo, req)
  18. if err != nil {
  19. response.Fail(err.Error(), c)
  20. return
  21. }
  22. response.OkData("操作成功", data, c)
  23. return
  24. }