ソースを参照

Merge branch 'feature/snapshot' into dev

qinchaoyue 4 ヶ月 前
コミット
dd6f2af042

+ 9 - 0
src/Hotline.Api/Controllers/Snapshot/IndustryController.cs

@@ -271,5 +271,14 @@ public class IndustryController : BaseController
     [HttpGet("volunteer/{id}")]
     public async Task<Volunteer> GetVolunteerAsync(string id)
         => await _industryApplication.GetVolunteerAsync(id);
+
+    /// <summary>
+    /// 修改志愿者
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPut("volunteer")]
+    public async Task UpdateVolunteerAsync(UpdateVolunteerInDto dto)
+        => await _industryApplication.UpdateVolunteerAsync(dto);
     #endregion
 }

+ 7 - 0
src/Hotline.Application/Snapshot/IIndustryApplication.cs

@@ -156,4 +156,11 @@ public interface IIndustryApplication
     /// <param name="id"></param>
     /// <returns></returns>
     Task<Volunteer> GetVolunteerAsync(string id);
+
+    /// <summary>
+    /// 修改志愿者
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    Task UpdateVolunteerAsync(UpdateVolunteerInDto dto);
 }

+ 18 - 2
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -119,7 +119,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
             .LeftJoin<Industry>((c, i) => c.IndustryId == i.Id)
             .WhereIF(dto.IndustryName.NotNullOrEmpty(), (c, i) => i.Name.Contains(dto.IndustryName))
             .WhereIF(dto.CaseName.NotNullOrEmpty(), (c, i) => c.Name.Contains(dto.CaseName))
-            .OrderByDescending(m => m.CreationTime)
+            .OrderByDescending((c, i) => c.CreationTime)
             .Select<IndustryCaseItemOutDto>((c, i) => 
             new IndustryCaseItemOutDto {
                 Id = c.Id,
@@ -215,6 +215,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     {
         return await _snapshotSMSTemplateRepository.Queryable()
             .LeftJoin<Industry>((s, i) => s.IndustryId == i.Id)
+            .Where((s, i) => s.Id == id)
             .Select<SnapshotSMSTemplateItemsOutDto>()
             .FirstAsync();
     }
@@ -283,7 +284,9 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     public async Task UpdatePractitionerAsync(UpdatePractitionerInDto dto)
     {
         dto.ValidateObject();
-        var entity = dto.Adapt<Practitioner>();
+
+        var entity = await _practitionerRepository.GetAsync(dto.Id) ?? throw UserFriendlyException.SameMessage($"从业人员不存在 {dto.Id}");
+        dto.Adapt(entity);
         await _practitionerRepository.UpdateAsync(entity);
     }
 
@@ -341,5 +344,18 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     {
         return await _volunteerRepository.GetAsync(id);
     }
+
+    /// <summary>
+    /// 修改志愿者
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    public async Task UpdateVolunteerAsync(UpdateVolunteerInDto dto)
+    {
+        dto.ValidateObject();
+        var entity = await _volunteerRepository.GetAsync(dto.Id) ?? throw UserFriendlyException.SameMessage($"志愿者不存在 {dto.Id}");
+        dto.Adapt(entity);
+        await _volunteerRepository.UpdateAsync(entity);
+    }
     #endregion
 }

+ 10 - 0
src/Hotline.Share/Dtos/Snapshot/VolunteerDto.cs

@@ -7,6 +7,16 @@ using System.Text;
 using System.Threading.Tasks;
 
 namespace Hotline.Share.Dtos.Snapshot;
+
+public class UpdateVolunteerInDto : AddVolunteerInDto
+{
+    /// <summary>
+    /// 志愿者Id
+    /// </summary>
+    [Required]
+    public string Id { get; set; }
+}
+
 public class AddVolunteerInDto
 {
     /// <summary>