feat: support player

This commit is contained in:
yanghao05
2025-04-25 14:38:55 +08:00
parent 11bea6b8c9
commit 75865ae19a
7 changed files with 151 additions and 12 deletions

View File

@@ -283,3 +283,25 @@ func (m *usersModel) GetUsersMapByIDs(ctx context.Context, ids []int64) (map[int
return item.ID, item
}), nil
}
// HasBought
func (m *usersModel) HasBought(ctx context.Context, userID, postID int64) (bool, error) {
tbl := table.UserPosts
stmt := tbl.
SELECT(tbl.ID).
WHERE(
tbl.UserID.EQ(Int64(userID)).AND(
tbl.PostID.EQ(Int64(postID)),
),
)
m.log.Infof("sql: %s", stmt.DebugSql())
var userPost model.UserPosts
if err := stmt.QueryContext(ctx, db, &userPost); err != nil {
m.log.Errorf("error querying user post: %v", err)
return false, err
}
return userPost.ID > 0, nil
}