From 59e73ad4283491cd407854874879e0ddc8dafaba Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期四, 07 八月 2025 14:08:20 +0800 Subject: [PATCH] feat:地区字典 --- FlexJobApi.EntityFramework.Core/DbContexts/HumanResourcesDbContext.cs | 28 +++++++ FlexJobApi.Core/DbContextLocators/LogDbContextLocator.cs | 2 FlexJobApi.Core/Entities/HumanResources/Area.cs | 60 +++++++++++++++ FlexJobApi.Core/DbContextLocators/HumanResourcesDbContextLocator.cs | 16 ++++ FlexJobApi.Core/FlexJobApi.Core.xml | 62 +++++++++++++++ FlexJobApi.Core/Models/Main/Dictionaries/Commands/SyncHumanResourcesAreaDictionaryDataCommand.cs | 17 ++++ FlexJobApi.EntityFramework.Core/Startup.cs | 1 FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs | 13 +++ FlexJobApi.Web.Entry/appsettings.json | 3 9 files changed, 198 insertions(+), 4 deletions(-) diff --git a/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs b/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs index 57f7d0c..7df5b54 100644 --- a/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs +++ b/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs @@ -21,7 +21,8 @@ IRepository<DictionaryCategory> repDictionaryCategory ) : IRequestHandler<SaveDictionaryDataCommand, Guid>, - IRequestHandler<SetDictionaryDataIsDisabledCommand, int> + IRequestHandler<SetDictionaryDataIsDisabledCommand, int>, + IRequestHandler<SyncHumanResourcesAreaDictionaryDataCommand, int> { private readonly IRepository<DictionaryData> rep = rep; @@ -78,5 +79,15 @@ { return request.SetIsDisabled<DictionaryData>(cancellationToken: cancellationToken); } + + public async Task<int> Handle(SyncHumanResourcesAreaDictionaryDataCommand request, CancellationToken cancellationToken) + { + var rep = Db.GetRepository<BaseArea, HumanResourcesDbContextLocator>(); + var areas = await rep.AsQueryable().AsNoTracking() + .Take(10) + .ToListAsync(); + Console.WriteLine(); + return 1; + } } } diff --git a/FlexJobApi.Core/DbContextLocators/HumanResourcesDbContextLocator.cs b/FlexJobApi.Core/DbContextLocators/HumanResourcesDbContextLocator.cs new file mode 100644 index 0000000..68b6cad --- /dev/null +++ b/FlexJobApi.Core/DbContextLocators/HumanResourcesDbContextLocator.cs @@ -0,0 +1,16 @@ +锘縰sing Furion.DatabaseAccessor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlexJobApi.Core +{ + /// <summary> + /// 浜哄姏璧勬簮鏁版嵁搴撲笂涓嬫枃瀹氫綅鍣� + /// </summary> + public class HumanResourcesDbContextLocator : IDbContextLocator + { + } +} diff --git a/FlexJobApi.Core/DbContextLocators/LogDbContextLocator.cs b/FlexJobApi.Core/DbContextLocators/LogDbContextLocator.cs index ce5a64e..546263f 100644 --- a/FlexJobApi.Core/DbContextLocators/LogDbContextLocator.cs +++ b/FlexJobApi.Core/DbContextLocators/LogDbContextLocator.cs @@ -8,7 +8,7 @@ namespace FlexJobApi.Core { /// <summary> - /// 鏃ュ織鏁版嵁搴� + /// 鏃ュ織鏁版嵁搴撳畾浣嶅櫒 /// </summary> public sealed class LogDbContextLocator : IDbContextLocator { diff --git a/FlexJobApi.Core/Entities/HumanResources/Area.cs b/FlexJobApi.Core/Entities/HumanResources/Area.cs new file mode 100644 index 0000000..ed7b1ac --- /dev/null +++ b/FlexJobApi.Core/Entities/HumanResources/Area.cs @@ -0,0 +1,60 @@ +锘縰sing Furion.DatabaseAccessor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlexJobApi.Core +{ + /// <summary> + /// 鍦板尯 + /// </summary> + public class BaseArea : EntityBase<Guid, HumanResourcesDbContextLocator> + { + /// <summary> + /// 涓婄骇鍦板尯缂栧彿 + /// </summary> + public int? ParentId { get; set; } + + /// <summary> + /// 鍦板尯缂栧彿 + /// </summary> + public int AreaCode { get; set; } + + /// <summary> + /// 鍦板尯鍚嶇О + /// </summary> + public string AreaName { get; set; } + + /// <summary> + /// 蹇嵎鏌ヨ + /// </summary> + public string QuickQuery { get; set; } + + /// <summary> + /// 鎻忚堪 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// 灞傜骇 + /// </summary> + public int Layer { get; set; } + + /// <summary> + /// 鎺掑簭 + /// </summary> + public int? Sort { get; set; } + + /// <summary> + /// 绠�鎷� + /// </summary> + public string SimpleSpelling { get; set; } + + /// <summary> + /// 鏄惁鍚敤 + /// </summary> + public bool IsEnable { get; set; } + } +} diff --git a/FlexJobApi.Core/FlexJobApi.Core.xml b/FlexJobApi.Core/FlexJobApi.Core.xml index 1bb9277..e6920f5 100644 --- a/FlexJobApi.Core/FlexJobApi.Core.xml +++ b/FlexJobApi.Core/FlexJobApi.Core.xml @@ -4,9 +4,14 @@ <name>FlexJobApi.Core</name> </assembly> <members> + <member name="T:FlexJobApi.Core.HumanResourcesDbContextLocator"> + <summary> + 浜哄姏璧勬簮鏁版嵁搴撲笂涓嬫枃瀹氫綅鍣� + </summary> + </member> <member name="T:FlexJobApi.Core.LogDbContextLocator"> <summary> - 鏃ュ織鏁版嵁搴� + 鏃ュ織鏁版嵁搴撳畾浣嶅櫒 </summary> </member> <member name="P:FlexJobApi.Core.CommonEntity`1.Sort"> @@ -257,6 +262,56 @@ <member name="P:FlexJobApi.Core.Resource.IsExpired"> <summary> 鏄惁宸茶繃鏈� + </summary> + </member> + <member name="T:FlexJobApi.Core.BaseArea"> + <summary> + 鍦板尯 + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.ParentId"> + <summary> + 涓婄骇鍦板尯缂栧彿 + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.AreaCode"> + <summary> + 鍦板尯缂栧彿 + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.AreaName"> + <summary> + 鍦板尯鍚嶇О + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.QuickQuery"> + <summary> + 蹇嵎鏌ヨ + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.Description"> + <summary> + 鎻忚堪 + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.Layer"> + <summary> + 灞傜骇 + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.Sort"> + <summary> + 鎺掑簭 + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.SimpleSpelling"> + <summary> + 绠�鎷� + </summary> + </member> + <member name="P:FlexJobApi.Core.BaseArea.IsEnable"> + <summary> + 鏄惁鍚敤 </summary> </member> <member name="T:FlexJobApi.Core.ConsoleLog"> @@ -2290,6 +2345,11 @@ 璁剧疆鏁版嵁瀛楀吀鏄惁绂佺敤 </summary> </member> + <member name="T:FlexJobApi.Core.SyncHumanResourcesAreaDictionaryDataCommand"> + <summary> + 鍚屾浜哄姏璧勬簮鍦板尯瀛楀吀鏁版嵁 + </summary> + </member> <member name="T:FlexJobApi.Core.GetDictionaryCategoriesQuery"> <summary> 鑾峰彇鏁版嵁瀛楀吀绫诲埆鍒嗛〉鍒楄〃鏁版嵁 diff --git a/FlexJobApi.Core/Models/Main/Dictionaries/Commands/SyncHumanResourcesAreaDictionaryDataCommand.cs b/FlexJobApi.Core/Models/Main/Dictionaries/Commands/SyncHumanResourcesAreaDictionaryDataCommand.cs new file mode 100644 index 0000000..ef453ad --- /dev/null +++ b/FlexJobApi.Core/Models/Main/Dictionaries/Commands/SyncHumanResourcesAreaDictionaryDataCommand.cs @@ -0,0 +1,17 @@ +锘縰sing MediatR; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlexJobApi.Core +{ + /// <summary> + /// 鍚屾浜哄姏璧勬簮鍦板尯瀛楀吀鏁版嵁 + /// </summary> + [Resource([EnumResourceController.Dictionary])] + public class SyncHumanResourcesAreaDictionaryDataCommand : IRequest<int> + { + } +} diff --git a/FlexJobApi.EntityFramework.Core/DbContexts/HumanResourcesDbContext.cs b/FlexJobApi.EntityFramework.Core/DbContexts/HumanResourcesDbContext.cs new file mode 100644 index 0000000..2a18b5d --- /dev/null +++ b/FlexJobApi.EntityFramework.Core/DbContexts/HumanResourcesDbContext.cs @@ -0,0 +1,28 @@ +锘縰sing FlexJobApi.Core; +using Furion.DatabaseAccessor; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlexJobApi.EntityFramework.Core +{ + /// <summary> + /// 浜哄姏璧勬簮鏁版嵁搴撲笂涓嬫枃 + /// </summary> + [AppDbContext("HumanResources", DbProvider.SqlServer)] + public class HumanResourcesDbContext : AppDbContext<HumanResourcesDbContext, HumanResourcesDbContextLocator> + { + public HumanResourcesDbContext(DbContextOptions<HumanResourcesDbContext> options) : base(options) + { + } + + /// <summary> + /// 鍦板尯 + /// </summary> + public DbSet<BaseArea> BaseArea { get; set; } + } +} diff --git a/FlexJobApi.EntityFramework.Core/Startup.cs b/FlexJobApi.EntityFramework.Core/Startup.cs index 0d901de..37a0190 100644 --- a/FlexJobApi.EntityFramework.Core/Startup.cs +++ b/FlexJobApi.EntityFramework.Core/Startup.cs @@ -13,6 +13,7 @@ { options.AddDbPool<DefaultDbContext>(); options.AddDbPool<LogDbContext, LogDbContextLocator>(); + options.AddDbPool<HumanResourcesDbContext, HumanResourcesDbContextLocator>(); }, "FlexJobApi.Database.Migrations"); } } diff --git a/FlexJobApi.Web.Entry/appsettings.json b/FlexJobApi.Web.Entry/appsettings.json index f6c5770..9c3686e 100644 --- a/FlexJobApi.Web.Entry/appsettings.json +++ b/FlexJobApi.Web.Entry/appsettings.json @@ -2,7 +2,8 @@ "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", "ConnectionStrings": { "FlexJobApi": "Server=120.26.58.240; Database=Dev_FlexJobApi; User=bole;Password=Bole1472589;Encrypt=false;", - "FlexJobApiLog": "Server=120.26.58.240; Database=Dev_FlexJobApiLog; User=bole;Password=Bole1472589;Encrypt=false;" + "FlexJobApiLog": "Server=120.26.58.240; Database=Dev_FlexJobApiLog; User=bole;Password=Bole1472589;Encrypt=false;", + "HumanResources": "Server=120.26.58.240; Database=Dev_12333; User=bole;Password=Bole1472589;Encrypt=false;" }, "Consul": { "Address": "http://localhost:8500/", -- Gitblit v1.9.1