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, IUserMessageService { public UserMessageService(IUserMessageRepository repository) : base(repository) { Init(repository); } /// /// 获取所有的信息 /// /// /// public async Task> GetAllUserMessage(dynamic data) { return await (repository as IUserMessageRepository).GetAllUserMessage(data); } /// 获取未读信息数量 /// /// /// public async Task> GetAllUserMessageUnReadCount() { return await (repository as IUserMessageRepository).GetAllUserMessageUnReadCount(); } /// /// 获取所有已读消息 /// /// /// public async Task> GetAllUserMessageRead(dynamic data) { return await (repository as IUserMessageRepository).GetAllUserMessageRead(data); } /// /// 消息标记为已读 /// /// /// public async Task> UpdateMessageStatus(dynamic data) { return await (repository as IUserMessageRepository).UpdateMessageStatus(data); } /// /// 新闻列表显示方法 /// /// /// public async Task> GetAllNewsBulletinUnRead(object data) { return await (repository as IUserMessageRepository).GetAllNewsBulletinUnRead(data); } /// /// 获取新闻公告 /// /// /// public async Task> 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); } } }