Ver Fonte

对字符串的条件增加非空的判断

lichangdong há 3 dias atrás
pai
commit
5d0e690572

+ 4 - 4
internal/logic/contact/get_contact_list_logic.go

@@ -106,16 +106,16 @@ func (l *GetContactListLogic) GetContactList(req *types.ContactListReq) (*types.
 		predicates = append(predicates, contact.Ctype(1)) // 默认 Ctype = 1
 	}
 
-	if req.WxWxid != nil {
+	if req.WxWxid != nil && *req.WxWxid != "" {
 		predicates = append(predicates, contact.WxWxidContains(*req.WxWxid))
 	}
-	if req.Wxid != nil {
+	if req.Wxid != nil && *req.Wxid != "" {
 		predicates = append(predicates, contact.WxidContains(*req.Wxid))
 	}
-	if req.Account != nil {
+	if req.Account != nil && *req.Account != "" {
 		predicates = append(predicates, contact.AccountContains(*req.Account))
 	}
-	if req.Nickname != nil {
+	if req.Nickname != nil && *req.Nickname != "" {
 		predicates = append(predicates, contact.NicknameContains(*req.Nickname))
 	}
 	if req.Type != nil {

+ 3 - 3
internal/logic/label_relationship/get_label_relationship_list_logic.go

@@ -80,10 +80,10 @@ func (l *GetLabelRelationshipListLogic) GetLabelRelationshipList(req *types.Labe
 		conPreds = append(conPreds, contact.Ctype(1)) // 默认 Ctype = 1
 	}
 
-	if req.WxWxid != nil {
+	if req.WxWxid != nil && *req.WxWxid != "" {
 		conPreds = append(conPreds, contact.WxWxidContains(*req.WxWxid))
 	}
-	if req.Wxid != nil {
+	if req.Wxid != nil && *req.Wxid != "" {
 		conPreds = append(conPreds, contact.WxidContains(*req.Wxid))
 	}
 
@@ -93,7 +93,7 @@ func (l *GetLabelRelationshipListLogic) GetLabelRelationshipList(req *types.Labe
 		conPreds = append(conPreds, contact.Or(contact.TypeEQ(1), contact.TypeEQ(2), contact.TypeEQ(4)))
 	}
 
-	if req.Nickname != nil {
+	if req.Nickname != nil && *req.Nickname != "" {
 		conPreds = append(conPreds, contact.NicknameContains(*req.Nickname))
 	}