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;
}
///
/// 消息已读
///
///
///
[HttpPost("[action]")]
public async Task Read([FromBody] List? messageIds)
{
if (messageIds == null || !messageIds.Any()) throw new ArgumentNullException("messageIds 不能为空!");
return await _notificationDomain.Read(messageIds);
}
///
/// 全部消息已读
///
///
///
[HttpPost("[action]")]
public async Task ReadAll()
{
return await _notificationDomain.RealAll();
}
///
/// 个人中心消息分页
///
///
///
[HttpGet("[action]")]
public async Task> Page([FromQuery] NotificationSearchPageDto search)
{
return await _notificationDomain.GetNotificationsPage(search);
}
///
/// 消息统计分页
///
///
///
[HttpGet("Statistics/Page")]
public async Task> GetNotificationStatisticsPage([FromQuery] NotificationStatisticsSearchPageDto dto)
{
return await _notificationDomain.GetNotificationStatisticsPage(dto);
}
///
/// 部门下拉
///
///
[HttpGet("Depts")]
public async Task> GetDeptments()
{
return await _cacheDomain.GetDeptments();
}
///
/// 重复成交的部门
///
///
[HttpGet("RepeatDepts")]
public async Task GetRepeatDeptments()
{
return await _notificationDomain.GetRepeatDeptments();
}
///
/// 消息数量
///
///
///
///
[HttpGet("messageCount")]
public async Task GetMessageCount([FromQuery] decimal? eid, string? connectionId)
{
return await _notificationDomain.GetMessageCount(eid, null, connectionId);
}
///
/// 发送消息
///
///
///
[HttpPost("sendMessage")]
public async Task SendMessage([FromBody] SendMessageDto dto)
{
await _notificationDomain.SendMessage(dto);
}
}
}