2 Комити 91ce5faa81 ... e40a36f0a1

Аутор SHA1 Порука Датум
  qinchaoyue e40a36f0a1 Merge branch 'feature/snapshot' into test пре 1 дан
  qinchaoyue 633477aedc 公告新增反惨 пре 1 дан

+ 12 - 3
src/Hotline.Api/Controllers/Snapshot/SnapshotBulletinController.cs

@@ -57,12 +57,21 @@ public class SnapshotBulletinController : BaseController
     {
         var model = await _bulletinRepository.Queryable()
             .Includes(x => x.ExaminMan)
-            .FirstAsync(x => x.Id == id, HttpContext.RequestAborted);
+            .FirstAsync(x => x.Id == id, HttpContext.RequestAborted)
+            ?? throw UserFriendlyException.SameMessage("公告不存在");
 
         if (model != null && !string.IsNullOrEmpty(model.Content))
             model.Content = _bulletinApplication.GetSiteUrls(model.Content);
 
-        return model.Adapt<SnapshotBulletinDetailOutDto>();
+        var outDto = model.Adapt<SnapshotBulletinDetailOutDto>();
+        if (outDto.SafetyTypeId.NotNullOrEmpty())
+        {
+            outDto.SafetyTypeNames = await _safetyTypeRepository.Queryable()
+                .Where(m => outDto.SafetyTypeId.Contains(m.Id))
+                .Select(m => m.Name)
+                .ToListAsync();
+        }
+        return outDto;
     }
 
     /// <summary>
