package playletser import ( "fmt" "videoweb/app/service/upstream" "github.com/gin-gonic/gin" ) const ( chapterLikeSetPath = "/api/app/playlet/chapter/like/set" chapterCollectSetPath = "/api/app/playlet/chapter/collect/set" ) // PlayletChapterLikeSetReq 对应 swagger proto.PlayletChapterLikeSetReq type PlayletChapterLikeSetReq struct { ChapterID int64 `json:"chapterId"` IsLike bool `json:"isLike"` } // PlayletChapterLikeSetResp 对应 swagger proto.PlayletChapterLikeSetResp type PlayletChapterLikeSetResp struct { ChapterID int64 `json:"chapterId"` CountLike int64 `json:"countLike"` IsLike int `json:"isLike"` } // ChapterLikeSet 设置剧集点赞/取消点赞。 func ChapterLikeSet(c *gin.Context, req PlayletChapterLikeSetReq) (*APIEnvelope[PlayletChapterLikeSetResp], error) { if req.ChapterID <= 0 { return nil, fmt.Errorf("chapter like invalid chapterId") } var env APIEnvelope[PlayletChapterLikeSetResp] if _, err := upstream.PostJSON(c, chapterLikeSetPath, req, &env); err != nil { return nil, err } return &env, nil } // PlayletChapterCollectSetReq 对应 swagger proto.PlayletChapterCollectSetReq type PlayletChapterCollectSetReq struct { ChapterID int64 `json:"chapterId"` IsCollect bool `json:"isCollect"` } // PlayletChapterCollectSetResp 对应 swagger proto.PlayletChapterCollectSetResp type PlayletChapterCollectSetResp struct { ChapterID int64 `json:"chapterId"` CountCollect int64 `json:"countCollect"` IsCollect int `json:"isCollect"` } // ChapterCollectSet 设置剧集收藏/取消收藏。 func ChapterCollectSet(c *gin.Context, req PlayletChapterCollectSetReq) (*APIEnvelope[PlayletChapterCollectSetResp], error) { if req.ChapterID <= 0 { return nil, fmt.Errorf("chapter collect invalid chapterId") } var env APIEnvelope[PlayletChapterCollectSetResp] if _, err := upstream.PostJSON(c, chapterCollectSetPath, req, &env); err != nil { return nil, err } return &env, nil }