fix: issues

This commit is contained in:
yanghao05
2025-04-25 21:19:03 +08:00
parent b35abb2090
commit 5bc3ae468d
15 changed files with 129 additions and 64 deletions

View File

@@ -29,11 +29,13 @@ type posts struct {
}
// List posts
// @Router /api/posts [get]
// @Router /posts [get]
// @Bind pagination query
// @Bind query query
// @Bind user local
func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery, user *model.Users) (*requests.Pager, error) {
log.Infof("ok", pagination, query.Keyword, user.ID)
cond := models.Posts.BuildConditionWithKey(query.Keyword)
pager, err := models.Posts.List(ctx.Context(), pagination, cond, func(item model.Posts) model.Posts {
item.Assets = fields.ToJson([]fields.MediaAsset{})
@@ -41,6 +43,7 @@ func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
return item
})
if err != nil {
log.WithError(err).Errorf("post list err: %v", err)
return nil, err
}
@@ -55,6 +58,7 @@ func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
mediaUrls := lo.FilterMap(medias, func(item model.Medias, _ int) (string, bool) {
url, err := ctl.oss.GetSignedUrl(ctx.Context(), item.Path)
if err != nil {
log.WithError(err).Errorf("head image GetSignedUrl err: %v", err)
return "", false
}
@@ -93,7 +97,7 @@ type PostItem struct {
}
// Show
// @Router /api/posts/:id [get]
// @Router /posts/:id [get]
// @Bind id path
// @Bind user local
func (ctl *posts) Show(ctx fiber.Ctx, id int64, user *model.Users) (*PostItem, error) {
@@ -141,7 +145,7 @@ type PlayUrl struct {
}
// Play
// @Router /api/posts/:id/play [get]
// @Router /posts/:id/play [get]
// @Bind id path
// @Bind user local
func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, error) {
@@ -174,7 +178,7 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, er
}
// Mine posts
// @Router /api/posts/mine [get]
// @Router /posts/mine [get]
// @Bind pagination query
// @Bind query query
func (ctl *posts) Mine(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery) (*requests.Pager, error) {
@@ -187,7 +191,7 @@ func (ctl *posts) Mine(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
}
// Buy
// @Router /api/posts/:id/buy [get]
// @Router /posts/:id/buy [get]
// @Bind id path
// @Bind user local
func (ctl *posts) Buy(ctx fiber.Ctx, id int64, user *model.Users) (*wechat.JSAPIPayParams, error) {