Explorar o código

Merge branch 'feature/snapshot' into dev

qinchaoyue hai 4 meses
pai
achega
9b2b1c579e

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

@@ -236,6 +236,40 @@ public class IndustryController : BaseController
     #endregion
 
     #region 志愿者
+    /// <summary>
+    /// 志愿者集合
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("volunteer")]
+    public async Task<PagedDto<VolunteerItemsOutDto>> GetVolunteerItemsAsync([FromQuery] VolunteerItemsInDto dto)
+        => (await _industryApplication.GetVolunteerItemsAsync(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
+
+    /// <summary>
+    /// 添加志愿者
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPost("volunteer")]
+    public async Task<string> AddVolunteerAsync([FromBody] AddVolunteerInDto dto)
+        => await _industryApplication.AddVolunteerAsync(dto);
 
+    /// <summary>
+    /// 批量删除志愿者
+    /// </summary>
+    /// <param name="ids"></param>
+    /// <returns></returns>
+    [HttpDelete("volunteer")]
+    public async Task DeleteVolunteerAsync([FromBody]IList<string> ids)
+        => await _industryApplication.DeleteVolunteerAsync(ids);
+
+    /// <summary>
+    /// 志愿者详情
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    [HttpGet("volunteer/{id}")]
+    public async Task<Volunteer> GetVolunteerAsync(string id)
+        => await _industryApplication.GetVolunteerAsync(id);
     #endregion
 }

+ 1 - 1
src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs

@@ -185,7 +185,7 @@ public class SnapshotController : BaseController
     /// <param name="id"></param>
     /// <returns></returns>
     [HttpGet("order/{id}")]
-    public async Task<OrderPublishDetailOutDto> QueryOrderListAsync([FromQuery] string id)
+    public async Task<OrderPublishDetailOutDto> QueryOrderListAsync(string id)
         => await _snapshotApplication.GetSnapshotOrderDetailAsync(id, HttpContext.RequestAborted);
 
     /// <summary>

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

@@ -128,4 +128,32 @@ public interface IIndustryApplication
     /// <param name="id"></param>
     /// <returns></returns>
     Task<PractitionerItemsOutDto> GetPractitionerAsync(string id);
+
+    /// <summary>
+    /// 志愿者集合
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    ISugarQueryable<VolunteerItemsOutDto> GetVolunteerItemsAsync(VolunteerItemsInDto dto);
+
+    /// <summary>
+    /// 添加志愿者
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    Task<string> AddVolunteerAsync(AddVolunteerInDto dto);
+
+    /// <summary>
+    /// 批量删除志愿者
+    /// </summary>
+    /// <param name="ids"></param>
+    /// <returns></returns>
+    Task DeleteVolunteerAsync(IList<string> ids);
+
+    /// <summary>
+    /// 志愿者详情
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    Task<Volunteer> GetVolunteerAsync(string id);
 }

+ 54 - 1
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -28,8 +28,9 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     private readonly IIndustryCaseRepository _industryCaseRepository;
     private readonly ISnapshotSMSTemplateRepository _snapshotSMSTemplateRepository;
     private readonly IPractitionerRepository _practitionerRepository;
+    private readonly IVolunteerRepository _volunteerRepository;
 
-    public IndustryApplication(IIndustryRepository industryRepository, IFileRepository fileRepository, ISystemSettingCacheManager sysSetting, IIndustryCaseRepository industryCaseRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IPractitionerRepository practitionerRepository)
+    public IndustryApplication(IIndustryRepository industryRepository, IFileRepository fileRepository, ISystemSettingCacheManager sysSetting, IIndustryCaseRepository industryCaseRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IPractitionerRepository practitionerRepository, IVolunteerRepository volunteerRepository)
     {
         _industryRepository = industryRepository;
         _fileRepository = fileRepository;
@@ -37,6 +38,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
         _industryCaseRepository = industryCaseRepository;
         _snapshotSMSTemplateRepository = snapshotSMSTemplateRepository;
         _practitionerRepository = practitionerRepository;
+        _volunteerRepository = volunteerRepository;
     }
     /// <summary>
     /// 新增行业
@@ -280,8 +282,59 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
         var entity = dto.Adapt<Practitioner>();
         await _practitionerRepository.UpdateAsync(entity);
     }
+
     #endregion
 
     #region 志愿者
+
+    /// <summary>
+    /// 志愿者集合
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    /// <exception cref="NotImplementedException"></exception>
+    public ISugarQueryable<VolunteerItemsOutDto> GetVolunteerItemsAsync(VolunteerItemsInDto dto)
+    {
+        var query = _volunteerRepository.Queryable()
+            .WhereIF(dto.Name.NotNullOrEmpty(), m => m.Name.Contains(dto.Name))
+            .WhereIF(dto.PhoneNumber.NotNullOrEmpty(), m => m.PhoneNumber.Contains(dto.PhoneNumber))
+            .Select<VolunteerItemsOutDto>();
+        return query;
+    }
+
+    /// <summary>
+    /// 添加志愿者
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    public async Task<string> AddVolunteerAsync(AddVolunteerInDto dto)
+    {
+        var entity = dto.Adapt<Volunteer>();
+        entity.Id = await _volunteerRepository.AddAsync(entity);
+        return entity.Id;
+    }
+
+    /// <summary>
+    /// 批量删除志愿者
+    /// </summary>
+    /// <param name="ids"></param>
+    /// <returns></returns>
+    public async Task DeleteVolunteerAsync(IList<string> ids)
+    {
+        await _volunteerRepository.Updateable()
+            .SetColumns(m => m.IsDeleted, true)
+            .Where(m => ids.Contains(m.Id))
+            .ExecuteCommandAsync();
+    }
+
+    /// <summary>
+    /// 志愿者详情
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    public async Task<Volunteer> GetVolunteerAsync(string id)
+    {
+        return await _volunteerRepository.GetAsync(id);
+    }
     #endregion
 }

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

@@ -317,7 +317,7 @@ public abstract class SnapshotApplicationBase
             .WhereIF(dto.Status == EOrderQueryStatus.Appraise, (snapshot, order) => order.Status == EOrderStatus.Visited)
             .WhereIF(dto.Status == EOrderQueryStatus.NoReply, (snapshot, order) => order.Status < EOrderStatus.Filed)
             .WhereIF(dto.Status == EOrderQueryStatus.Reply, (snapshot, order) => order.Status >= EOrderStatus.Filed)
-            .WhereIF(dto.KeyWords.NotNullOrEmpty(), (snapshot, order) => order.Title.Contains(dto.KeyWords))
+            .WhereIF(dto.KeyWords.NotNullOrEmpty(), (snapshot, order) => order.Title.Contains(dto.KeyWords) || order.No.Contains(dto.KeyWords))
             .Select((snapshot, order) => new OrderOutDto
             {
                 Id = snapshot.Id,

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

@@ -1,4 +1,5 @@
-using System;
+using Hotline.Share.Requests;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
@@ -21,7 +22,7 @@ public class AddVolunteerInDto
     public string PhoneNumber { get; set; }
 }
 
-public class VolunteerListOutDto
+public class VolunteerItemsOutDto
 {
     public string Id { get; set; }
 
@@ -35,3 +36,10 @@ public class VolunteerListOutDto
     /// </summary>
     public string PhoneNumber { get; set; }
 }
+
+/// <summary>
+/// 志愿者集合入参
+/// </summary>
+/// <param name="Name">姓名</param>
+/// <param name="PhoneNumber">电话</param>
+public record VolunteerItemsInDto(string? Name, string? PhoneNumber): PagedRequest;