这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
2.1 KiB

using LINGYUN.Abp.Notifications;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.MessageService.Controllers
{
[Route("api/app/notifications")]
public class NotificationController : AbpController
{
private readonly INotificationDispatcher _notificationDispatcher;
public NotificationController(
INotificationDispatcher notificationDispatcher)
{
_notificationDispatcher = notificationDispatcher;
}
[HttpPost]
[Route("Send")]
public async Task SendNofitication([FromForm] SendNotification notification)
{
var notificationInfo = new NotificationInfo
{
TenantId = null,
NotificationSeverity = notification.Severity,
NotificationType = NotificationType.Application,
Id = new Random().Next(int.MinValue, int.MaxValue),
Name = "TestApplicationNotofication",
CreationTime = Clock.Now
};
notificationInfo.Data.Properties["id"] = notificationInfo.Id.ToString();
notificationInfo.Data.Properties["title"] = notification.Title;
notificationInfo.Data.Properties["message"] = notification.Message;
notificationInfo.Data.Properties["datetime"] = Clock.Now;
notificationInfo.Data.Properties["severity"] = notification.Severity;
await _notificationDispatcher.DispatcheAsync(notificationInfo);
}
}
public class SendNotification
{
public Guid UserId { get; set; }
public string Title { get; set; }
public string Message { get; set; }
public NotificationSeverity Severity { get; set; } = NotificationSeverity.Success;
}
public class TestApplicationNotificationData : NotificationData
{
public object Message
{
get { return this[nameof(Message)]; }
set
{
Properties[nameof(Message)] = value;
}
}
}
}