From 47ea3b8f82d6efe1acec5af9d904a3b70c7d3946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com> Date: Tue, 25 Jun 2024 17:53:56 +0800 Subject: [PATCH] =?UTF-8?q?token=E8=A7=A3=E6=9E=90=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProvideServices/TrackPushService.cs | 17 ++++++- .../Services/ProvideServices/TrackService.cs | 50 +++++++++++++++++-- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs index 6897451e..41a91a72 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs @@ -6,6 +6,7 @@ using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackPushAggregate; using SJZY.Track.Domain.Consts; using SJZY.UserCenter.HttpApi.Services; +using Volo.Abp.Http.Client.DynamicProxying; namespace SJZY.Track.Application.Services.ProvideServices; @@ -19,14 +20,17 @@ public class TrackPushService : ApplicationService private readonly IOrderRepository _orderRepository; private readonly ICapPublisher _capPublisher; private readonly ITrackPushRecordsRepository _trackPushRecordsRepository; + private readonly IHttpClientProxy _requestCurrentUserService; public TrackPushService(IOrderRepository orderRepository , ICapPublisher capPublisher - , ITrackPushRecordsRepository trackPushRecordsRepository) + , ITrackPushRecordsRepository trackPushRecordsRepository, + IHttpClientProxy requestCurrentUserService) { _orderRepository = orderRepository; _capPublisher = capPublisher; _trackPushRecordsRepository = trackPushRecordsRepository; + _requestCurrentUserService = requestCurrentUserService; } /// @@ -50,6 +54,15 @@ public class TrackPushService : ApplicationService throw new BusinessException(message: "一个订单都不存在"); } + var userInfo = await _requestCurrentUserService.Service.GetCurrentUserBasicInfoAsync(); + if (userInfo.Code != "200" || userInfo.Data is null) + { + //TODO: log || ex + throw new BusinessException(message: $"调用用户中心,获取用户信息失败:{userInfo?.Msg}"); + } + + var name = userInfo.Data.UserName; + foreach (var group in orders.GroupBy(x => new { x.SubSystemId, x.CustomId })) { var trackPushEvent = new TrackPushEvent @@ -59,7 +72,7 @@ public class TrackPushService : ApplicationService CustomId = group.Key.CustomId, OrderIds = group.Select(x => x.Id).ToArray(), TrackCode = input.TrackCode, - OperationMan = CurrentUserRequest.CurrentUser.Name, + OperationMan = name, }; await _capPublisher.PublishAsync(GlobalConst.TrackManualPushSubscribe, trackPushEvent); diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs index 6c5d81ba..f3d63ca2 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs @@ -7,6 +7,7 @@ using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; using SJZY.Track.Domain.Consts; using SJZY.Track.Domain.Queries; using SJZY.UserCenter.HttpApi.Services; +using Volo.Abp.Http.Client.DynamicProxying; namespace SJZY.Track.Application.Services.ProvideServices; @@ -20,14 +21,17 @@ public partial class TrackService : ApplicationService, ITrackService private readonly IOrderRepository _orderRepository; private readonly IProvideQueries _provideQueries; private readonly ICapPublisher _capPublisher; + private readonly IHttpClientProxy _requestCurrentUserService; public TrackService(IOrderRepository orderRepository, IProvideQueries provideQueries, ICapPublisher capPublisher, - ITrackDetailsRepository trackDetailsRepository) + ITrackDetailsRepository trackDetailsRepository, + IHttpClientProxy requestCurrentUserService) { _orderRepository = orderRepository; _provideQueries = provideQueries; _provideQueries = provideQueries; _capPublisher = capPublisher; + _requestCurrentUserService = requestCurrentUserService; _trackDetailsRepository = trackDetailsRepository; } @@ -50,6 +54,15 @@ public partial class TrackService : ApplicationService, ITrackService throw new BusinessException(message: $"订单:{input.OrderNo}不存在"); } + var userInfo = await _requestCurrentUserService.Service.GetCurrentUserBasicInfoAsync(); + if (userInfo.Code != "200" || userInfo.Data is null) + { + //TODO: log || ex + throw new BusinessException(message: $"调用用户中心,获取用户信息失败:{userInfo?.Msg}"); + } + + var name = userInfo.Data.UserName; + // 新增/更新轨迹 var @event = ObjectMapper.Map(input); @event.SubSystemId = order.SubSystemId; @@ -63,7 +76,7 @@ public partial class TrackService : ApplicationService, ITrackService CustomId = order.CustomId } }; - @event.OperationMan = CurrentUserRequest.CurrentUser.Name; + @event.OperationMan = name; await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event); return new UnifyResultDto(true, true); } @@ -89,6 +102,15 @@ public partial class TrackService : ApplicationService, ITrackService x.Id, x.OrderNo, x.SubSystemId, x.CustomId }); + var userInfo = await _requestCurrentUserService.Service.GetCurrentUserBasicInfoAsync(); + if (userInfo.Code != "200" || userInfo.Data is null) + { + //TODO: log || ex + throw new BusinessException(message: $"调用用户中心,获取用户信息失败:{userInfo?.Msg}"); + } + + var name = userInfo.Data.UserName; + foreach (var group in orders.GroupBy(x => x.SubSystemId)) { // 新增/更新轨迹 @@ -107,7 +129,7 @@ public partial class TrackService : ApplicationService, ITrackService TrackPlace = input.TrackPlace, TrackTime = input.TrackTime!.Value, TrackTimeZone = input.TrackTimeZone!.Value, - OperationMan = CurrentUserRequest.CurrentUser.Name + OperationMan = name }; await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event); } @@ -143,13 +165,22 @@ public partial class TrackService : ApplicationService, ITrackService throw new BusinessException(message: "没有一个轨迹代码是可删的"); } + var userInfo = await _requestCurrentUserService.Service.GetCurrentUserBasicInfoAsync(); + if (userInfo.Code != "200" || userInfo.Data is null) + { + //TODO: log || ex + throw new BusinessException(message: $"调用用户中心,获取用户信息失败:{userInfo?.Msg}"); + } + + var name = userInfo.Data.UserName; + // 删除轨迹 var @event = new TrackDeleteEvent { OrderIds = new[] { order.Id }, TrackCodes = codes.Select(x => x.TrackCode).ToList(), SubSystemId = order.SubSystemId, - OperationMan = CurrentUserRequest.CurrentUser.Name + OperationMan = name }; await _capPublisher.PublishAsync(GlobalConst.TrackDeleteSubscribe, @event); @@ -182,6 +213,15 @@ public partial class TrackService : ApplicationService, ITrackService throw new BusinessException(message: "没有一个轨迹代码是可删的"); } + var userInfo = await _requestCurrentUserService.Service.GetCurrentUserBasicInfoAsync(); + if (userInfo.Code != "200" || userInfo.Data is null) + { + //TODO: log || ex + throw new BusinessException(message: $"调用用户中心,获取用户信息失败:{userInfo?.Msg}"); + } + + var name = userInfo.Data.UserName; + // 删除轨迹 foreach (var group in codes.GroupBy(x => x.OrderId)) { @@ -190,7 +230,7 @@ public partial class TrackService : ApplicationService, ITrackService OrderIds = group.Select(x => x.OrderId).ToArray(), TrackCodes = input.TrackCodes, SubSystemId = orders.First(x => x.Id == group.Key).SubSystemId, - OperationMan = CurrentUserRequest.CurrentUser.Name + OperationMan = name }; await _capPublisher.PublishAsync(GlobalConst.TrackDeleteSubscribe, @event); }