Parcourir la source

😁调整sqlsugar二级缓存及升级依赖

zuohuaijun il y a 2 ans
Parent
commit
6e2d8c86e5

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

@@ -36,7 +36,7 @@
     <PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.1.9" />
     <PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.1.9" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="2.33.0" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="2.33.0" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="2.20.0" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="2.20.0" />
-    <PackageReference Include="SqlSugarCore" Version="5.1.4.108" />
+    <PackageReference Include="SqlSugarCore" Version="5.1.4.109" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.5" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.5" />
     <PackageReference Include="UAParser" Version="3.1.47" />
     <PackageReference Include="UAParser" Version="3.1.47" />
     <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
     <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />

+ 42 - 42
Admin.NET/Admin.NET.Core/Cache/SqlSugarCache.cs

@@ -14,46 +14,46 @@ namespace Admin.NET.Core;
 /// </summary>
 /// </summary>
 public class SqlSugarCache : ICacheService
 public class SqlSugarCache : ICacheService
 {
 {
-	/// <summary>
-	/// 系统缓存服务
-	/// </summary>
-	private static readonly SysCacheService _cache = App.GetService<SysCacheService>();
-
-	public void Add<V>(string key, V value)
-	{
-		_cache.Set($"{CacheConst.SqlSugar}{key}", value);
-	}
-
-	public void Add<V>(string key, V value, int cacheDurationInSeconds)
-	{
-		_cache.Set($"{CacheConst.SqlSugar}{key}", value, TimeSpan.FromSeconds(cacheDurationInSeconds));
-	}
-
-	public bool ContainsKey<V>(string key)
-	{
-		return _cache.ExistKey($"{CacheConst.SqlSugar}{key}");
-	}
-
-	public V Get<V>(string key)
-	{
-		return _cache.Get<V>($"{CacheConst.SqlSugar}{key}");
-	}
-
-	public IEnumerable<string> GetAllKey<V>()
-	{
-		return _cache.GetKeysByPrefixKey(CacheConst.SqlSugar);
-	}
-
-	public V GetOrCreate<V>(string key, Func<V> create, int cacheDurationInSeconds = int.MaxValue)
-	{
-		return _cache.GetOrAdd<V>($"{CacheConst.SqlSugar}{key}", (cacheKey) =>
-		{
-			return create();
-		}, cacheDurationInSeconds);
-	}
-
-	public void Remove<V>(string key)
-	{
-		_cache.Remove($"{CacheConst.SqlSugar}{key}");
-	}
+    /// <summary>
+    /// 系统缓存服务
+    /// </summary>
+    private static readonly SysCacheService _cache = App.GetService<SysCacheService>();
+
+    public void Add<V>(string key, V value)
+    {
+        _cache.Set($"{CacheConst.SqlSugar}{key}", value);
+    }
+
+    public void Add<V>(string key, V value, int cacheDurationInSeconds)
+    {
+        _cache.Set($"{CacheConst.SqlSugar}{key}", value, TimeSpan.FromSeconds(cacheDurationInSeconds));
+    }
+
+    public bool ContainsKey<V>(string key)
+    {
+        return _cache.ExistKey($"{CacheConst.SqlSugar}{key}");
+    }
+
+    public V Get<V>(string key)
+    {
+        return _cache.Get<V>($"{CacheConst.SqlSugar}{key}");
+    }
+
+    public IEnumerable<string> GetAllKey<V>()
+    {
+        return _cache.GetKeysByPrefixKey(CacheConst.SqlSugar);
+    }
+
+    public V GetOrCreate<V>(string key, Func<V> create, int cacheDurationInSeconds = int.MaxValue)
+    {
+        return _cache.GetOrAdd<V>($"{CacheConst.SqlSugar}{key}", (cacheKey) =>
+        {
+            return create();
+        }, cacheDurationInSeconds);
+    }
+
+    public void Remove<V>(string key)
+    {
+        _cache.Remove($"{CacheConst.SqlSugar}{key}");
+    }
 }
 }

+ 4 - 4
Admin.NET/Admin.NET.Core/Const/CacheConst.cs

@@ -67,8 +67,8 @@ public class CacheConst
     /// </summary>
     /// </summary>
     public const string KeyAll = "sys_keys";
     public const string KeyAll = "sys_keys";
 
 
-	/// <summary>
-	/// SqlSugar二级缓存
-	/// </summary>
-	public const string SqlSugar = "sqlSugar:";
+    /// <summary>
+    /// SqlSugar二级缓存
+    /// </summary>
+    public const string SqlSugar = "sys_sqlSugar:";
 }
 }

+ 4 - 3
Admin.NET/Admin.NET.Core/Service/Region/SysRegionService.cs

@@ -20,6 +20,9 @@ public class SysRegionService : IDynamicApiController, ITransient
 {
 {
     private readonly SqlSugarRepository<SysRegion> _sysRegionRep;
     private readonly SqlSugarRepository<SysRegion> _sysRegionRep;
 
 
+    // Url地址-国家统计局行政区域2023年
+    private readonly string _url = "http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2023/index.html";
+
     public SysRegionService(SqlSugarRepository<SysRegion> sysRegionRep)
     public SysRegionService(SqlSugarRepository<SysRegion> sysRegionRep)
     {
     {
         _sysRegionRep = sysRegionRep;
         _sysRegionRep = sysRegionRep;
@@ -123,10 +126,8 @@ public class SysRegionService : IDynamicApiController, ITransient
     {
     {
         await _sysRegionRep.DeleteAsync(u => u.Id > 0);
         await _sysRegionRep.DeleteAsync(u => u.Id > 0);
 
 
-        // 国家统计局行政区域2023年
-        var url = "http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2023/index.html";
         var context = BrowsingContext.New(Configuration.Default.WithDefaultLoader());
         var context = BrowsingContext.New(Configuration.Default.WithDefaultLoader());
-        var dom = await context.OpenAsync(url);
+        var dom = await context.OpenAsync(_url);
 
 
         // 省级
         // 省级
         var itemList = dom.QuerySelectorAll("table.provincetable tr.provincetr td a");
         var itemList = dom.QuerySelectorAll("table.provincetable tr.provincetr td a");