Эх сурвалжийг харах

😎1、调整基类服务更新方法返回 2、调整行政区域接口服务 3、升级Furion v4.9.1.56

zuohuaijun 2 жил өмнө
parent
commit
3dde656d20

+ 3 - 3
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -21,9 +21,9 @@
     <PackageReference Include="AspNet.Security.OAuth.Gitee" Version="6.0.15" />
     <PackageReference Include="AspNet.Security.OAuth.Weixin" Version="6.0.15" />
     <PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
-    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.55" />
-    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.55" />
-    <PackageReference Include="Furion.Pure" Version="4.9.1.55" />
+    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.56" />
+    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.56" />
+    <PackageReference Include="Furion.Pure" Version="4.9.1.56" />
     <PackageReference Include="IPTools.China" Version="1.6.0" />
     <PackageReference Include="Lazy.Captcha.Core" Version="2.0.6" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.7.5.1" />

+ 2 - 2
Admin.NET/Admin.NET.Core/Service/BaseService.cs

@@ -69,9 +69,9 @@ public class BaseService<TEntity> : IDynamicApiController where TEntity : class,
     /// <returns></returns>
     [ApiDescriptionSettings(Name = "Update"), HttpPost]
     [DisplayName("更新")]
-    public virtual async Task<bool> Update(TEntity entity)
+    public virtual async Task<int> Update(TEntity entity)
     {
-        return await _rep.UpdateAsync(entity);
+        return await _rep.AsUpdateable(entity).IgnoreColumns(true).ExecuteCommandAsync();
     }
 
     /// <summary>

+ 1 - 0
Admin.NET/Admin.NET.Core/Service/Job/SysJobService.cs

@@ -354,6 +354,7 @@ public class SysJobService : IDynamicApiController, ITransient
         return await _sysJobTriggerRecordRep.AsQueryable()
             .WhereIF(!string.IsNullOrWhiteSpace(input.JobId), u => u.JobId.Contains(input.JobId))
             .WhereIF(!string.IsNullOrWhiteSpace(input.TriggerId), u => u.TriggerId.Contains(input.TriggerId))
+            .OrderByDescending(u => u.Id)
             .ToPagedListAsync(input.Page, input.PageSize);
     }
 }

+ 28 - 2
Admin.NET/Admin.NET.Core/Service/Region/SysRegionService.cs

@@ -58,6 +58,19 @@ public class SysRegionService : IDynamicApiController, ITransient
     [DisplayName("增加行政区域")]
     public async Task<long> AddRegion(AddRegionInput input)
     {
+        input.Code = input.Code.Trim();
+        if (input.Code.Length != 12 && input.Code.Length != 9 && input.Code.Length != 6)
+            throw Oops.Oh("行政区代码只能为6、9或12位");
+
+        if (input.Pid != 0)
+        {
+            var pRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Pid);
+            pRegion ??= await _sysRegionRep.GetFirstAsync(u => u.Code == input.Pid.ToString());
+            if (pRegion == null)
+                throw Oops.Oh(ErrorCodeEnum.D2000);
+            input.Pid = pRegion.Id;
+        }
+
         var isExist = await _sysRegionRep.IsAnyAsync(u => u.Name == input.Name && u.Code == input.Code);
         if (isExist)
             throw Oops.Oh(ErrorCodeEnum.R2002);
@@ -76,11 +89,24 @@ public class SysRegionService : IDynamicApiController, ITransient
     [DisplayName("更新行政区域")]
     public async Task UpdateRegion(UpdateRegionInput input)
     {
-        if (input.Pid != 0)
+        input.Code = input.Code.Trim();
+        if (input.Code.Length != 12 && input.Code.Length != 9 && input.Code.Length != 6)
+            throw Oops.Oh("行政区代码只能为6、9或12位");
+
+        if (input.Pid != input.Pid && input.Pid != 0)
         {
             var pRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Pid);
-            _ = pRegion ?? throw Oops.Oh(ErrorCodeEnum.D2000);
+            pRegion ??= await _sysRegionRep.GetFirstAsync(u => u.Code == input.Pid.ToString());
+            if (pRegion == null)
+                throw Oops.Oh(ErrorCodeEnum.D2000);
+
+            input.Pid = pRegion.Id;
+            var regionTreeList = await _sysRegionRep.AsQueryable().ToChildListAsync(u => u.Pid, input.Id, true);
+            var childIdList = regionTreeList.Select(u => u.Id).ToList();
+            if (childIdList.Contains(input.Pid))
+                throw Oops.Oh("父节点不能为自己的子节点");
         }
+
         if (input.Id == input.Pid)
             throw Oops.Oh(ErrorCodeEnum.R2001);