|
@@ -185,15 +185,14 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
{
|
|
|
Result result = new Result() { Code = -1, Msg = "未知错误",Data = new object[] { } };
|
|
|
|
|
|
- //userId
|
|
|
- string msgSqlWhere = $" And smra.ReadableUId = {dto.UserId}";
|
|
|
-
|
|
|
//消息类型
|
|
|
List<NotificationTypeView> messageTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
|
|
|
List<int> _operationTypeList = messageTypeViews.Where(it =>it.TypeId == 1021).FirstOrDefault().MsgTypeIds.ToList();
|
|
|
List<int> _taskTypeList = messageTypeViews.Where(it => it.TypeId == 1020).FirstOrDefault().MsgTypeIds.ToList();
|
|
|
List<int> _noticeTypeList = messageTypeViews.Where(it => it.TypeId == 1022).FirstOrDefault().MsgTypeIds.ToList();
|
|
|
|
|
|
+ //userId
|
|
|
+ string msgSqlWhere = $" And smra.ReadableUId = {dto.UserId}";
|
|
|
|
|
|
string msgSql = string.Format(@"Select * From(
|
|
|
Select row_number() over(order by sm.ReleaseTime Desc) as RowNumber,
|
|
@@ -210,59 +209,52 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
|
|
|
var data = await _sqlSugar.SqlQueryable<MessageListView>(msgSql).ToListAsync();
|
|
|
|
|
|
- if (data.Count > 0)
|
|
|
+ var msgTypeResult = await _setData.GetSetDataBySTId(_setData, 77);
|
|
|
+ if (msgTypeResult.Code != 0)
|
|
|
{
|
|
|
- var msgTypeResult = await _setData.GetSetDataBySTId(_setData, 77);
|
|
|
- if (msgTypeResult.Code != 0)
|
|
|
- {
|
|
|
- result.Msg = "消息类型不存在!";
|
|
|
- return result;
|
|
|
- }
|
|
|
- string msgTypeDataStr = JsonConvert.SerializeObject(msgTypeResult.Data);
|
|
|
- var msgTypeData = JsonConvert.DeserializeObject<List<MessageTypeView>>(msgTypeDataStr);
|
|
|
-
|
|
|
- //操作通知 OperationNotification
|
|
|
- var operationNotificationData = data.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
- int operationNotificationDataCount = operationNotificationData.Where(it => it.IsRead == 0).ToList().Count;
|
|
|
+ result.Msg = "消息类型不存在!";
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ string msgTypeDataStr = JsonConvert.SerializeObject(msgTypeResult.Data);
|
|
|
+ var msgTypeData = JsonConvert.DeserializeObject<List<MessageTypeView>>(msgTypeDataStr);
|
|
|
|
|
|
- //任务通知
|
|
|
- var taskNotificationData = data.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();//操作通知所属类型
|
|
|
- int taskNotificationDataCount = taskNotificationData.Where(it => it.IsRead == 0).ToList().Count; //任务通知 TaskNotification
|
|
|
+ //操作通知 OperationNotification
|
|
|
+ var operationNotificationData = data.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
+ int operationNotificationDataCount = operationNotificationData.Where(it => it.IsRead == 0).ToList().Count;
|
|
|
|
|
|
- //公告通知 notice
|
|
|
- var noticeNotificationData = data.Where(it => _noticeTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();//操作通知所属类型
|
|
|
- int noticeNotificationDataCount = noticeNotificationData.Where(it => it.IsRead == 0).ToList().Count; //任务通知 TaskNotification
|
|
|
+ //任务通知
|
|
|
+ var taskNotificationData = data.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();//操作通知所属类型
|
|
|
+ int taskNotificationDataCount = taskNotificationData.Where(it => it.IsRead == 0).ToList().Count; //任务通知 TaskNotification
|
|
|
|
|
|
+ //公告通知 notice
|
|
|
+ var noticeNotificationData = data.Where(it => _noticeTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();//操作通知所属类型
|
|
|
+ int noticeNotificationDataCount = noticeNotificationData.Where(it => it.IsRead == 0).ToList().Count; //任务通知 TaskNotification
|
|
|
|
|
|
- foreach (var item in msgTypeData)
|
|
|
- {
|
|
|
- //1021 团组操作通知 1020 任务操作通知 1022 公告通知
|
|
|
- if (item.Id == 1020) item.UnReadCount = taskNotificationDataCount;
|
|
|
- else if (item.Id == 1021) item.UnReadCount = operationNotificationDataCount;
|
|
|
- else if (item.Id == 1022) item.UnReadCount = noticeNotificationDataCount;
|
|
|
- }
|
|
|
+ foreach (var item in msgTypeData)
|
|
|
+ {
|
|
|
+ //1021 团组操作通知 1020 任务操作通知 1022 公告通知
|
|
|
+ if (item.Id == 1020) item.UnReadCount = taskNotificationDataCount;
|
|
|
+ else if (item.Id == 1021) item.UnReadCount = operationNotificationDataCount;
|
|
|
+ else if (item.Id == 1022) item.UnReadCount = noticeNotificationDataCount;
|
|
|
+ }
|
|
|
|
|
|
- if (dto.PortType == 1 || dto.PortType == 2) // web/android
|
|
|
- {
|
|
|
- result.Code = 0;
|
|
|
- result.Data = msgTypeData;
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2) // web/android
|
|
|
+ {
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = $"操作成功";
|
|
|
+ result.Data = msgTypeData;
|
|
|
|
|
|
- }
|
|
|
- else if (dto.PortType == 3)
|
|
|
- {
|
|
|
- result.Code = 0;
|
|
|
- result.Data = new
|
|
|
- {
|
|
|
- MsgTypeData = msgTypeData,
|
|
|
- FirstUnreadData = data[0],
|
|
|
- UnreadTotalCount = data.Where(it => it.IsRead == 0).ToList().Count,
|
|
|
- };
|
|
|
- }
|
|
|
}
|
|
|
- else
|
|
|
+ else if (dto.PortType == 3)
|
|
|
{
|
|
|
result.Code = 0;
|
|
|
- result.Msg = "暂无消息";
|
|
|
+ result.Msg = $"操作成功";
|
|
|
+ result.Data = new
|
|
|
+ {
|
|
|
+ MsgTypeData = msgTypeData,
|
|
|
+ FirstUnreadData = data[0],
|
|
|
+ UnreadTotalCount = data.Where(it => it.IsRead == 0).ToList().Count,
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
return result;
|