using Furion.EventBus;

namespace BPA.MES.Base.Application.Subscriber
{
    /// <summary>
    /// 名    称 ：  
    /// 创 建 人 ：yangxiao  
    /// 创建时间 ：  2023/7/20 15:09:49 
    /// 描    述 ：  
    /// </summary>
    public class ToDoEventSubscriber : IEventSubscriber
    {
        private readonly ISqlSugarClient _dbContext;
        public ToDoEventSubscriber(ISqlSugarClient db)
        {
            _dbContext = db;
        }

        [EventSubscribe("ToDo:OperLog")]
        public async Task CreateToDo(EventHandlerExecutingContext context)
        {
            var todo = context.Source;
            OperLogEntity entity =(OperLogEntity)todo.Payload;
            await _dbContext.Insertable(entity).ExecuteCommandAsync();
            await Task.CompletedTask;
        }
    }
}
