feat: support player
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user