فهرست منبع

fix:优化contact/simple

jimmyyem 1 ماه پیش
والد
کامیت
9f56e5295e
1فایلهای تغییر یافته به همراه3 افزوده شده و 16 حذف شده
  1. 3 16
      internal/logic/contact/get_contact_simple_list_logic.go

+ 3 - 16
internal/logic/contact/get_contact_simple_list_logic.go

@@ -3,10 +3,7 @@ package contact
 import (
 	"context"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
-	"wechat-api/ent"
 	"wechat-api/ent/contact"
-	"wechat-api/ent/label"
-	"wechat-api/ent/labelrelationship"
 	"wechat-api/ent/predicate"
 	"wechat-api/internal/utils/dberrorhandler"
 
@@ -39,15 +36,9 @@ func (l *GetContactSimpleListLogic) GetContactSimpleList(req *types.ContactListR
 		ctype = *req.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 {
-		predicates = append(predicates, contact.WxWxidContains(*req.WxWxid))
+		predicates = append(predicates, contact.WxWxid(*req.WxWxid))
 	}
 	if req.Wxid != nil {
 		predicates = append(predicates, contact.WxidContains(*req.Wxid))
@@ -60,13 +51,9 @@ func (l *GetContactSimpleListLogic) GetContactSimpleList(req *types.ContactListR
 	}
 	if req.Type != nil {
 		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 {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)