using Dapr; using FrameworkBLL.EventLog; using FrameworkDAL.DTO.EventLog; using FrameworkSL.Endpoints.Module; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.PubSub; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.EventLog { [ApiController] public class SubscribeEventLog { private readonly ILogger _logger; private readonly IEventLogBLL _eventLogBLL; public SubscribeEventLog(IEventLogBLL eventLogBLL,ILogger Logger) { _logger = Logger; _eventLogBLL = eventLogBLL; } [Topic("pubsub", "SavePayProduction")] [HttpPost("/SubscribeEventLog")] public async Task HandleModuleListEvent([FromBody] string Message) { try { _logger.LogInformation("Received PubSub message on topic 'SubscribeEventLog': {Message}", Message); EventLogDTO? EventLogDTO = System.Text.Json.JsonSerializer.Deserialize(Message); var Result = await _eventLogBLL.SaveEventLog(EventLogDTO!, EventLogDTO!.Login!); _logger.LogInformation("Received PubSub Result message on 'SubscribeEventLogTopic': {Result}", Result); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED,null!); } catch (Exception) { throw; } } } }