Browse Source

修复过滤

qinchaoyue 3 hours ago
parent
commit
4404a68d1e
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/Hotline.Application/Snapshot/SnapshotUserApplication.cs

+ 6 - 3
src/Hotline.Application/Snapshot/SnapshotUserApplication.cs

@@ -106,10 +106,13 @@ public class SnapshotUserApplication : ISnapshotUserApplication, IScopeDependenc
     {
         var query = _citizenRepository.Queryable(includeDeleted: true)
             .LeftJoin<ThirdAccount>((citizen, third) => citizen.Id == third.ExternalId)
-            .LeftJoin<CitizenRelationSafetyType>((citizen, third, relation) => relation.CitizenId == citizen.Id)
+            .LeftJoin<CitizenRelationSafetyType>((citizen, third, relation) => relation.CitizenId == citizen.Id && relation.SafetyTypeId == dto.SafetyTypeId)
             .WhereIF(dto.PhoneNumber.NotNullOrEmpty(), (citizen, third) => citizen.PhoneNumber.Contains(dto.PhoneNumber))
-            .WhereIF(dto.SafetyTypeId.NotNullOrEmpty(), (citizen, third, relation) => relation.SafetyTypeId == dto.SafetyTypeId && relation.CitizenId == null)
-            .Select((citizen, third, relation) => new GetThirdCitizenOutDto { CitizenId = citizen.Id}, true);
+            .WhereIF(dto.SafetyTypeId.NotNullOrEmpty(), (citizen, third, relation) => relation.CitizenId == null)
+            .Select((citizen, third, relation) => new GetThirdCitizenOutDto 
+            {
+                CitizenId = citizen.Id
+            }, true);
 #if DEBUG
         var sql = query.ToSqlString();
 #endif