70 lines
2.6 KiB
C#
Executable File
70 lines
2.6 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;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Opsoft.NetCore.O3App.Services.BaseData
|
|
{
|
|
[MapTo(typeof(IPersonalMessageService), ServiceLifetime.Transient)]
|
|
public class PersonalMessageService : ServiceBase<SYS_PRESONINFO, IPersonalMessageRepository>, IPersonalMessageService
|
|
{
|
|
public PersonalMessageService(IPersonalMessageRepository repository) : base(repository)
|
|
{
|
|
Init(repository);
|
|
}
|
|
/// <summary>
|
|
/// 获取当前登录用户的所有消息
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public async Task<GetPersonalMessage> GetAllPersonalMessage(object data)
|
|
{
|
|
dynamic getData = JsonOperator.JsonDeserialize<dynamic>(data.ToString());
|
|
if (getData.userId == null)
|
|
{
|
|
throw new Exception($@"登录人不能为空!");
|
|
}
|
|
return await (repository as IPersonalMessageRepository).GetAllPersonalMessage(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新个人消息
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public async Task<GetPersonalMessage> UpdatePersonalMessage(UpdatePersonalMeaasge data)
|
|
{
|
|
if (data.MeaasgeNoList.IsNullOrEmpty())
|
|
{
|
|
throw new Exception($@"请传入更新的消息编号");
|
|
}
|
|
else if (data.Type != 3 && data.Type != 4)
|
|
{
|
|
throw new Exception($@"操作类型必须是3 ,或者4");
|
|
}
|
|
return await (repository as IPersonalMessageRepository).UpdatePersonalMessage(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取个人未读的消息数量
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public async Task<object> GetCountUnReadPersonalMessage(object data)
|
|
{
|
|
|
|
dynamic getData = JsonOperator.JsonDeserialize<dynamic>(data.ToString());
|
|
if (getData.userId==null)
|
|
{
|
|
throw new Exception($@"登录人不能为空!");
|
|
}
|
|
return await(repository as IPersonalMessageRepository).GetCountUnReadPersonalMessage(data);
|
|
}
|
|
}
|
|
}
|