Pārlūkot izejas kodu

Merge branch 'feature/snapshot' into test

qinchaoyue 3 dienas atpakaļ
vecāks
revīzija
a13a95fbf2

+ 8 - 4
src/Hotline.Application/Snapshot/SnapshotPointsApplication.cs

@@ -4,6 +4,7 @@ using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Enums.Snapshot;
 using Hotline.Share.Tools;
+using Hotline.Snapshot;
 using Hotline.Snapshot.IRepository;
 using SqlSugar;
 using System;
@@ -60,7 +61,6 @@ public class SnapshotPointsApplication : ISnapshotPointsApplication, IScopeDepen
 
     public async Task UpdateIsSecurityMaxAsync(UpdateIsSecurityMaxAsync dto, CancellationToken token)
     {
-        // TODO 紧急
         await _citizenRepository.Updateable()
             .SetColumns(citizen => citizen.IsSecurityMax, dto.IsSecurityMax)
             .Where(citizen => citizen.Id == dto.UserId)
@@ -73,11 +73,15 @@ public class SnapshotPointsApplication : ISnapshotPointsApplication, IScopeDepen
             {
                 await _safetyTypeRepository.Queryable()
                     .Where(m => m.Name == "安全卫士")
-                    .Select(m => m.Id)
                     .FirstAsync(token)
-                    .Then(async id =>
+                    .Then(async safetyType =>
                     {
-                        //citizen.
+                        if (dto.IsSecurityMax)
+                            citizen.SafetyTypes.Add(safetyType);
+                        else
+                            citizen.SafetyTypes.Remove(safetyType);
+                        await _citizenRepository.UpdateNav(citizen).Include(m => m.SafetyTypes)
+                                .ExecuteCommandAsync();
                     });
             });
     }

+ 1 - 1
src/Hotline.Application/Snapshot/SnapshotUserApplication.cs

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

+ 1 - 0
test/Hotline.Tests/Application/SnapshotUserApplicationTest.cs

@@ -101,6 +101,7 @@ public class SnapshotUserApplicationTest : TestBase
         await _snapshotUserApplication.DeleteCitizenRelationSafetyAsync(deleteInDto);
 
         items = await _snapshotUserApplication.GetCitizenRelationSafetyType(inDto).ToListAsync();
+        items.Any(m => m.SafetyTypeId.IsNullOrEmpty()).ShouldBeFalse
         item = items.FirstOrDefault(m => m.CitizenId == citizen.Id && m.SafetyTypeId == safetyType.Id);
         item.ShouldBeNull();
         inDto = new CitizenRelationSafetyTypeInDto