@@ -180,7 +189,7 @@ public class SnapshotBulletinController : BaseController
     public async Task<object> BulletinAddBaseData()
     {
         var safetyTypes = await _safetyTypeRepository.Queryable()
-            .Select(m => new SystemDicDataOutDto { Id =  m.Id, DicDataName = m.Name , DicDataValue = m.Id})
+            .Select(m => new SystemDicDataOutDto { Id = m.Id, DicDataName = m.Name, DicDataValue = m.Id })
             .ToListAsync(HttpContext.RequestAborted);
         var rsp = new
         {

+ 3 - 9
src/Hotline.Application/Snapshot/SnapshotBulletinApplication.cs

@@ -1,5 +1,4 @@
-using DocumentFormat.OpenXml.Vml.Office;
-using DotNetCore.CAP;
+using DotNetCore.CAP;
 using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.Orders;
@@ -14,14 +13,9 @@ using Hotline.Snapshot;
 using Hotline.Snapshot.Contracts;
 using Hotline.Snapshot.IRepository;
 using Mapster;
-using Microsoft.AspNetCore.Http;
 using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
-using System.Threading.Tasks;
 using XF.Domain.Authentications;
 using XF.Domain.Dependency;
 using XF.Domain.Exceptions;
@@ -85,7 +79,7 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
         await _bulletinRepository.GetAsync(bullutionId, token)
             .Then(async bulletion =>
             {
-                if (bulletion!.IsSnapshot == false) return;
+                if (bulletion!.SnapshotBulletinTypeId != "aqws") return;
                 if (bulletion!.SafetyTypeId!.IsNullOrEmpty()) return;
                 foreach (var safetyTypeId in bulletion!.SafetyTypeId!)
                 {
@@ -99,7 +93,7 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
                         {
                             var inDto = bulletion.Adapt<AddNotifyInDto>();
                             inDto.UserIds = citizenIds;
-                            if (bulletion.VideoPath.NotNullOrEmpty())
+                            if (bulletion.Shape != null && bulletion.Shape == EBulletinShape.Video)
                             {
                                 inDto.NotifyType = ENotificationType.Video;
                             }

+ 8 - 2
src/Hotline.Share/Dtos/Snapshot/SnapshotBulletinDto.cs

@@ -1,5 +1,6 @@
 using Hotline.Share.Dtos.Users;
 using Hotline.Share.Enums.Article;
+using Hotline.Share.Enums.Snapshot;
 using Hotline.Share.Requests;
 using System;
 using System.Collections.Generic;
@@ -163,6 +164,11 @@ public class SnapshotBulletinDetailOutDto : UpdateSnapshotBulletinInDto
     /// 上下架
     /// </summary>
     public bool IsArrive { get; set; }
+
+    /// <summary>
+    /// 类型
+    /// </summary>
+    public IList<string> SafetyTypeNames { get; set; }
 }
 
 public class UpdateSnapshotBulletinInDto : AddSnapshotBulletinInDto
@@ -256,9 +262,9 @@ public class AddSnapshotBulletinInDto
     public bool IsPopup { get; set; }
 
     /// <summary>
-    /// 是否随手拍
+    /// 公告形式
     /// </summary>
-    public bool? IsSnapshot { get; set; }
+    public EBulletinShape? Shape { get; set; }
 
     /// <summary>
     /// 志愿者类型Id

+ 23 - 0
src/Hotline.Share/Enums/Snapshot/EBulletinShape.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Enums.Snapshot;
+
+public enum EBulletinShape
+{
+    /// <summary>
+    /// 消息
+    /// </summary>
+    [Description("消息")]
+    Message = 0,
+
+    /// <summary>
+    /// 视频
+    /// </summary>
+    [Description("视频")]
+    Video = 1
+}

+ 4 - 3
src/Hotline/Snapshot/SnapshotBulletin.cs

@@ -1,5 +1,6 @@
 using Hotline.Share.Dtos;
 using Hotline.Share.Enums.Article;
+using Hotline.Share.Enums.Snapshot;
 using Hotline.Users;
 using SqlSugar;
 using System.ComponentModel;
@@ -177,10 +178,10 @@ public class SnapshotBulletin : CreationEntity
     }
 
     /// <summary>
-    /// 是否随手拍
+    /// 公告形式
     /// </summary>
-    [SugarColumn(ColumnDescription = "是否随手拍")]
-    public bool? IsSnapshot { get; set; }
+    [SugarColumn(ColumnDescription = "公告形式")]
+    public EBulletinShape? Shape { get; set; }
 
     /// <summary>
     /// 志愿者类型Id

+ 3 - 3
test/Hotline.Tests/Application/SnapshotBulletionApplicationTest.cs

@@ -51,7 +51,7 @@ public class SnapshotBulletionApplicationTest : TestBase
     public async Task Bulletin_Test()
     {
         SetWeiXin();
-        var bulletinType =  _systemDicDataCacheManager.SnapshotBulletinType.First();
+        var bulletinType =  _systemDicDataCacheManager.SnapshotBulletinType.First(m => m.DicDataName == "安全卫士");
         var safetyType = await _safetyTypeRepository.Queryable().FirstAsync();
         var addRelationInDto = new AddCitizenRelationSafetyTypeInDto { SafetyTypeId = safetyType.Id, CitizenIds = [_sessionContext.UserId] };
         await _snapshotUserApplication.AddCitizenRelationSafetyType(addRelationInDto, CancellationToken.None);
@@ -60,7 +60,7 @@ public class SnapshotBulletionApplicationTest : TestBase
             Title = "测试公告" + DateTime.Now.ToLongDateTimeString(),
             Content = "没什么内容",
             BulletinTime = DateTime.Now,
-            IsSnapshot = true,
+            Shape = Share.Enums.Snapshot.EBulletinShape.Video,
             BulletinTypeId = bulletinType.DicDataValue,
             BulletinTypeName = bulletinType.DicDataName,
             SafetyTypeId = [safetyType.Id],
@@ -69,7 +69,7 @@ public class SnapshotBulletionApplicationTest : TestBase
         };
         var bulletinId = await _snapshotBulletinApplication.AddBulletinAsync(inDto, CancellationToken.None);
         var bulletin = await _bulletinRepository.GetAsync(bulletinId);
-        bulletin.IsSnapshot.ShouldBe(true);
+        bulletin.Shape.ShouldBe(Share.Enums.Snapshot.EBulletinShape.Video);
         bulletin.SafetyTypeId.First().ShouldBe(safetyType.Id);
         bulletin.VideoPath.ShouldBe(inDto.VideoPath);
         bulletin.VideoCoverImgUrl.ShouldBe(inDto.VideoCoverImgUrl);