This commit is contained in:
@@ -36,16 +36,16 @@ type posts struct {
|
||||
|
||||
// List posts
|
||||
//
|
||||
// @Summary 作品列表
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param pagination query requests.Pagination false "分页参数"
|
||||
// @Param query query ListQuery false "筛选条件"
|
||||
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
|
||||
// @Router /v1/posts [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
// @Bind user local
|
||||
// @Summary 作品列表
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param pagination query requests.Pagination false "分页参数"
|
||||
// @Param query query ListQuery false "筛选条件"
|
||||
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
|
||||
// @Router /v1/posts [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
// @Bind user local
|
||||
func (ctl *posts) List(
|
||||
ctx fiber.Ctx,
|
||||
pagination *requests.Pagination,
|
||||
@@ -81,7 +81,7 @@ func (ctl *posts) List(
|
||||
log.Errorf("GetMediaByIds err: %v", err)
|
||||
return PostItem{}, false
|
||||
}
|
||||
mediaUrls := lo.FilterMap(medias, func(item *models.Media, _ int) (string, bool) {
|
||||
mediaUrls := lo.FilterMap(medias, func(item *models.Medium, _ int) (string, bool) {
|
||||
url, err := ctl.oss.GetSignedUrl(ctx, item.Path)
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("head image GetSignedUrl err: %v", err)
|
||||
@@ -131,14 +131,14 @@ type PostItem struct {
|
||||
|
||||
// Show
|
||||
//
|
||||
// @Summary 作品详情
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} PostItem "成功"
|
||||
// @Router /v1/posts/:id/show [get]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind user local
|
||||
// @Summary 作品详情
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} PostItem "成功"
|
||||
// @Router /v1/posts/:id/show [get]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind user local
|
||||
func (ctl *posts) Show(ctx fiber.Ctx, post *models.Post, user *models.User) (*PostItem, error) {
|
||||
log.Infof("Fetching post with ID: %d", post.ID)
|
||||
|
||||
@@ -155,7 +155,7 @@ func (ctl *posts) Show(ctx fiber.Ctx, post *models.Post, user *models.User) (*Po
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mediaUrls := lo.FilterMap(medias, func(item *models.Media, _ int) (string, bool) {
|
||||
mediaUrls := lo.FilterMap(medias, func(item *models.Medium, _ int) (string, bool) {
|
||||
url, err := ctl.oss.GetSignedUrl(ctx, item.Path)
|
||||
if err != nil {
|
||||
return "", false
|
||||
@@ -186,14 +186,14 @@ type PlayUrl struct {
|
||||
|
||||
// Play
|
||||
//
|
||||
// @Summary 获取播放地址
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} PlayUrl "成功"
|
||||
// @Router /v1/posts/:id/play [get]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind user local
|
||||
// @Summary 获取播放地址
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} PlayUrl "成功"
|
||||
// @Router /v1/posts/:id/play [get]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind user local
|
||||
func (ctl *posts) Play(ctx fiber.Ctx, post *models.Post, user *models.User) (*PlayUrl, error) {
|
||||
log := log.WithField("PlayPostID", strconv.FormatInt(post.ID, 10))
|
||||
// return &PlayUrl{
|
||||
@@ -237,16 +237,16 @@ func (ctl *posts) Play(ctx fiber.Ctx, post *models.Post, user *models.User) (*Pl
|
||||
|
||||
// Mine posts
|
||||
//
|
||||
// @Summary 我的已购作品
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param pagination query requests.Pagination false "分页参数"
|
||||
// @Param query query ListQuery false "筛选条件"
|
||||
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
|
||||
// @Router /v1/posts/mine [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
// @Bind user local
|
||||
// @Summary 我的已购作品
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param pagination query requests.Pagination false "分页参数"
|
||||
// @Param query query ListQuery false "筛选条件"
|
||||
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
|
||||
// @Router /v1/posts/mine [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
// @Bind user local
|
||||
func (ctl *posts) Mine(
|
||||
ctx fiber.Ctx,
|
||||
pagination *requests.Pagination,
|
||||
@@ -278,7 +278,7 @@ func (ctl *posts) Mine(
|
||||
log.Errorf("GetMediaByIds err: %v", err)
|
||||
return PostItem{}, false
|
||||
}
|
||||
mediaUrls := lo.FilterMap(medias, func(item *models.Media, _ int) (string, bool) {
|
||||
mediaUrls := lo.FilterMap(medias, func(item *models.Medium, _ int) (string, bool) {
|
||||
url, err := ctl.oss.GetSignedUrl(ctx, item.Path)
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("head image GetSignedUrl err: %v", err)
|
||||
@@ -309,14 +309,14 @@ func (ctl *posts) Mine(
|
||||
|
||||
// Buy
|
||||
//
|
||||
// @Summary 购买作品
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} wechat.JSAPIPayParams "成功(余额支付返回 AppId=balance)"
|
||||
// @Router /v1/posts/:id/buy [post]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind user local
|
||||
// @Summary 购买作品
|
||||
// @Tags Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} wechat.JSAPIPayParams "成功(余额支付返回 AppId=balance)"
|
||||
// @Router /v1/posts/:id/buy [post]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind user local
|
||||
func (ctl *posts) Buy(ctx fiber.Ctx, post *models.Post, user *models.User) (*wechat.JSAPIPayParams, error) {
|
||||
bought, err := services.Users.HasBought(ctx, user.ID, post.ID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user