feat: update models

This commit is contained in:
Rogee
2025-05-23 20:49:10 +08:00
parent 57cb0a750b
commit 18808200c2
14 changed files with 69 additions and 73 deletions

View File

@@ -53,7 +53,7 @@ func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
postIds := lo.Map(pager.Items.([]model.Posts), func(item model.Posts, _ int) int64 { return item.ID })
if len(postIds) > 0 {
userBoughtIds, err := model.UsersModel.BatchCheckHasBought(ctx.Context(), user.ID, postIds)
userBoughtIds, err := user.BatchCheckHasBought(ctx.Context(), postIds)
if err != nil {
log.WithError(err).Errorf("BatchCheckHasBought err: %v", err)
}
@@ -124,7 +124,7 @@ func (ctl *posts) Show(ctx fiber.Ctx, id int64, user *model.Users) (*PostItem, e
return nil, err
}
bought, err := model.UsersModel.HasBought(ctx.Context(), user.ID, post.ID)
bought, err := user.HasBought(ctx.Context(), post.ID)
if err != nil {
return nil, err
}
@@ -173,7 +173,7 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, er
// }, nil
preview := false
bought, err := model.UsersModel.HasBought(ctx.Context(), user.ID, id)
bought, err := user.HasBought(ctx.Context(), id)
if !bought || err != nil {
preview = true
}
@@ -270,7 +270,7 @@ func (ctl *posts) Mine(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
// @Bind id path
// @Bind user local
func (ctl *posts) Buy(ctx fiber.Ctx, id int64, user *model.Users) (*wechat.JSAPIPayParams, error) {
bought, err := model.UsersModel.HasBought(ctx.Context(), user.ID, id)
bought, err := user.HasBought(ctx.Context(), id)
if err != nil {
return nil, errors.New("查询购买失败")
}