Notice 第二阶段
This commit is contained in:
@@ -72,5 +72,10 @@ namespace Ewide.Core
|
||||
/// </summary>
|
||||
[Comment("状态")]
|
||||
public int Status { get; set; }
|
||||
/// <summary>
|
||||
/// 上传文件ids
|
||||
/// </summary>
|
||||
[Comment("上传文件id集合")]
|
||||
public string Attachments { set; get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,6 +1223,11 @@
|
||||
状态(字典 0草稿 1发布 2撤回 3删除)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.SysNotice.Attachments">
|
||||
<summary>
|
||||
上传文件ids
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Ewide.Core.SysNoticeUser">
|
||||
<summary>
|
||||
通知公告用户表
|
||||
@@ -5332,6 +5337,11 @@
|
||||
通知公告参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.NoticeBase.Id">
|
||||
<summary>
|
||||
ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.NoticeBase.Title">
|
||||
<summary>
|
||||
标题
|
||||
@@ -5397,6 +5407,11 @@
|
||||
通知到的用户阅读信息集合
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.NoticeDetailOutput.Attachments">
|
||||
<summary>
|
||||
上传文件Id集合
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.NoticeUserRead.UserId">
|
||||
<summary>
|
||||
用户Id
|
||||
@@ -5472,6 +5487,11 @@
|
||||
通知到的人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.AddNoticeInput.Attachments">
|
||||
<summary>
|
||||
上传文件集合
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.DeleteNoticeInput.Id">
|
||||
<summary>
|
||||
Id
|
||||
|
||||
@@ -7,6 +7,10 @@ namespace Ewide.Core.Service
|
||||
/// </summary>
|
||||
public class NoticeBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public string Id { set; get; }
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace Ewide.Core.Service
|
||||
/// 通知到的用户阅读信息集合
|
||||
/// </summary>
|
||||
public List<NoticeUserRead> NoticeUserReadInfoList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件Id集合
|
||||
/// </summary>
|
||||
public string Attachments { set; get; }
|
||||
}
|
||||
|
||||
public class NoticeUserRead
|
||||
|
||||
@@ -65,6 +65,11 @@ namespace Ewide.Core.Service
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "通知到的人不能为空")]
|
||||
public override List<string> NoticeUserIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件集合
|
||||
/// </summary>
|
||||
public List<string> Attachments { set; get; }
|
||||
}
|
||||
|
||||
public class DeleteNoticeInput
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Ewide.Core.Service.Notice
|
||||
{
|
||||
var searchValue = !string.IsNullOrEmpty(input.SearchValue?.Trim());
|
||||
var notices = await _sysNoticeRep.DetachedEntities
|
||||
.Where(searchValue, u => EF.Functions.Like(u.Title, $"%{input.SearchValue.Trim()}%") ||
|
||||
.Where(searchValue, u => EF.Functions.Like(u.Title, $"%{input.SearchValue.Trim()}%") ||
|
||||
EF.Functions.Like(u.Content, $"%{input.SearchValue.Trim()}%"))
|
||||
.Where(input.Type > 0, u => u.Type == input.Type)
|
||||
.Where(u => u.Status != (int)NoticeStatus.DELETED)
|
||||
@@ -79,6 +79,8 @@ namespace Ewide.Core.Service.Notice
|
||||
var notice = input.Adapt<SysNotice>();
|
||||
var id = System.Guid.NewGuid().ToString().ToLower();
|
||||
notice.Id = id;
|
||||
if (input.Attachments!=null)
|
||||
notice.Attachments = string.Join(",", input.Attachments);
|
||||
await UpdatePublicInfo(notice);
|
||||
// 如果是发布,则设置发布时间
|
||||
if (input.Status == (int)NoticeStatus.PUBLIC)
|
||||
@@ -123,12 +125,14 @@ namespace Ewide.Core.Service.Notice
|
||||
throw Oops.Oh(ErrorCode.D7002);
|
||||
|
||||
var notice = input.Adapt<SysNotice>();
|
||||
if (input.Attachments != null)
|
||||
notice.Attachments = string.Join(",", input.Attachments);
|
||||
if (input.Status == (int)NoticeStatus.PUBLIC)
|
||||
{
|
||||
notice.PublicTime = DateTime.Now;
|
||||
await UpdatePublicInfo(notice);
|
||||
}
|
||||
await notice.UpdateAsync();
|
||||
await notice.UpdateAsync(true);
|
||||
|
||||
// 通知到的人
|
||||
var noticeUserIdList = input.NoticeUserIdList;
|
||||
@@ -212,11 +216,11 @@ namespace Ewide.Core.Service.Notice
|
||||
{
|
||||
var sql = @"SELECT
|
||||
SN.*,
|
||||
SU.Avatar
|
||||
SU.Avatar,SNU.ReadStatus
|
||||
FROM sys_notice SN
|
||||
LEFT JOIN sys_notice_user SNU ON SN.Id = SNU.NoticeId
|
||||
LEFT JOIN sys_user SU ON SN.PublicUserId = SU.Id
|
||||
WHERE SNU.UserId = @UserId AND SN.Status <> @Status";
|
||||
WHERE SNU.UserId = @UserId AND SN.Status = @Status";
|
||||
|
||||
var data = await _dapperRepository.QueryPageDataDynamic(
|
||||
sql,
|
||||
@@ -224,11 +228,16 @@ WHERE SNU.UserId = @UserId AND SN.Status <> @Status";
|
||||
new
|
||||
{
|
||||
_userManager.UserId,
|
||||
Status = (int)NoticeStatus.DELETED
|
||||
Status = (int)NoticeStatus.PUBLIC
|
||||
},
|
||||
new[]
|
||||
{
|
||||
"Type","Title"
|
||||
}
|
||||
);
|
||||
|
||||
data.Items = data.Items.Select(p => {
|
||||
data.Items = data.Items.Select(p =>
|
||||
{
|
||||
var r = p.Adapt<dynamic>();
|
||||
r.Content = Regex.Replace(r.Content, @"<\/?.+?\/?>", "").Replace("\r\n", "");
|
||||
return r;
|
||||
@@ -245,7 +254,8 @@ WHERE SNU.UserId = @UserId AND SN.Status <> @Status";
|
||||
[HttpGet("/sysNotice/unread")]
|
||||
public async Task<int> GetUnreadCount()
|
||||
{
|
||||
return await _sysNoticeUserRep.Where(u => u.UserId == _userManager.UserId && u.ReadStatus == (int)NoticeUserStatus.UNREAD).CountAsync();
|
||||
var noticeList = await _sysNoticeRep.Where(u => u.Status != (int)NoticeStatus.DELETED).Select(s => s.Id).ToListAsync();
|
||||
return await _sysNoticeUserRep.Where(u => u.UserId == _userManager.UserId && noticeList.Contains(u.NoticeId) && u.ReadStatus == (int)NoticeUserStatus.UNREAD).CountAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user