Browse Source

Merge branch 'test' of http://110.188.24.182:10023/Fengwo/hotline into test

Dun.Jason 3 months ago
parent
commit
ac2a39ffb3

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

@@ -45,6 +45,15 @@ public class InviteCodeController : BaseController
     public async Task<PagedDto<InviteCode>> GetInviteCodeItemsAsync([FromQuery] GetInviteCodeItemsInDto dto)
         => (await _inviteCodeApplication.GetInviteCodeItemsAsync().ToPagedListAsync(dto)).ToPaged();
 
+
+    /// <summary>
+    /// 删除邀请码
+    /// </summary>
+    /// <returns></returns>
+    [HttpDelete]
+    public async Task DeleteInviteCodeAsync([FromBody] IList<string> ids)
+        => await _inviteCodeApplication.DeleteInviteCodeAsync(ids);
+
     /// <summary>
     /// 邀请码详情
     /// </summary>

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

@@ -12,6 +12,13 @@ namespace Hotline.Application.Snapshot;
 public interface IInviteCodeApplication
 {
     Task AddInviteCodeAsync(AddInviteCodeInDto dto);
+
+    /// <summary>
+    /// 删除邀请码
+    /// </summary>
+    /// <param name="ids"></param>
+    /// <returns></returns>
+    Task DeleteInviteCodeAsync(IList<string> ids);
     ISugarQueryable<InviteCode> GetInviteCodeItemsAsync();
 
     /// <summary>

+ 28 - 1
src/Hotline.Application/Snapshot/InviteCodeApplication.cs

@@ -1,4 +1,5 @@
 using Hotline.Share.Dtos.Snapshot;
+using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Hotline.Tools;
@@ -38,6 +39,26 @@ public class InviteCodeApplication : IInviteCodeApplication, IScopeDependency
         await _inviteCodeRepository.AddAsync(entity);
     }
 
+    /// <summary>
+    /// 删除邀请码
+    /// </summary>
+    /// <param name="ids"></param>
+    /// <returns></returns>
+    public async Task DeleteInviteCodeAsync(IList<string> ids)
+    {
+        await _inviteCodeRepository.Queryable()
+            .Where(m => ids.Contains(m.Id))
+            .ToListAsync()
+            .Then(async invite =>
+            {
+                for (int i = 0;i < invite.Count;i++)
+                {
+                    invite[i].IsDeleted = true;
+                    await _inviteCodeRepository.UpdateAsync(invite[i]);
+                }
+            });
+    }
+
     public ISugarQueryable<InviteCode> GetInviteCodeItemsAsync()
     {
         return _inviteCodeRepository.Queryable();
@@ -69,7 +90,13 @@ public class InviteCodeApplication : IInviteCodeApplication, IScopeDependency
         dto.ValidateObject();
         var query = _inviteCodeRecordRepository.Queryable()
             .Where(m => m.CreationTime >= dto.StartTime && m.CreationTime <= dto.EndTime && m.OrgId == dto.OrgId)
-            .Select(m => new InviteCodeStatisticDetailOutDto());
+            .WhereIF(dto.Name.NotNullOrEmpty(), m => m.Name.Contains(dto.Name))
+            .WhereIF(dto.PhoneNumber.NotNullOrEmpty(), m => m.PhoneNumber.Contains(dto.PhoneNumber))
+            .WhereIF(dto.InviteCode.NotNullOrEmpty(), m => m.InviteCode.Contains(dto.InviteCode))
+            .Select(m => new InviteCodeStatisticDetailOutDto
+            { 
+                OpenId = m.WXOpenId
+            }, true);
         return query;
     }
 

+ 6 - 0
src/Hotline/Snapshot/InviteCode.cs

@@ -46,4 +46,10 @@ public class InviteCode : CreationSoftDeleteEntity
     /// </summary>
     [SugarColumn(ColumnDescription = "邀请码Url")]
     public string? QRCodeUrl { get; set; }
+
+    /// <summary>
+    /// 上传附件Id
+    /// </summary>
+    [SugarColumn(ColumnDescription ="上传附件Id")]
+    public string? Additions { get; set; }
 }