From 32288af3e5f12bc48d8360114c872fde5d9ff4a8 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期五, 08 八月 2025 09:09:08 +0800 Subject: [PATCH] pref:优化 --- FlexJobApi.Core/Utils/DbUtils/DbUtils.cs | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/FlexJobApi.Core/Utils/DbUtils/DbUtils.cs b/FlexJobApi.Core/Utils/DbUtils/DbUtils.cs index 03c260d..cf2c06d 100644 --- a/FlexJobApi.Core/Utils/DbUtils/DbUtils.cs +++ b/FlexJobApi.Core/Utils/DbUtils/DbUtils.cs @@ -305,12 +305,14 @@ /// <typeparam name="TEntity"></typeparam> /// <typeparam name="TRequest"></typeparam> /// <param name="request"></param> + /// <param name="query"></param> /// <param name="checkExist"></param> /// <param name="update"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public static async Task<Guid> SaveData<TEntity, TRequest>( this TRequest request, + Func<IQueryable<TEntity>, IQueryable<TEntity>> query = null, Expression<Func<TEntity, bool>> checkExist = null, Action<TEntity> update = null, CancellationToken cancellationToken = default) @@ -324,7 +326,9 @@ throw Oops.Oh(EnumErrorCodeType.s405, $"璇summary ?? "淇℃伅"}"); if (request.Id.HasValue) { - var entity = await rep.AsQueryable().FirstOrDefaultAsync(it => it.Id == request.Id, cancellationToken); + var q = rep.AsQueryable(); + if (query != null) q = query(q); + var entity = await q.FirstOrDefaultAsync(it => it.Id == request.Id, cancellationToken); if (entity == null) throw Oops.Oh(EnumErrorCodeType.s404, $"璇summary ?? "淇℃伅"}"); if (update != null) update(entity); else request.Adapt(entity); @@ -451,10 +455,17 @@ } // 璧嬪�肩敤鎴蜂俊鎭疘d - prop = entity.Property(nameof(CommonEntity.CreatedUserInfoId)); + prop = entity.Property(nameof(CommonEntity.CreatedUserId)); if (prop != null && prop.CurrentValue == null) { - prop.CurrentValue = logier?.UserInfoId; + prop.CurrentValue = logier?.Id; + } + + // 璧嬪�间紒涓欼d + prop = entity.Property(nameof(CommonEntity.CreatedEnterpriseId)); + if (prop != null && prop.CurrentValue == null) + { + prop.CurrentValue = logier?.EnterpriseId; } // 璧嬪�艰窡韪狪d @@ -474,10 +485,10 @@ } // 璧嬪�肩敤鎴蜂俊鎭疘d - prop = entity.Property(nameof(CommonEntity.UpdatedUserInfoId)); + prop = entity.Property(nameof(CommonEntity.UpdatedUserId)); if (prop != null) { - prop.CurrentValue = logier?.UserInfoId; + prop.CurrentValue = logier?.Id; } // 璧嬪�艰窡韪狪d @@ -523,7 +534,8 @@ : EnumDbAuditOperate.Deleted, TraceId = App.GetTraceId(), CreatedTime = DateTime.Now, - CreatedUserInfoId = logier?.UserInfoId, + CreatedUserId = logier?.Id, + CreatedEnterpriseId = logier?.EnterpriseId }); } } -- Gitblit v1.9.1