This commit is contained in:
SunCheng
2026-02-10 17:49:19 +08:00
parent 3e18283e52
commit d052ae5197
104 changed files with 10369 additions and 3000 deletions

View File

@@ -1,48 +1,29 @@
using Service.Message;
using Application;
namespace WebApi.Controllers;
[ApiController]
[Route("api/[controller]/[action]")]
public class NotificationController(INotificationService notificationService) : ControllerBase
public class NotificationController(
INotificationApplication notificationApplication
) : ControllerBase
{
[HttpGet]
public async Task<BaseResponse<string>> GetVapidPublicKey()
{
try
{
var key = await notificationService.GetVapidPublicKeyAsync();
return key.Ok<string>();
}
catch (Exception ex)
{
return ex.Message.Fail<string>();
}
var key = await notificationApplication.GetVapidPublicKeyAsync();
return key.Ok<string>();
}
public async Task<BaseResponse> Subscribe([FromBody] PushSubscription subscription)
{
try
{
await notificationService.SubscribeAsync(subscription);
return BaseResponse.Done();
}
catch (Exception ex)
{
return ex.Message.Fail();
}
await notificationApplication.SubscribeAsync(subscription);
return BaseResponse.Done();
}
public async Task<BaseResponse> TestNotification([FromQuery] string message)
{
try
{
await notificationService.SendNotificationAsync(message);
return BaseResponse.Done();
}
catch (Exception ex)
{
return ex.Message.Fail();
}
await notificationApplication.SendNotificationAsync(message);
return BaseResponse.Done();
}
}