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

@@ -125,7 +125,7 @@ func (m *Posts) BoughtStatistics(ctx context.Context, postIds []int64) (map[int6
tbl.PostID.AS("post_id"),
).
WHERE(
tbl.PostID.IN(lo.Map(postIds, func(id int64, _ int) Expression { return Int64(id) })...),
tbl.PostID.IN(IntExprSlice(postIds)...),
).
GROUP_BY(
tbl.PostID,
@@ -218,7 +218,7 @@ func (m *Posts) GetPostsMapByIDs(ctx context.Context, ids []int64) (map[int64]Po
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())
@@ -245,7 +245,7 @@ func (m *Posts) GetMediaByIds(ctx context.Context, ids []int64) ([]Medias, error
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())