This commit is contained in:
parent
cdb6cf7807
commit
4dce056c5f
|
|
@ -948,15 +948,18 @@ func (m *BizCore) NewsAsyncBatch(ctx *itypes.Context, req *proto.NewsAsyncBatchR
|
|||
}
|
||||
|
||||
func (m *BizCore) NewsPullNew(ctx *itypes.Context, req *proto.NewsPullNewReq) (resp *proto.NewsPullNewResp, total int64, code itypes.BizCode) {
|
||||
// 1. 提取 OrgIDs
|
||||
orgIDs := make([]int64, 0, len(req.List))
|
||||
// 1. 转换 List 为 Pairs(只用 OrgId,Digest 忽略但结构体字段需要赋值)
|
||||
pairs := make([]dao.OrgDigestPair, 0, len(req.List))
|
||||
for _, item := range req.List {
|
||||
orgIDs = append(orgIDs, item.OrgID)
|
||||
pairs = append(pairs, dao.OrgDigestPair{
|
||||
OrgId: item.OrgID, // 这个字段名必须匹配 dao.OrgDigestPair 里的定义
|
||||
Digest: "", // 虽然不处理,但结构体字段得占上
|
||||
})
|
||||
}
|
||||
|
||||
// 2. 调用 DAO 查询
|
||||
dos, total, err := m.newsDAO.QueryPullNew(&dao.NewsPullNewCondition{
|
||||
OrgIDs: orgIDs,
|
||||
Pairs: pairs,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, 0, itypes.NewBizCodeDatabaseError(err.Error())
|
||||
|
|
|
|||
|
|
@ -22,8 +22,12 @@ type NewsAsyncCondition struct {
|
|||
Digest string
|
||||
}
|
||||
|
||||
// type NewsPullNewCondition struct {
|
||||
// OrgIDs []int64 `json:"org_ids"`
|
||||
// }
|
||||
|
||||
type NewsPullNewCondition struct {
|
||||
OrgIDs []int64 `json:"org_ids"`
|
||||
Pairs []OrgDigestPair
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -484,10 +488,15 @@ func (dao *NewsDAO) QueryPullNew(cond *NewsPullNewCondition) (dos []*models.News
|
|||
models.NEWS_COLUMN_EXTRA_DATA,
|
||||
)
|
||||
|
||||
// 只按 org_ids 过滤
|
||||
if len(cond.OrgIDs) > 0 {
|
||||
e.NotIn(models.NEWS_COLUMN_ORG_ID, cond.OrgIDs)
|
||||
// 🔧 仅提取 org_id,忽略 digest
|
||||
if len(cond.Pairs) > 0 {
|
||||
orgIDs := make([]int64, 0, len(cond.Pairs))
|
||||
for _, p := range cond.Pairs {
|
||||
orgIDs = append(orgIDs, p.OrgID)
|
||||
}
|
||||
e.Where(fmt.Sprintf("%s NOT IN (?)", models.NEWS_COLUMN_ORG_ID), orgIDs)
|
||||
}
|
||||
|
||||
_, total, err = e.QueryEx()
|
||||
if err != nil {
|
||||
log.Errorf("QueryPullNew failed: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue