feat: update slice expr

This commit is contained in:
Rogee
2025-05-26 14:31:41 +08:00
parent d634e0175b
commit 0a8f6f9a1b
5 changed files with 39 additions and 13 deletions

View File

@@ -210,7 +210,7 @@ func (m *Users) GetUsersMapByIDs(ctx context.Context, ids []int64) (map[int64]Us
stmt := tbl.
SELECT(tbl.AllColumns).
WHERE(
tbl.ID.IN(lo.Map(ids, func(id int64, _ int) Expression { return Int64(id) })...),
tbl.ID.IN(IntExprSlice(ids)...),
)
m.log().Infof("sql: %s", stmt.DebugSql())
@@ -231,7 +231,7 @@ func (m *Users) BatchCheckHasBought(ctx context.Context, postIDs []int64) (map[i
tbl := tblUserPosts
stmt := tbl.SELECT(tbl.PostID.AS("post_id")).WHERE(
tbl.UserID.EQ(Int64(m.ID)).AND(
tbl.PostID.IN(lo.Map(postIDs, func(id int64, _ int) Expression { return Int64(id) })...),
tbl.PostID.IN(IntExprSlice(postIDs)...),
),
)