|
@@ -1,6 +1,8 @@
|
|
|
-using DotNetCore.CAP;
|
|
|
+using DocumentFormat.OpenXml.Vml.Office;
|
|
|
+using DotNetCore.CAP;
|
|
|
using Hotline.Application.Snapshot.Contracts;
|
|
|
using Hotline.Caching.Interfaces;
|
|
|
+using Hotline.Orders;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Share.Attributes;
|
|
|
using Hotline.Share.Dtos.Article;
|
|
@@ -69,12 +71,13 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
|
|
|
await _bulletinRepository.UpdateAsync(bulletin, token);
|
|
|
|
|
|
var citizens = await _safetyTypeRepository.Queryable()
|
|
|
- .Includes(m => m.Citizens.Select(c => c.Id))
|
|
|
- .Where(m => m.Id == bulletin.SafetyTypeId)
|
|
|
+ .LeftJoin<CitizenRelationSafetyType>((safety, relation) => safety.Id == relation.SafetyTypeId)
|
|
|
+ .LeftJoin<Citizen>((safety, relation, citizen) => relation.CitizenId == citizen.Id)
|
|
|
+ .Where((safety, relation, citizen) => safety.Id == bulletin.SafetyTypeId)
|
|
|
+ .Select((safety, relation, citizen) => citizen.Id)
|
|
|
.ToListAsync(token);
|
|
|
|
|
|
await _capPublisher.PublishAsync(Share.Mq.EventNames.BulletinIsPass, bulletin.Id, cancellationToken: token);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -86,16 +89,20 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
|
|
|
public async Task NotifyUserAsync(string bullutionId, CancellationToken token)
|
|
|
{
|
|
|
await _bulletinRepository.GetAsync(bullutionId, token)
|
|
|
- .Then(async bulletion => {
|
|
|
- await _safetyTypeRepository.Queryable().Where(m => m.Id == bulletion.SafetyTypeId)
|
|
|
- .Includes(m => m.Citizens.Select(c => c.Id))
|
|
|
- .FirstAsync(token)
|
|
|
- .Then(async safetyType =>
|
|
|
- {
|
|
|
- var inDto = bulletion.Adapt<AddNotifyInDto>();
|
|
|
- inDto.UserIds = [.. safetyType.Citizens.Select(m => m.Id)];
|
|
|
- await _notificationDomainService.AddNotifyAsync(inDto, token);
|
|
|
- });
|
|
|
+ .Then(async bulletion =>
|
|
|
+ {
|
|
|
+ await _safetyTypeRepository.Queryable()
|
|
|
+ .LeftJoin<CitizenRelationSafetyType>((safety, relation) => safety.Id == relation.SafetyTypeId)
|
|
|
+ .LeftJoin<Citizen>((safety, relation, citizen) => relation.CitizenId == citizen.Id)
|
|
|
+ .Where((safety, relation, citizen) => safety.Id == bulletion.SafetyTypeId)
|
|
|
+ .Select((safety, relation, citizen) => relation.CitizenId)
|
|
|
+ .ToListAsync(token)
|
|
|
+ .Then(async citizenIds =>
|
|
|
+ {
|
|
|
+ var inDto = bulletion.Adapt<AddNotifyInDto>();
|
|
|
+ inDto.UserIds = citizenIds;
|
|
|
+ await _notificationDomainService.AddNotifyAsync(inDto, token);
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -161,10 +168,26 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public async Task CommitBulletinAsync(string id, CancellationToken requestAborted)
|
|
|
+ {
|
|
|
+ var bulletin = await _bulletinRepository.GetAsync(id, requestAborted);
|
|
|
+ if (bulletin == null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效数据");
|
|
|
+
|
|
|
+ if (bulletin.BulletinState != EBulletinState.Draft && bulletin.BulletinState != EBulletinState.ReviewNoPass)
|
|
|
+ throw UserFriendlyException.SameMessage("当前状态不能提交");
|
|
|
+
|
|
|
+ bulletin.BulletinState = EBulletinState.InReview;
|
|
|
+ bulletin.CommitTime = DateTime.Now;
|
|
|
+ await _bulletinRepository.UpdateAsync(bulletin, requestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public async Task<string> AddBulletinAsync(AddSnapshotBulletinInDto dto, CancellationToken token)
|
|
|
{
|
|
|
var model = dto.Adapt<SnapshotBulletin>();
|
|
|
- model.BulletinState = Share.Enums.Article.EBulletinState.Draft;
|
|
|
+ model.BulletinState = EBulletinState.Draft;
|
|
|
model.ReadedNum = 0;
|
|
|
if (model.BulletinTime.HasValue == false) model.BulletinTime = DateTime.Now;
|
|
|
return await _bulletinRepository.AddAsync(model, token);
|