110 lines
3.5 KiB
C#
110 lines
3.5 KiB
C#
using Crm.Core.Domain.Dto.CRM;
|
|
using Crm.Core.Domain.Impl;
|
|
using Crm.Core.Entity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
|
|
|
namespace Crm.Core.WebApi.Controllers
|
|
{
|
|
public class NotificationController : BaseController
|
|
{
|
|
private readonly INotificationDomain _notificationDomain;
|
|
private readonly ICacheDomain _cacheDomain;
|
|
public NotificationController(INotificationDomain notificationDomain,
|
|
ICacheDomain cacheDomain)
|
|
{
|
|
_notificationDomain = notificationDomain;
|
|
_cacheDomain = cacheDomain;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 消息已读
|
|
/// </summary>
|
|
/// <param name="messageId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("[action]")]
|
|
public async Task<bool> Read([FromBody] List<decimal>? messageIds)
|
|
{
|
|
if (messageIds == null || !messageIds.Any()) throw new ArgumentNullException("messageIds 不能为空!");
|
|
return await _notificationDomain.Read(messageIds);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 全部消息已读
|
|
/// </summary>
|
|
/// <param name="messageId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("[action]")]
|
|
public async Task<bool> ReadAll()
|
|
{
|
|
return await _notificationDomain.RealAll();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 个人中心消息分页
|
|
/// </summary>
|
|
/// <param name="search"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("[action]")]
|
|
public async Task<PageResult<NotificationDto>> Page([FromQuery] NotificationSearchPageDto search)
|
|
{
|
|
return await _notificationDomain.GetNotificationsPage(search);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 消息统计分页
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("Statistics/Page")]
|
|
public async Task<LivePageDto<NotificationStatisticsDto>> GetNotificationStatisticsPage([FromQuery] NotificationStatisticsSearchPageDto dto)
|
|
{
|
|
return await _notificationDomain.GetNotificationStatisticsPage(dto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 部门下拉
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("Depts")]
|
|
public async Task<List<DeptmentDto>> GetDeptments()
|
|
{
|
|
return await _cacheDomain.GetDeptments();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重复成交的部门
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("RepeatDepts")]
|
|
public async Task<RepeatDeptmentDto> GetRepeatDeptments()
|
|
{
|
|
return await _notificationDomain.GetRepeatDeptments();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 消息数量
|
|
/// </summary>
|
|
/// <param name="eid"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("messageCount")]
|
|
public async Task<int> GetMessageCount([FromQuery] decimal? eid, string? connectionId)
|
|
{
|
|
return await _notificationDomain.GetMessageCount(eid, null, connectionId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送消息
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("sendMessage")]
|
|
public async Task SendMessage([FromBody] SendMessageDto dto)
|
|
{
|
|
await _notificationDomain.SendMessage(dto);
|
|
}
|
|
}
|
|
}
|