|
@@ -3,10 +3,7 @@ package contact
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
"github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
"github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
- "wechat-api/ent"
|
|
|
|
"wechat-api/ent/contact"
|
|
"wechat-api/ent/contact"
|
|
- "wechat-api/ent/label"
|
|
|
|
- "wechat-api/ent/labelrelationship"
|
|
|
|
"wechat-api/ent/predicate"
|
|
"wechat-api/ent/predicate"
|
|
"wechat-api/internal/utils/dberrorhandler"
|
|
"wechat-api/internal/utils/dberrorhandler"
|
|
|
|
|
|
@@ -39,15 +36,9 @@ func (l *GetContactSimpleListLogic) GetContactSimpleList(req *types.ContactListR
|
|
ctype = *req.Ctype
|
|
ctype = *req.Ctype
|
|
}
|
|
}
|
|
predicates = append(predicates, contact.Ctype(ctype))
|
|
predicates = append(predicates, contact.Ctype(ctype))
|
|
- if len(req.LabelIDs) > 0 {
|
|
|
|
- predicates = append(predicates, contact.HasContactRelationshipsWith(
|
|
|
|
- labelrelationship.HasLabelsWith(
|
|
|
|
- label.IDIn(req.LabelIDs...),
|
|
|
|
- ),
|
|
|
|
- ))
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
if req.WxWxid != nil {
|
|
if req.WxWxid != nil {
|
|
- predicates = append(predicates, contact.WxWxidContains(*req.WxWxid))
|
|
|
|
|
|
+ predicates = append(predicates, contact.WxWxid(*req.WxWxid))
|
|
}
|
|
}
|
|
if req.Wxid != nil {
|
|
if req.Wxid != nil {
|
|
predicates = append(predicates, contact.WxidContains(*req.Wxid))
|
|
predicates = append(predicates, contact.WxidContains(*req.Wxid))
|
|
@@ -60,13 +51,9 @@ func (l *GetContactSimpleListLogic) GetContactSimpleList(req *types.ContactListR
|
|
}
|
|
}
|
|
if req.Type != nil {
|
|
if req.Type != nil {
|
|
predicates = append(predicates, contact.TypeEQ(*req.Type))
|
|
predicates = append(predicates, contact.TypeEQ(*req.Type))
|
|
- } else {
|
|
|
|
- predicates = append(predicates, contact.Or(contact.TypeEQ(1), contact.TypeEQ(2)))
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- data, err := l.svcCtx.DB.Contact.Query().Where(predicates...).WithContactRelationships(func(query *ent.LabelRelationshipQuery) {
|
|
|
|
- query.WithLabels()
|
|
|
|
- }).Page(l.ctx, req.Page, req.PageSize)
|
|
|
|
|
|
+ data, err := l.svcCtx.DB.Contact.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
|
|
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|