1
0
懒得勤快 5 жил өмнө
parent
commit
6b47c7dfa0

+ 5 - 4
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -8,7 +8,6 @@ using Masuit.Tools.Media;
 using MaxMind.GeoIP2;
 using MaxMind.GeoIP2.Exceptions;
 using MaxMind.GeoIP2.Responses;
-using Microsoft.EntityFrameworkCore.Internal;
 using Microsoft.Extensions.DependencyInjection;
 using Polly;
 using System;
@@ -23,9 +22,6 @@ using System.Text;
 using System.Threading;
 using TimeZoneConverter;
 
-#if !DEBUG
-#endif
-
 namespace Masuit.MyBlogs.Core.Common
 {
     /// <summary>
@@ -145,6 +141,11 @@ namespace Masuit.MyBlogs.Core.Common
 
         public static AsnResponse GetIPAsn(this string ip)
         {
+            if (ip.IsPrivateIP())
+            {
+                return new AsnResponse();
+            }
+
             return Policy<AsnResponse>.Handle<AddressNotFoundException>().Fallback(new AsnResponse()).Execute(() => MaxmindAsnReader.Asn(ip));
         }
 

+ 1 - 1
src/Masuit.MyBlogs.Core/Controllers/BaseController.cs

@@ -7,12 +7,12 @@ using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools;
 using Masuit.Tools.Core.Net;
 using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Filters;
-using Microsoft.EntityFrameworkCore.Internal;
 using System;
 using System.Linq;
 using System.Net;

+ 1 - 1
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -24,7 +24,6 @@ using Masuit.Tools.Systems;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore.Internal;
 using Microsoft.Net.Http.Headers;
 using System;
 using System.ComponentModel.DataAnnotations;
@@ -585,6 +584,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             var post = await PostService.GetByIdAsync(id) ?? throw new NotFoundException("文章未找到");
             post.Status = Status.Deleted;
             bool b = await PostService.SaveChangesAsync(true) > 0;
+            SearchEngine.LuceneIndexer.Delete(post);
             return ResultData(null, b, b ? "删除成功!" : "删除失败!");
         }
 

+ 0 - 1
src/Masuit.MyBlogs.Core/Controllers/SystemController.cs

@@ -13,7 +13,6 @@ using Masuit.Tools.Systems;
 using Masuit.Tools.Win32;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore.Internal;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using System;

+ 0 - 1
src/Masuit.MyBlogs.Core/Extensions/Firewall/RequestInterceptMiddleware.cs

@@ -6,7 +6,6 @@ using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
 using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore.Internal;
 using Microsoft.Net.Http.Headers;
 using System;
 using System.Linq;

+ 0 - 18
src/Masuit.MyBlogs.Core/Infrastructure/DataContext.cs

@@ -1,6 +1,5 @@
 using Masuit.MyBlogs.Core.Models.Entity;
 using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Design;
 using System.Linq;
 
 namespace Masuit.MyBlogs.Core.Infrastructure
@@ -96,21 +95,4 @@ namespace Masuit.MyBlogs.Core.Infrastructure
         public virtual DbSet<PostMergeRequest> PostMergeRequests { get; set; }
         public virtual DbSet<Advertisement> Advertisements { get; set; }
     }
-
-    /// <summary>
-    /// 勿删,数据库迁移时powershell会执行该方法
-    /// </summary>
-    public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<DataContext>
-    {
-        public DataContext CreateDbContext(string[] args)
-        {
-            //IConfigurationRoot config = new ConfigurationBuilder().AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
-            var conn = "Server=127.0.0.1;Database=myblogs;Uid=root;Pwd=;Charset=utf8mb4";
-            var builder = new DbContextOptionsBuilder<DataContext>();
-            builder.UseMySql(conn);
-            //builder.UseSqlServer("Data Source=.;Initial Catalog=CoreTest;Integrated Security=True");
-
-            return new DataContext(builder.Options);
-        }
-    }
 }

+ 0 - 1
src/Masuit.MyBlogs.Core/Infrastructure/Services/PostService.cs

@@ -10,7 +10,6 @@ using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
 using Masuit.Tools.Html;
-using Microsoft.EntityFrameworkCore.Internal;
 using PanGu;
 using PanGu.HighLight;
 using System;

+ 5 - 5
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -45,21 +45,21 @@
         <PackageReference Include="IP2Region" Version="1.2.0" />
         <PackageReference Include="Karambolo.AspNetCore.Bundling.NUglify" Version="3.4.1" />
         <PackageReference Include="MaxMind.GeoIP2" Version="3.3.0" />
-        <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.9" />
-        <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.9" />
-        <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.9" />
+        <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.0" />
+        <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="5.0.0" />
+        <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="5.0.0" />
         <PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.2.1" />
         <PackageReference Include="OpenXmlPowerTools-NetStandard" Version="4.4.21" />
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.2.1" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="Polly" Version="7.2.1" />
-        <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.4" />
+        <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.1" />
         <PackageReference Include="Svg" Version="3.1.1" />
         <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.5" />
         <PackageReference Include="TimeZoneConverter" Version="3.3.0" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
-        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.69" />
+        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.0.0-rc.2.20475.6-02" />
     </ItemGroup>
     <ItemGroup>
         <Content Update="appsettings.json">