This commit is contained in:
hailin 2025-06-20 17:28:45 +08:00
parent fa35a08240
commit 1451aa19aa
1 changed files with 1 additions and 4 deletions

View File

@ -538,20 +538,17 @@ func (dao *NewsDAO) QueryPullNew(cond *NewsPullNewCondition) (dos []*models.News
models.NEWS_COLUMN_EXTRA_DATA,
)
// 🔧 正确展开 org_id 切片
if cond != nil && len(cond.Pairs) > 0 {
orgIDs := make([]interface{}, 0, len(cond.Pairs))
for _, p := range cond.Pairs {
orgIDs = append(orgIDs, p.OrgId)
}
// 构造正确的 IN 子句(防止 ORM 不展开切片)
placeholders := make([]string, len(orgIDs))
for i := range orgIDs {
placeholders[i] = "?"
}
whereClause := fmt.Sprintf("%s NOT IN (%s)", models.NEWS_COLUMN_ORG_ID, strings.Join(placeholders, ","))
e.Where(whereClause, orgIDs...)
e = e.Where(whereClause, orgIDs...) // 必须 e = e.Where
}
_, total, err = e.QueryEx()