public async Task <DefaultEventHandlerResponse> InitRoleBasedAccessControler(EventHandleRequest <LoginSuccessDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(InitRoleBasedAccessControler), input.GetDataJson(), async() =>
     {
         InitUserOauthDto.Github data = default;
         if (!string.IsNullOrEmpty(input.GetData().Token))
         {
             data = System.Text.Json.JsonSerializer.Deserialize <InitUserOauthDto.Github>(input.GetData().Token);
         }
         var role = new Role();
         role.SetRole("超级管理员", true);
         roleRepository.Add(role);
         var admin = new Account();
         var defpwd = "x1234567";
         admin.CreateAccount(data?.login ?? "eshopadmin", data?.name ?? "商城管理员", defpwd, Common.GetMD5SaltCode);
         if (data != null)
         {
             admin.User.CreateOrUpdateUser(data?.name ?? "商城管理员", data?.avatar_url ?? "", "", "", UserGender.Male, Convert.ToDateTime("1980-01-01"));
         }
         admin.SetRoles(new List <Guid>()
         {
             role.Id
         });
         var defbuyer = new Account();
         defbuyer.CreateAccount("eshopuser", "白云苍狗", defpwd, Common.GetMD5SaltCode);
         defbuyer.User.CreateOrUpdateUser("张老三", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.huabanimg.com%2F0830450561b24f4573bed70d7f74bd43f39302e11bee-s2tj6i_fw658&refer=http%3A%2F%2Fhbimg.huabanimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1618110799&t=b215598f3b458ad7c08aee2b4614622b", "北京市海淀区太平路1号", "13000000000", UserGender.Male, Convert.ToDateTime("1980-01-01"));
         accountRepository.Add(admin);
         accountRepository.Add(defbuyer);
         if (await new UniqueSuperRoleSpecification(roleRepository).IsSatisfiedBy(role))
         {
             await unitofWork.CommitAsync();
         }
         await stateManager.SetState(new RoleBaseInitCheckCache(true));
     }));
 public async Task <DefaultEventHandlerResponse> LoginCacheExpire(EventHandleRequest <LoginSuccessDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(LoginCacheExpire), input.GetDataJson(), async() =>
     {
         await stateManager.DelState(new AccountLoginAccessToken(input.GetData().Token));
     }));
 }
Ejemplo n.º 3
0
 public async Task <DefaultEventHandlerResponse> EventHandleErrCatch(EventHandleRequest <EventHandlerErrDto> input)
 {
     try
     {
         var entity = input.GetData().CopyTo <EventHandlerErrDto, EventHandleErrorInfo>();
         infoRepository.Add(entity);
         await unitofWork.CommitAsync();
     }
     catch (Exception e)
     {
         logger.LogError($"事件订阅器异常处理持久化失败,异常信息:{e.Message}");
     }
     return(DefaultEventHandlerResponse.Default());
 }
Ejemplo n.º 4
0
 public async Task <DefaultEventHandlerResponse> RecordTradeLogByOrderPay(EventHandleRequest <OperateOrderSuccDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(RecordTradeLogByOrderPay), input.GetDataJson(), async() =>
     {
         var eventData = input.GetData();
         var order = await repository.GetAsync(eventData.OrderId);
         if (order == null)
         {
             throw new ApplicationServiceException($"没有找到订单");
         }
         var tradeLog = new TradeLog();
         tradeLog.CreateTradeLog(TradeLogState.PayOrder, eventData.OrderId, order.OrderNo, null, null, eventData.UserId, eventData.UserName);
         tradeLogRepository.Add(tradeLog);
         await unitofWork.CommitAsync();
     }));
 }
Ejemplo n.º 5
0
 public async Task <DefaultEventHandlerResponse> ExpireCancelOrder(EventHandleRequest <OperateOrderSuccDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(ExpireCancelOrder), input.GetDataJson(), async() =>
     {
         var eventData = input.GetData();
         var order = await repository.GetAsync(eventData.OrderId);
         if (order == null)
         {
             throw new ApplicationServiceException($"没有找到订单");
         }
         var cancelOrderService = new CancelOrderService(UnDeductionGoodsStock);
         if (await cancelOrderService.Cancel(order))
         {
             repository.Update(order);
             var tradeLog = new TradeLog();
             tradeLog.CreateTradeLog(TradeLogState.CancelOrder, eventData.OrderId, order.OrderNo, null, null, Guid.Empty, null);
             tradeLogRepository.Add(tradeLog);
             await unitofWork.CommitAsync();
         }
     }));
 }
Ejemplo n.º 6
0
 public async Task <DefaultEventHandlerResponse> RecordTradeLogByLogisticsReceiveSucc(EventHandleRequest <CreateLogisticsSuccDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(RecordTradeLogByOrderPay), input.GetDataJson(), async() =>
     {
         var eventData = input.GetData();
         var order = await repository.GetAsync(eventData.OrderId);
         if (order == null)
         {
             throw new ApplicationServiceException($"没有找到订单");
         }
         var log = await logisticsRepository.GetAsync(eventData.LogisticsId);
         if (log == null)
         {
             throw new ApplicationServiceException($"没有找到物流单");
         }
         var tradeLog = new TradeLog();
         tradeLog.CreateTradeLog(TradeLogState.ReceivingGoods, eventData.OrderId, order.OrderNo, log.Id, log.LogisticsNo, eventData.UserId, eventData.UserName);
         tradeLogRepository.Add(tradeLog);
         await unitofWork.CommitAsync();
     }));
 }
Ejemplo n.º 7
0
        public async Task <DefaultEventHandlerResponse> LoginCacheExpireJob(EventHandleRequest <LoginSuccessDto> input)
        {
            //作业执行延时后失效登录Token
            var jobid = BackgroundJob.Schedule <IEventBus>(x => x.SendEvent(EventTopicDictionary.Account.LoginExpire, input.GetData()), TimeSpan.FromDays(7));

            return(await Task.FromResult(DefaultEventHandlerResponse.Default()));
        }
Ejemplo n.º 8
0
 public async Task <DefaultEventHandlerResponse> SubscribeByUserInfoEvent(EventHandleRequest <TestEventDto> input)
 {
     logger.LogInformation($"订阅器收到消息:{JsonSerializer.Serialize(input.GetData(), new JsonSerializerOptions() { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) })}");
     return(await Task.FromResult(DefaultEventHandlerResponse.Default()));
 }
Ejemplo n.º 9
0
        public async Task <DefaultEventHandlerResponse> CancelOrderJob(EventHandleRequest <OperateOrderSuccDto> input)
        {
            var jobid = BackgroundJob.Schedule <IEventBus>(x => x.SendEvent(EventTopicDictionary.Order.ExpireCancelOrder, input.GetData()), TimeSpan.FromSeconds(60 * 5));

            return(await Task.FromResult(DefaultEventHandlerResponse.Default()));
        }