From 7d64d742e52809237473e13e18faec2c23dfe3c7 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期四, 07 八月 2025 17:13:53 +0800 Subject: [PATCH] feat:企业开发 --- FlexJobApi.Core/Models/User/Enterprises/Commands/SaveEnterpriseCommand.cs | 12 +++--- FlexJobApi.Core/Models/User/Enterprises/Queries/GetEnterpriseQuery.cs | 12 +++--- FlexJobApi.Core/Models/Main/Tasks/Repositories/TaskInfoRepository.cs | 14 +++---- FlexJobApi.Application/Tasks/Commands/TaskInfoCommandHandler.cs | 2 FlexJobApi.Application/Tasks/Queries/TaskInfoQueryHandler.cs | 11 ++++- FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs | 23 ++++++++--- 6 files changed, 44 insertions(+), 30 deletions(-) diff --git a/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs b/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs index 6e121f5..3228f39 100644 --- a/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs +++ b/FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs @@ -50,6 +50,10 @@ if (category == null) throw Oops.Oh(EnumErrorCodeType.s404, "鏁版嵁瀛楀吀绫诲埆"); request.CategoryId = category.Id; if (!request.Code.StartsWith($"{category.Code}-")) throw Oops.Oh(EnumErrorCodeType.s400, "缂栧彿寮�澶撮渶瑕佸寘鍚被鍒紪鍙�-"); + var parent = request.ParentId.HasValue + ? await rep.AsQueryable().AsNoTracking() + .FirstOrDefaultAsync(it => it.Id == request.ParentId) + : null; return await request.SaveData<DictionaryData, SaveDictionaryDataCommand>( null, it => @@ -62,10 +66,15 @@ if (request.Id.HasValue) { if (entity.Code != request.Code) throw Oops.Oh(EnumErrorCodeType.s400, "缂栧彿涓嶅彲淇敼"); - DbUtils.UpdateTreeDataChildrenPath<DictionaryData>( - $"{entity.Path}/{entity.Code}/", - $"{entity.Path}/{request.Code}/", - cancellationToken).Wait(); + if (entity.ParentId != request.ParentId) throw Oops.Oh(EnumErrorCodeType.s400, "涓婄骇Id涓嶅彲淇敼"); + //DbUtils.UpdateTreeDataChildrenPath<DictionaryData>( + // $"{entity.Path}/{entity.Code}/", + // $"{entity.Path}/{request.Code}/", + // cancellationToken).Wait(); + } + else + { + entity.Deep = request.ParentId == null ? 1 : parent.Deep + 1; } request.Adapt(entity); }, @@ -114,7 +123,8 @@ /// <param name="entities"></param> /// <param name="all"></param> /// <param name="areas"></param> - private void LoopSyncHumanResourcesAreaDictionaryData(Guid categoryId, List<DictionaryData> entities, List<BaseArea> all, List<BaseArea> areas) + /// <param name="deep"></param> + private void LoopSyncHumanResourcesAreaDictionaryData(Guid categoryId, List<DictionaryData> entities, List<BaseArea> all, List<BaseArea> areas, int deep = 1) { if (areas.IsNotNull()) { @@ -149,11 +159,12 @@ entity.Field3 = area.SimpleSpelling; entity.Field4 = area.Layer.ToString(); entity.Field5 = area.Description; + entity.Deep = deep; entity.Sort = area.Sort ?? 0; entities.Add(entity); var children = all.Where(it => it.ParentId == area.AreaCode).ToList(); - LoopSyncHumanResourcesAreaDictionaryData(categoryId, entities, all, children); + LoopSyncHumanResourcesAreaDictionaryData(categoryId, entities, all, children, deep + 1); } } } diff --git a/FlexJobApi.Application/Tasks/Commands/TaskInfoCommandHandler.cs b/FlexJobApi.Application/Tasks/Commands/TaskInfoCommandHandler.cs index 3b9c630..a71b3b1 100644 --- a/FlexJobApi.Application/Tasks/Commands/TaskInfoCommandHandler.cs +++ b/FlexJobApi.Application/Tasks/Commands/TaskInfoCommandHandler.cs @@ -34,7 +34,7 @@ { var logier = JwtUtils.GetCurrentLogier(); return await request.SaveData<TaskInfo, SaveTaskInfoCommand>( - q => TaskInfoQueryable.GetQueryable( + q => TaskInfoRepository.GetQueryable( rep, q => q .Include(it => it.Benefits) diff --git a/FlexJobApi.Application/Tasks/Queries/TaskInfoQueryHandler.cs b/FlexJobApi.Application/Tasks/Queries/TaskInfoQueryHandler.cs index f3fc70b..7b635b7 100644 --- a/FlexJobApi.Application/Tasks/Queries/TaskInfoQueryHandler.cs +++ b/FlexJobApi.Application/Tasks/Queries/TaskInfoQueryHandler.cs @@ -32,7 +32,8 @@ /// <returns></returns> public Task<GetTaskInfoQueryResult> Handle(GetTaskInfoQuery request, CancellationToken cancellationToken) { - return TaskInfoQueryable.GetQueryable(rep, q => q.Where(it => it.Id == request.Id)) + return TaskInfoRepository.GetQueryable(rep) + .Where(it => it.Id == request.Id) .ProjectToType<GetTaskInfoQueryResult>() .FirstOrDefaultAsync(cancellationToken); } @@ -45,8 +46,12 @@ /// <returns></returns> public Task<PagedListQueryResult<GetTaskInfosQueryResultItem>> Handle(GetTaskInfosQuery request, CancellationToken cancellationToken) { - //return request.PageModel.GetPagedListAsync<TaskInfo, >() - throw new Exception(); + return request.PageModel.GetPagedListAsync<TaskInfo, GetTaskInfosQueryResultItem>( + q => + { + q = TaskInfoRepository.GetQueryable(rep); + return q; + }); } } } diff --git a/FlexJobApi.Core/Models/Main/Tasks/Queryables/TaskInfoQueryable.cs b/FlexJobApi.Core/Models/Main/Tasks/Repositories/TaskInfoRepository.cs similarity index 60% rename from FlexJobApi.Core/Models/Main/Tasks/Queryables/TaskInfoQueryable.cs rename to FlexJobApi.Core/Models/Main/Tasks/Repositories/TaskInfoRepository.cs index 0275097..4fbc5a6 100644 --- a/FlexJobApi.Core/Models/Main/Tasks/Queryables/TaskInfoQueryable.cs +++ b/FlexJobApi.Core/Models/Main/Tasks/Repositories/TaskInfoRepository.cs @@ -10,9 +10,9 @@ namespace FlexJobApi.Core { /// <summary> - /// 浠诲姟鏌ヨ + /// 浠诲姟浠撳簱 /// </summary> - public static class TaskInfoQueryable + public static class TaskInfoRepository { /// <summary> /// 鑾峰彇浠诲姟鏌ヨ @@ -21,14 +21,12 @@ /// <param name="query"></param> /// <param name="logier"></param> /// <returns></returns> - public static IQueryable<TaskInfo> GetQueryable(this IRepository<TaskInfo> rep, Func<IQueryable<TaskInfo>, IQueryable<TaskInfo>> query, CurrentLogier logier = null) + public static IQueryable<TaskInfo> GetQueryable(this IRepository<TaskInfo> rep, CurrentLogier logier = null) { logier = logier ?? JwtUtils.GetCurrentLogier(); - IQueryable<TaskInfo> q = rep.AsQueryable().AsNoTracking() - .OrderBy(it => it.BeginTime); - if (query != null) q = query(q); - return q - .Where(it => it.EnterpriseId == logier.EnterpriseId); + return q = rep.AsQueryable().AsNoTracking() + .OrderBy(it => it.BeginTime) + .Where(it => it.EnterpriseId == logier.EnterpriseId); } } } diff --git a/FlexJobApi.Core/Models/User/Enterprises/Commands/SaveEnterpriseCommand.cs b/FlexJobApi.Core/Models/User/Enterprises/Commands/SaveEnterpriseCommand.cs index acf59f0..d3055d9 100644 --- a/FlexJobApi.Core/Models/User/Enterprises/Commands/SaveEnterpriseCommand.cs +++ b/FlexJobApi.Core/Models/User/Enterprises/Commands/SaveEnterpriseCommand.cs @@ -53,19 +53,19 @@ }; /// <summary> - /// 鎵�鍦ㄧ渷浠絀d + /// 鎵�鍦ㄧ渷浠界紪鍙� /// </summary> - public Guid? ProvinceId { get; set; } + public string ProvinceCode { get; set; } /// <summary> - /// 鎵�鍦ㄥ煄甯侷d + /// 鎵�鍦ㄥ煄甯傜紪鍙� /// </summary> - public Guid? CityId { get; set; } + public string CityCode { get; set; } /// <summary> - /// 鎵�灞炶涓欼d + /// 鎵�灞炶涓氱紪鍙� /// </summary> - public Guid? IndustryTypeId { get; set; } + public Guid? IndustryTypeCode { get; set; } /// <summary> /// 涓昏惀涓氬姟 diff --git a/FlexJobApi.Core/Models/User/Enterprises/Queries/GetEnterpriseQuery.cs b/FlexJobApi.Core/Models/User/Enterprises/Queries/GetEnterpriseQuery.cs index c0f1cc8..5ec7e7e 100644 --- a/FlexJobApi.Core/Models/User/Enterprises/Queries/GetEnterpriseQuery.cs +++ b/FlexJobApi.Core/Models/User/Enterprises/Queries/GetEnterpriseQuery.cs @@ -62,9 +62,9 @@ public SaveEnterpriseCommandAuth EnterpriseAuth { get; set; } /// <summary> - /// 鎵�鍦ㄧ渷浠絀d + /// 鎵�鍦ㄧ渷浠界紪鍙� /// </summary> - public Guid? ProvinceId { get; set; } + public string ProvinceCode { get; set; } /// <summary> /// 鎵�鍦ㄧ渷浠� @@ -72,9 +72,9 @@ public string ProvinceContent { get; set; } /// <summary> - /// 鎵�鍦ㄥ煄甯侷d + /// 鎵�鍦ㄥ煄甯傜紪鍙� /// </summary> - public Guid? CityId { get; set; } + public string CityCode { get; set; } /// <summary> /// 鎵�鍦ㄥ煄甯� @@ -82,9 +82,9 @@ public string CityContent { get; set; } /// <summary> - /// 鎵�灞炶涓欼d + /// 鎵�灞炶涓氱紪鍙� /// </summary> - public Guid? IndustryTypeId { get; set; } + public string IndustryTypeCode { get; set; } /// <summary> /// 鎵�灞炶涓� -- Gitblit v1.9.1