fix
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 37s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s

This commit is contained in:
2026-01-02 18:51:28 +08:00
parent e250a7df2f
commit 5c76e9287e
9 changed files with 60 additions and 66 deletions

View File

@@ -1,27 +1,46 @@
namespace WebApi.Controllers;
[ApiController]
[Route("api/[controller]")]
[Route("api/[controller]/[action]")]
public class NotificationController(INotificationService notificationService) : ControllerBase
{
[HttpGet("vapid-public-key")]
public async Task<IActionResult> GetVapidPublicKey()
[HttpGet()]
public async Task<BaseResponse<string>> GetVapidPublicKey()
{
var key = await notificationService.GetVapidPublicKeyAsync();
return Ok(new { publicKey = key });
try
{
var key = await notificationService.GetVapidPublicKeyAsync();
return BaseResponse<string>.Done(key);
}
catch (Exception ex)
{
return BaseResponse<string>.Fail(ex.Message);
}
}
[HttpPost("subscribe")]
public async Task<IActionResult> Subscribe([FromBody] PushSubscriptionEntity subscription)
public async Task<BaseResponse> Subscribe([FromBody] PushSubscriptionEntity subscription)
{
await notificationService.SubscribeAsync(subscription);
return Ok();
try
{
await notificationService.SubscribeAsync(subscription);
return BaseResponse.Done();
}
catch (Exception ex)
{
return BaseResponse.Fail(ex.Message);
}
}
[HttpPost("test")]
public async Task<IActionResult> TestNotification([FromQuery] string message)
public async Task<BaseResponse> TestNotification([FromQuery] string message)
{
await notificationService.SendNotificationAsync(message);
return Ok();
try
{
await notificationService.SendNotificationAsync(message);
return BaseResponse.Done();
}
catch (Exception ex)
{
return BaseResponse.Fail(ex.Message);
}
}
}