فهرست منبع

广告系统支持二级分类

懒得勤快 3 سال پیش
والد
کامیت
799858b30f

+ 1 - 0
src/Masuit.MyBlogs.Core/Extensions/UEditor/CrawlerHandler.cs

@@ -73,6 +73,7 @@ namespace Masuit.MyBlogs.Core.Extensions.UEditor
             }
             try
             {
+                HttpClient.DefaultRequestHeaders.Referrer = new Uri(SourceUrl);
                 using var response = await HttpClient.GetAsync(SourceUrl);
                 if (response.StatusCode != HttpStatusCode.OK)
                 {

+ 6 - 3
src/Masuit.MyBlogs.Core/Infrastructure/Services/AdvertisementService.cs

@@ -1,4 +1,5 @@
 using CacheManager.Core;
+using EFCoreSecondLevelCacheInterceptor;
 using Masuit.LuceneEFCore.SearchEngine.Interfaces;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
@@ -58,10 +59,12 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
                 where = where.And(a => a.RegionMode == RegionLimitMode.All || (a.RegionMode == RegionLimitMode.AllowRegion ? Regex.IsMatch(location, a.Regions) : !Regex.IsMatch(location, a.Regions)));
                 if (cid.HasValue)
                 {
-                    var scid = cid.ToString();
-                    if (Any(a => a.CategoryIds.Contains(scid)))
+                    var cids1 = CategoryRepository.GetQuery(c => c.ParentId == cid).Select(c => c.Id).Cacheable().ToArray();
+                    var cids2 = CategoryRepository.GetQuery(c => c.Id == cid && c.ParentId != null).Select(c => c.ParentId.Value).Cacheable().ToArray();
+                    var scid = cids1.Union(cids2).Append(cid.Value).Join("|");
+                    if (Any(a => Regex.IsMatch(a.CategoryIds, scid)))
                     {
-                        where = where.And(a => a.CategoryIds.Contains(scid) || string.IsNullOrEmpty(a.CategoryIds));
+                        where = where.And(a => Regex.IsMatch(a.CategoryIds, scid) || string.IsNullOrEmpty(a.CategoryIds));
                     }
                 }
 

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Home/Category.cshtml

@@ -13,8 +13,8 @@
 	ViewBag.Title = "分类_" + cat.Name;
 	Layout = "~/Views/Shared/_Layout.cshtml";
 	Random r = new Random();
-	var alllist = CategoryService.GetQuery(c => c.Status == Status.Available && c.ParentId == null, c => c.Name).Select(c => new{c.Id,c.Name}).Cacheable().ToList();
-	var children = cat.ParentId==null?cat.Children:cat.Parent.Children.OrderBy(c => c.Id).ToList();
+	var alllist = CategoryService.GetQuery(c => c.Status == Status.Available && c.ParentId == null&&c.Post.Count>0, c => c.Name).Select(c => new{c.Id,c.Name}).Cacheable().ToList();
+	var children = cat.ParentId==null?cat.Children:cat.Parent.Children.Where(c => c.Status == Status.Available && c.Post.Count>0).OrderBy(c => c.Id).ToList();
 }
 <style>
 	.bg-title {