Files
GX.O3.WMS/APP.O3/Services/BaseData/UserMessageService.cs
T

116 lines
4.2 KiB
C#
Executable File

using Microsoft.Extensions.DependencyInjection;
using Opsoft.NetCore.O3App.Domain.UnitOfWork.BaseData.IRepositories;
using Opsoft.NetCore.O3App.Domain.UnitOfWork.BaseData.IServices;
using Opsoft.NetCore.O3App.Domain.UnitOfWork.BaseData.Model;
using Opsoft.NetCore.O3App.Shared;
using System.Collections.Generic;
using System.Threading.Tasks;
using Opsoft.NetCore.O3App.Domain;
using System;
namespace Opsoft.NetCore.O3App.Services.BaseData
{
[MapTo(typeof(IUserMessageService), ServiceLifetime.Transient)]
public class UserMessageService : ServiceBase<SYS_USERMESSAGE, IUserMessageRepository>, IUserMessageService
{
public UserMessageService(IUserMessageRepository repository) : base(repository)
{
Init(repository);
}
/// <summary>
/// 获取所有的信息
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public async Task<List<UserMessages>> GetAllUserMessage(dynamic data)
{
return await (repository as IUserMessageRepository).GetAllUserMessage(data);
}
/// 获取未读信息数量
/// </summary>
/// <returns></returns>
///
public async Task<List<GetAllUserMessageUnReadCountDto>> GetAllUserMessageUnReadCount()
{
return await (repository as IUserMessageRepository).GetAllUserMessageUnReadCount();
}
/// <summary>
/// 获取所有已读消息
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public async Task<List<UserMessages>> GetAllUserMessageRead(dynamic data)
{
return await (repository as IUserMessageRepository).GetAllUserMessageRead(data);
}
/// <summary>
/// 消息标记为已读
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public async Task<List<UpdateMessageStatus>> UpdateMessageStatus(dynamic data)
{
return await (repository as IUserMessageRepository).UpdateMessageStatus(data);
}
/// <summary>
/// 新闻列表显示方法
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public async Task<List<SYS_NEWS>> GetAllNewsBulletinUnRead(object data)
{
return await (repository as IUserMessageRepository).GetAllNewsBulletinUnRead(data);
}
/// <summary>
/// 获取新闻公告
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public async Task<List<EnAnnou>> Notice(GetNotice SData)
{
if (SData.basicType==null)
{
throw new O3AppException("传参信息错误,未定义",400);
}
if (!int.TryParse(SData.basicType.ToString(),out int basicType))
{
throw new O3AppException("类别信息错误,值设定有误", 400);
}
switch (SData.basicType.ToString())
{
case "2":
if (SData.pageSize==null || SData.pageIndex==null)
{
throw new O3AppException("页码信息错误,未定义", 400);
}
if (!int.TryParse(SData.pageSize.ToString(), out int pageSize))
{
throw new O3AppException("页码信息错误,值设定有误", 400);
}
if (!int.TryParse(SData.pageIndex.ToString(), out int pageIndex))
{
throw new O3AppException("页码信息错误,值设定有误", 400);
}
break;
case "3":
if (SData.UID == null)
{
throw new O3AppException("UID信息错误,未定义", 400);
}
break;
}
return await (repository as IUserMessageRepository).Notice(SData);
}
}
}