| | |
| | | using Aop.Api.Domain; |
| | | using ApiTools.Core; |
| | | using ApiTools.Core.Entities.LogRecords; |
| | | using Furion; |
| | | using Furion.DatabaseAccessor; |
| | | using Furion.HttpRemote; |
| | | using log4net.Core; |
| | | using MediatR; |
| | |
| | | namespace ApiTools.Application |
| | | { |
| | | public class WxmpSubscribMessageCommandHandler( |
| | | IRepository<WxmpSubscribMessageLog> repWxmpSubscribMessageLog, |
| | | ILogger<WxmpSubscribMessageCommandHandler> logger, |
| | | WxmpUtils utils, |
| | | IHttpRemoteService httpRemoteService |
| | | ) : |
| | | IRequestHandler<SendWxmpSubscribMessageCommand, Guid>, |
| | | IRequestHandler<WxmpSubscribMessageNotifyCommand, bool> |
| | | IRequestHandler<WxmpSubscribMessageNotifyCommand, Guid> |
| | | { |
| | | private readonly IRepository<WxmpSubscribMessageLog> repWxmpSubscribMessageLog = repWxmpSubscribMessageLog; |
| | | private readonly ILogger<WxmpSubscribMessageCommandHandler> logger = logger; |
| | | private readonly WxmpUtils utils = utils; |
| | | private readonly IHttpRemoteService httpRemoteService = httpRemoteService; |
| | |
| | | WxmpCode = request.WxmpCode, |
| | | Touser = request.Touser, |
| | | }); |
| | | return Guid.Empty; |
| | | var log = new WxmpSubscribMessageLog |
| | | { |
| | | Code = request.WxmpCode, |
| | | OpenId = request.Touser, |
| | | SubscribeStatusString = "send", |
| | | TemplateId = request.TemplateId, |
| | | Page = request.Page, |
| | | Data = request.Data.ToJson() |
| | | }; |
| | | await repWxmpSubscribMessageLog.InsertNowAsync(log); |
| | | return log.Id; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="request"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<bool> Handle(WxmpSubscribMessageNotifyCommand request, CancellationToken cancellationToken) |
| | | public async Task<Guid> Handle(WxmpSubscribMessageNotifyCommand request, CancellationToken cancellationToken) |
| | | { |
| | | var env = App.GetConfig<string>("Environment"); |
| | | if (env == "Product") |
| | |
| | | |
| | | } |
| | | } |
| | | return true; |
| | | |
| | | var log = new WxmpSubscribMessageLog |
| | | { |
| | | Code = request.Code, |
| | | OpenId = request.OpenId, |
| | | PopupScene = request.Content.PopupScene, |
| | | SubscribeStatusString = request.Content.SubscribeStatusString, |
| | | TemplateId = request.Content.TemplateId |
| | | }; |
| | | await repWxmpSubscribMessageLog.InsertNowAsync(log); |
| | | return log.Id; |
| | | } |
| | | } |
| | | } |