From 46e927df476f938439759d67a86a6d29094f59b1 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Thu, 23 Mar 2023 13:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A7=E7=89=A9=E7=8A=B6=E6=80=81=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingGoodsStatusConfigService.cs | 36 +++++++++++-------- .../IBookingGoodsStatusConfigService.cs | 1 + 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Myshipping.Application/Service/BookingGoodsStatusConfig/BookingGoodsStatusConfigService.cs b/Myshipping.Application/Service/BookingGoodsStatusConfig/BookingGoodsStatusConfigService.cs index 152ae030..245cff43 100644 --- a/Myshipping.Application/Service/BookingGoodsStatusConfig/BookingGoodsStatusConfigService.cs +++ b/Myshipping.Application/Service/BookingGoodsStatusConfig/BookingGoodsStatusConfigService.cs @@ -52,20 +52,7 @@ namespace Myshipping.Application public async Task Page([FromQuery] QueryBookingGoodsStatusConfigInput input) { //初次使用没有数据,进行初始化 - if (_rep.AsQueryable().Count(x => x.CreatedUserId == UserManager.UserId) == 0) - { - var dicData = await _cache.GetAllDictData(); - var listGoodsStatus = dicData.Where(x => x.TypeCode == "booking_goods_status").ToList(); - listGoodsStatus.ForEach(async itm => - { - await _rep.InsertAsync(new BookingGoodsStatusConfig() - { - StatusName = itm.Value, - Sort = itm.Sort, - SystemCode = itm.Code - }); - }); - } + InitGoodsStatusConfig(); var entities = await _rep.AsQueryable() .Where(m => m.CreatedUserId == UserManager.UserId) @@ -136,5 +123,26 @@ namespace Myshipping.Application return await _rep.FirstOrDefaultAsync(u => u.Id == id); } + /// + /// 初始化当前用户的货物状态配置 + /// + [NonAction] + public async void InitGoodsStatusConfig() + { + if (_rep.AsQueryable().Count(x => x.CreatedUserId == UserManager.UserId) == 0) + { + var dicData = await _cache.GetAllDictData(); + var listGoodsStatus = dicData.Where(x => x.TypeCode == "booking_goods_status").ToList(); + listGoodsStatus.ForEach(async itm => + { + await _rep.InsertAsync(new BookingGoodsStatusConfig() + { + StatusName = itm.Value, + Sort = itm.Sort, + SystemCode = itm.Code + }); + }); + } + } } } diff --git a/Myshipping.Application/Service/BookingGoodsStatusConfig/IBookingGoodsStatusConfigService.cs b/Myshipping.Application/Service/BookingGoodsStatusConfig/IBookingGoodsStatusConfigService.cs index 5f0e35f0..409b9f62 100644 --- a/Myshipping.Application/Service/BookingGoodsStatusConfig/IBookingGoodsStatusConfigService.cs +++ b/Myshipping.Application/Service/BookingGoodsStatusConfig/IBookingGoodsStatusConfigService.cs @@ -11,5 +11,6 @@ namespace Myshipping.Application Task Save(SaveBookingGoodsStatusConfigInput input); Task Delete(long id); Task Get(long id); + void InitGoodsStatusConfig(); } } \ No newline at end of file