Jelajahi Sumber

1.banner功能重构;
2.代码兼容mssql和mysql

懒得勤快 6 tahun lalu
induk
melakukan
ab08844900
55 mengubah file dengan 724 tambahan dan 875 penghapusan
  1. 57 1
      src/Masuit.MyBlogs.Core/Controllers/AdminController.cs
  2. 64 0
      src/Masuit.MyBlogs.Core/Controllers/BannerController.cs
  3. 4 4
      src/Masuit.MyBlogs.Core/Controllers/BaseController.cs
  4. 7 6
      src/Masuit.MyBlogs.Core/Controllers/CommentController.cs
  5. 26 37
      src/Masuit.MyBlogs.Core/Controllers/HomeController.cs
  6. 2 1
      src/Masuit.MyBlogs.Core/Controllers/LinksController.cs
  7. 0 1
      src/Masuit.MyBlogs.Core/Controllers/MenuController.cs
  8. 2 1
      src/Masuit.MyBlogs.Core/Controllers/MiscController.cs
  9. 6 5
      src/Masuit.MyBlogs.Core/Controllers/MsgController.cs
  10. 3 2
      src/Masuit.MyBlogs.Core/Controllers/NoticeController.cs
  11. 10 10
      src/Masuit.MyBlogs.Core/Controllers/PassportController.cs
  12. 9 72
      src/Masuit.MyBlogs.Core/Controllers/PostController.cs
  13. 2 1
      src/Masuit.MyBlogs.Core/Controllers/SeminarController.cs
  14. 2 2
      src/Masuit.MyBlogs.Core/Controllers/UploadController.cs
  15. 3 2
      src/Masuit.MyBlogs.Core/Extensions/AuthorityAttribute.cs
  16. 1 1
      src/Masuit.MyBlogs.Core/Extensions/FirewallMiddleware.cs
  17. 0 135
      src/Masuit.MyBlogs.Core/Extensions/SessionExt.cs
  18. 17 7
      src/Masuit.MyBlogs.Core/Infrastructure/DataContext.cs
  19. 2 40
      src/Masuit.MyBlogs.Core/Infrastructure/Repository/BaseRepository.cs
  20. 2 25
      src/Masuit.MyBlogs.Core/Infrastructure/Repository/Interface/IBaseRepository.cs
  21. 1 2
      src/Masuit.MyBlogs.Core/Infrastructure/Repository/PostRepository.cs
  22. 43 21
      src/Masuit.MyBlogs.Core/Infrastructure/Repository/Repositories.cs
  23. 3 38
      src/Masuit.MyBlogs.Core/Infrastructure/Services/BaseService.cs
  24. 43 6
      src/Masuit.MyBlogs.Core/Infrastructure/Services/CommentService.cs
  25. 1 25
      src/Masuit.MyBlogs.Core/Infrastructure/Services/Interface/IBaseService.cs
  26. 2 2
      src/Masuit.MyBlogs.Core/Infrastructure/Services/Interface/ICommentService.cs
  27. 1 0
      src/Masuit.MyBlogs.Core/Infrastructure/Services/Interface/IServices.cs
  28. 45 5
      src/Masuit.MyBlogs.Core/Infrastructure/Services/LeaveMessageService.cs
  29. 26 2
      src/Masuit.MyBlogs.Core/Infrastructure/Services/MenuService.cs
  30. 6 0
      src/Masuit.MyBlogs.Core/Infrastructure/Services/Services.cs
  31. 3 2
      src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj
  32. 96 203
      src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml
  33. 51 52
      src/Masuit.MyBlogs.Core/Migrations/20190321050816_Init.Designer.cs
  34. 35 23
      src/Masuit.MyBlogs.Core/Migrations/20190321050816_Init.cs
  35. 39 27
      src/Masuit.MyBlogs.Core/Migrations/DataContextModelSnapshot.cs
  36. 0 17
      src/Masuit.MyBlogs.Core/Models/DTO/PostOutputDto.cs
  37. 36 0
      src/Masuit.MyBlogs.Core/Models/Entity/Banner.cs
  38. 0 18
      src/Masuit.MyBlogs.Core/Models/Entity/Post.cs
  39. 2 1
      src/Masuit.MyBlogs.Core/Models/ViewModel/IndexPageViewModel.cs
  40. 8 7
      src/Masuit.MyBlogs.Core/Startup.cs
  41. 2 1
      src/Masuit.MyBlogs.Core/Views/Home/Category.cshtml
  42. 3 2
      src/Masuit.MyBlogs.Core/Views/Home/Index.cshtml
  43. 2 2
      src/Masuit.MyBlogs.Core/Views/Home/Post.cshtml
  44. 2 2
      src/Masuit.MyBlogs.Core/Views/Home/Tag.cshtml
  45. 2 2
      src/Masuit.MyBlogs.Core/Views/Msg/Index_Admin.cshtml
  46. 2 2
      src/Masuit.MyBlogs.Core/Views/Notice/Details.cshtml
  47. 2 2
      src/Masuit.MyBlogs.Core/Views/Post/Details.cshtml
  48. 2 2
      src/Masuit.MyBlogs.Core/Views/Post/Details_Admin.cshtml
  49. 2 2
      src/Masuit.MyBlogs.Core/Views/Post/HistoryVersion.cshtml
  50. 2 2
      src/Masuit.MyBlogs.Core/Views/Post/Publish_Admin.cshtml
  51. 3 4
      src/Masuit.MyBlogs.Core/Views/Seminar/Index.cshtml
  52. 2 2
      src/Masuit.MyBlogs.Core/Views/Shared/_Layout.cshtml
  53. 4 4
      src/Masuit.MyBlogs.Core/appsettings.json
  54. 15 31
      src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/post.js
  55. 19 11
      src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/post/top.html

+ 57 - 1
src/Masuit.MyBlogs.Core/Controllers/AdminController.cs

@@ -1,8 +1,17 @@
-using Masuit.MyBlogs.Core.Extensions;
+using Common;
+using Masuit.MyBlogs.Core.Configs;
+using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
+using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
+using Masuit.Tools.Security;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
 using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
 using System.Text;
 
 namespace Masuit.MyBlogs.Core.Controllers
@@ -56,5 +65,52 @@ namespace Masuit.MyBlogs.Core.Controllers
                 MissingMemberHandling = MissingMemberHandling.Ignore
             }), "application/json", Encoding.UTF8);
         }
+
+        /// <summary>在调用操作方法前调用。</summary>
+        /// <param name="filterContext">有关当前请求和操作的信息。</param>
+        public override void OnActionExecuting(ActionExecutingContext filterContext)
+        {
+            base.OnActionExecuting(filterContext);
+            if (filterContext.HttpContext.Request.Method.Equals("GET", StringComparison.InvariantCultureIgnoreCase)) //get方式的多半是页面
+            {
+                UserInfoOutputDto user = filterContext.HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
+#if DEBUG
+                user = UserInfoService.GetByUsername("masuit").Mapper<UserInfoOutputDto>();
+                filterContext.HttpContext.Session.Set(SessionKey.UserInfo, user);
+#endif
+                if (user == null && Request.Cookies.Count > 2) //执行自动登录
+                {
+                    string name = Request.Cookies["username"];
+                    string pwd = Request.Cookies["password"]?.DesDecrypt(AppConfig.BaiduAK);
+                    var userInfo = UserInfoService.Login(name, pwd);
+                    if (userInfo != null)
+                    {
+                        Response.Cookies.Append("username", name, new CookieOptions
+                        {
+                            Expires = DateTime.Now.AddDays(7)
+                        });
+                        Response.Cookies.Append("password", Request.Cookies["password"], new CookieOptions
+                        {
+                            Expires = DateTime.Now.AddDays(7)
+                        });
+                        filterContext.HttpContext.Session.Set(SessionKey.UserInfo, userInfo);
+                    }
+                }
+            }
+            else
+            {
+                if (ModelState.IsValid) return;
+                List<string> errmsgs = new List<string>();
+                ModelState.ForEach(kv => kv.Value.Errors.ForEach(error => errmsgs.Add(error.ErrorMessage)));
+                if (errmsgs.Count > 1)
+                {
+                    for (var i = 0; i < errmsgs.Count; i++)
+                    {
+                        errmsgs[i] = i + 1 + ". " + errmsgs[i];
+                    }
+                }
+                filterContext.Result = ResultData(null, false, "数据校验失败,错误信息:" + string.Join(" | ", errmsgs));
+            }
+        }
     }
 }

+ 64 - 0
src/Masuit.MyBlogs.Core/Controllers/BannerController.cs

@@ -0,0 +1,64 @@
+using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
+using Masuit.MyBlogs.Core.Models.Entity;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using System.Threading.Tasks;
+
+namespace Masuit.MyBlogs.Core.Controllers
+{
+    /// <summary>
+    /// banner
+    /// </summary>
+    [Route("[controller]/[action]")]
+    public class BannerController : AdminController
+    {
+        /// <summary>
+        /// bannerService
+        /// </summary>
+        public IBannerService BannerService { get; set; }
+
+        /// <summary>
+        /// 获取全部
+        /// </summary>
+        /// <returns></returns>
+        public async Task<IActionResult> Get()
+        {
+            return ResultData(await BannerService.GetAllFromL2CacheNoTracking(b => b.Id, false).ToListAsync());
+        }
+
+        /// <summary>
+        /// 保存banner
+        /// </summary>
+        /// <param name="banner"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<IActionResult> Save(Banner banner)
+        {
+            Banner entity = BannerService.GetById(banner.Id);
+            if (entity != null)
+            {
+                entity.Url = banner.Url;
+                entity.Description = banner.Description;
+                entity.ImageUrl = banner.ImageUrl;
+                entity.Title = banner.Title;
+                bool b1 = await BannerService.UpdateEntitySavedAsync(entity) > 0;
+                return ResultData(null, b1, b1 ? "修改成功" : "修改失败");
+            }
+
+            bool b = BannerService.AddEntitySaved(banner) != null;
+            return ResultData(null, b, b ? "添加成功" : "添加失败");
+        }
+
+        /// <summary>
+        /// 删除banner
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpPost("{id}"), HttpGet("{id}")]
+        public IActionResult Delete(int id)
+        {
+            bool b = BannerService.DeleteByIdSaved(id);
+            return ResultData(null, b, b ? "删除成功" : "删除失败");
+        }
+    }
+}

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

@@ -1,9 +1,9 @@
 using Masuit.MyBlogs.Core.Configs;
-using Masuit.MyBlogs.Core.Extensions;
 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.Core.Net;
 using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
@@ -90,10 +90,10 @@ namespace Masuit.MyBlogs.Core.Controllers
             base.OnActionExecuting(filterContext);
             if (filterContext.HttpContext.Request.Method.Equals("GET", StringComparison.InvariantCultureIgnoreCase)) //get方式的多半是页面
             {
-                UserInfoOutputDto user = filterContext.HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+                UserInfoOutputDto user = filterContext.HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
 #if DEBUG
                 user = UserInfoService.GetByUsername("masuit").Mapper<UserInfoOutputDto>();
-                filterContext.HttpContext.Session.SetByRedis(SessionKey.UserInfo, user);
+                filterContext.HttpContext.Session.Set(SessionKey.UserInfo, user);
 #endif
                 if (user == null && Request.Cookies.Count > 2) //执行自动登录
                 {
@@ -110,7 +110,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         {
                             Expires = DateTime.Now.AddDays(7)
                         });
-                        filterContext.HttpContext.Session.SetByRedis(SessionKey.UserInfo, userInfo);
+                        filterContext.HttpContext.Session.Set(SessionKey.UserInfo, userInfo);
                     }
                 }
             }

+ 7 - 6
src/Masuit.MyBlogs.Core/Controllers/CommentController.cs

@@ -6,8 +6,10 @@ using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Net.Http.Headers;
 using System;
@@ -16,7 +18,6 @@ using System.IO;
 using System.Linq;
 using System.Text.RegularExpressions;
 using System.Web;
-using Microsoft.AspNetCore.Http;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -58,10 +59,10 @@ namespace Masuit.MyBlogs.Core.Controllers
             {
                 return ResultData(null, false, "评论失败,文章不存在!");
             }
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             comment.Content = comment.Content.Trim().Replace("<p><br></p>", string.Empty);
 
-            if (comment.Content.RemoveHtml().Trim().Equals(HttpContext.Session.GetByRedis<string>("comment" + comment.PostId)))
+            if (comment.Content.RemoveHtml().Trim().Equals(HttpContext.Session.Get<string>("comment" + comment.PostId)))
             {
                 return ResultData(null, false, "您刚才已经在这篇文章发表过一次评论了,换一篇文章吧,或者换一下评论内容吧!");
             }
@@ -87,7 +88,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             Comment com = CommentService.AddEntitySaved(comment.Mapper<Comment>());
             if (com != null)
             {
-                HttpContext.Session.SetByRedis("comment" + comment.PostId, comment.Content.RemoveHtml().Trim());
+                HttpContext.Session.Set("comment" + comment.PostId, comment.Content.RemoveHtml().Trim());
                 var emails = new List<string>();
                 var email = CommonHelper.SystemSettings["ReceiveEmail"]; //站长邮箱
                 emails.Add(email);
@@ -190,7 +191,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost]
         public ActionResult GetComments(int? id, int page = 1, int size = 5, int cid = 0)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             int total; //总条数,用于前台分页
             if (cid != 0)
             {
@@ -241,7 +242,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost]
         public ActionResult GetPageComments(int page = 1, int size = 5, int cid = 0)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             int total; //总条数,用于前台分页
             if (cid != 0)
             {

+ 26 - 37
src/Masuit.MyBlogs.Core/Controllers/HomeController.cs

@@ -1,12 +1,12 @@
 using AutoMapper.QueryableExtensions;
 using EFSecondLevelCache.Core;
-using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Net.Http.Headers;
 using System;
@@ -53,23 +53,9 @@ namespace Masuit.MyBlogs.Core.Controllers
         public IFastShareService FastShareService { get; set; }
 
         /// <summary>
-        /// 首页
+        /// banner
         /// </summary>
-        /// <param name="postService"></param>
-        /// <param name="categoryService"></param>
-        /// <param name="searchDetailsService"></param>
-        /// <param name="noticeService"></param>
-        /// <param name="postAccessRecordService"></param>
-        /// <param name="fastShareService"></param>
-        public HomeController(IPostService postService, ICategoryService categoryService, ISearchDetailsService searchDetailsService, INoticeService noticeService, IPostAccessRecordService postAccessRecordService, IFastShareService fastShareService)
-        {
-            CategoryService = categoryService;
-            PostService = postService;
-            SearchDetailsService = searchDetailsService;
-            NoticeService = noticeService;
-            PostAccessRecordService = postAccessRecordService;
-            FastShareService = fastShareService;
-        }
+        public IBannerService BannerService { get; set; }
 
         /// <summary>
         /// 首页
@@ -80,23 +66,12 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult Index(OrderBy orderBy = OrderBy.ModifyDate)
         {
             //ViewBag.Total = 0;
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
-            var tops = PostService.LoadEntitiesFromL2CacheNoTracking(t => t.Status == Status.Pended && t.IsBanner, p => p.ModifyDate, false).Select(p => new
-            {
-                p.Title,
-                p.Description,
-                p.Id,
-                p.ImageUrl
-            }).ToList();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            var banners = BannerService.GetAllFromL2CacheNoTracking(b => b.Id, false).ToList();
             List<FastShare> fastShares = FastShareService.GetAllFromL2CacheNoTracking(s => s.Sort).ToList();
             ViewBag.FastShare = fastShares;
             var viewModel = GetIndexPageViewModel(1, 15, orderBy, user);
-            var banner = new List<PostOutputDto>();
-            tops.ForEach(t =>
-            {
-                banner.Add(t.MapTo<PostOutputDto>());
-            });
-            viewModel.Banner = banner;
+            viewModel.Banner = banners;
             return View(viewModel);
         }
 
@@ -110,7 +85,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("p/{page:int?}/{size:int?}/{orderBy:int?}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "page", "size", "orderBy" }, VaryByHeader = HeaderNames.Cookie)]
         public ActionResult Post(int page = 1, int size = 15, OrderBy orderBy = OrderBy.ModifyDate)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             ViewBag.Total = PostService.LoadEntitiesFromL2Cache<PostOutputDto>(p => p.Status == Status.Pended || user.IsAdmin && !p.IsFixedTop).Count(p => !p.IsFixedTop);
             var viewModel = GetIndexPageViewModel(page, size, orderBy, user);
             return View(viewModel);
@@ -128,7 +103,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult Tag(string id, int page = 1, int size = 15, OrderBy orderBy = OrderBy.ModifyDate)
         {
             IList<PostOutputDto> posts;
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             var temp = PostService.LoadEntities<PostOutputDto>(p => p.Label.Contains(id) && (p.Status == Status.Pended || user.IsAdmin)).OrderByDescending(p => p.IsFixedTop);
             switch (orderBy)
             {
@@ -170,7 +145,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("cat/{id:int}/{page:int?}/{size:int?}/{orderBy:int?}")]
         public async Task<ActionResult> Category(int id, int page = 1, int size = 15, OrderBy orderBy = OrderBy.ModifyDate)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             var cat = await CategoryService.GetByIdAsync(id).ConfigureAwait(true);
             if (cat is null) return RedirectToAction("Index", "Error");
             var posts = PostService.LoadEntitiesNoTracking(p => p.CategoryId == cat.Id && (p.Status == Status.Pended || user.IsAdmin)).OrderByDescending(p => p.IsFixedTop);
@@ -234,9 +209,23 @@ namespace Masuit.MyBlogs.Core.Controllers
                     break;
             }
             var hot6Post = postList.OrderByDescending(order).Skip(0).Take(5).Cacheable().ToList(); //热门文章
-            var topPostWeek = PostService.SqlQuery<SimplePostModel>("SELECT [Id],[Title] from Post WHERE Id in (SELECT top 10 PostId FROM [dbo].[PostAccessRecord] where DATEDIFF(week,AccessTime,getdate())<=1 GROUP BY PostId ORDER BY sum(ClickCount) desc)").ToList(); //文章周排行
-            var topPostMonth = PostService.SqlQuery<SimplePostModel>("SELECT [Id],[Title] from Post WHERE Id in (SELECT top 10 PostId FROM [dbo].[PostAccessRecord] where DATEDIFF(month,AccessTime,getdate())<=1 GROUP BY PostId ORDER BY sum(ClickCount) desc)").ToList(); //文章月排行
-            var topPostToday = PostService.SqlQuery<SimplePostModel>("SELECT [Id],[Title] from Post WHERE Id in (SELECT top 10 PostId FROM [dbo].[PostAccessRecord] where DATEDIFF(day,AccessTime,getdate())<=1 GROUP BY PostId ORDER BY sum(ClickCount) desc)").ToList(); //文章今日排行
+            var topPostToday = PostAccessRecordService.LoadPageEntitiesNoTracking(1, 10, out _, p => p.AccessTime > DateTime.Today, r => r.ClickCount, false).Select(r => new SimplePostModel()
+            {
+                Id = r.PostId,
+                Title = r.Post.Title
+            }).Cacheable().ToList();//文章今日排行
+            var week = DateTime.Today.AddDays(-7);
+            var topPostWeek = PostAccessRecordService.LoadPageEntitiesNoTracking(1, 10, out _, p => p.AccessTime > week, r => r.ClickCount, false).Select(r => new SimplePostModel()
+            {
+                Id = r.PostId,
+                Title = r.Post.Title
+            }).Cacheable().ToList(); //文章周排行
+            var month = DateTime.Today.AddMonths(-1);
+            var topPostMonth = PostAccessRecordService.LoadPageEntitiesNoTracking(1, 10, out _, p => p.AccessTime > month, r => r.ClickCount, false).Select(r => new SimplePostModel()
+            {
+                Id = r.PostId,
+                Title = r.Post.Title
+            }).Cacheable().ToList(); //文章月排行
             var tags = new List<string>(); //标签云
             var tagdic = new Dictionary<string, int>();
             var newdic = new Dictionary<string, int>(); //标签云最终结果

+ 2 - 1
src/Masuit.MyBlogs.Core/Controllers/LinksController.cs

@@ -5,6 +5,7 @@ using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Net.Http.Headers;
 using System;
@@ -28,7 +29,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("links"), ResponseCache(Duration = 600, VaryByHeader = HeaderNames.Cookie)]
         public ActionResult Index()
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             List<LinksOutputDto> list = LinksService.LoadEntities<object, LinksOutputDto>(l => l.Status == Status.Available, l => l.Recommend, false).ToList();
             if (user != null && user.IsAdmin)
             {

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

@@ -72,7 +72,6 @@ namespace Masuit.MyBlogs.Core.Controllers
             return ResultData(null, b, b ? "删除成功" : "删除失败");
         }
 
-
         /// <summary>
         /// 保持菜单
         /// </summary>

+ 2 - 1
src/Masuit.MyBlogs.Core/Controllers/MiscController.cs

@@ -5,6 +5,7 @@ using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
@@ -69,7 +70,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("donate")]
         public ActionResult Donate()
         {
-            var user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            var user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             if (user != null && user.IsAdmin)
             {
                 return View("Donate_Admin");

+ 6 - 5
src/Masuit.MyBlogs.Core/Controllers/MsgController.cs

@@ -6,6 +6,7 @@ using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
@@ -56,7 +57,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [ResponseCache(Duration = 600, VaryByHeader = HeaderNames.Cookie), Route("msg")]
         public ActionResult Index()
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             ViewBag.TotalCount = LeaveMessageService.LoadEntitiesNoTracking(m => m.ParentId == 0 && m.Status == Status.Pended).Count();
             if (user.IsAdmin)
             {
@@ -74,7 +75,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <returns></returns>
         public ActionResult GetMsgs(int page = 1, int size = 10, int cid = 0)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             int total;
             if (cid != 0)
             {
@@ -123,9 +124,9 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost, ValidateAntiForgeryToken]
         public ActionResult Put(LeaveMessageInputDto msg)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             msg.Content = msg.Content.Trim().Replace("<p><br></p>", string.Empty);
-            if (msg.Content.RemoveHtml().Trim().Equals(HttpContext.Session.GetByRedis<string>("msg")))
+            if (msg.Content.RemoveHtml().Trim().Equals(HttpContext.Session.Get<string>("msg")))
             {
                 return ResultData(null, false, "您刚才已经发表过一次留言了!");
             }
@@ -152,7 +153,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             LeaveMessage msg2 = LeaveMessageService.AddEntitySaved(msg.Mapper<LeaveMessage>());
             if (msg2 != null)
             {
-                HttpContext.Session.SetByRedis("msg", msg.Content.RemoveHtml().Trim());
+                HttpContext.Session.Set("msg", msg.Content.RemoveHtml().Trim());
                 var email = CommonHelper.SystemSettings["ReceiveEmail"];
                 string content = System.IO.File.ReadAllText(_hostingEnvironment.WebRootPath + "/template/notify.html").Replace("{{title}}", "网站留言板").Replace("{{time}}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Replace("{{nickname}}", msg2.NickName).Replace("{{content}}", msg2.Content);
                 if (msg.Status == Status.Pended)

+ 3 - 2
src/Masuit.MyBlogs.Core/Controllers/NoticeController.cs

@@ -6,15 +6,16 @@ using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Net.Http.Headers;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.RegularExpressions;
-using Microsoft.AspNetCore.Http;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -51,7 +52,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("notice"), ResponseCache(Duration = 60, VaryByQueryKeys = new[] { "page", "size", "id" }, VaryByHeader = HeaderNames.Cookie)]
         public ActionResult Index(int page = 1, int size = 10, int id = 0)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             List<NoticeOutputDto> list;
             int total;
             if (user != null && user.IsAdmin)

+ 10 - 10
src/Masuit.MyBlogs.Core/Controllers/PassportController.cs

@@ -1,7 +1,6 @@
 using Common;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Configs;
-using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.DTO;
@@ -9,6 +8,7 @@ using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
 using Masuit.Tools.AspNetCore.ResumeFileResults.Extensions;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Security;
 using Masuit.Tools.Strings;
 using Microsoft.AspNetCore.Hosting;
@@ -78,7 +78,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 from = HttpUtility.UrlDecode(from);
                 Response.Cookies.Append("refer", from);
             }
-            if (HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) != null)
+            if (HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) != null)
             {
                 if (string.IsNullOrEmpty(from))
                 {
@@ -95,7 +95,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 {
                     Response.Cookies.Append("username", name, new CookieOptions() { Expires = DateTime.Now.AddDays(7) });
                     Response.Cookies.Append("password", Request.Cookies["password"], new CookieOptions() { Expires = DateTime.Now.AddDays(7) });
-                    HttpContext.Session.SetByRedis(SessionKey.UserInfo, userInfo);
+                    HttpContext.Session.Set(SessionKey.UserInfo, userInfo);
                     HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.LoginRecord), "default", userInfo, HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(), LoginType.Default);
                     if (string.IsNullOrEmpty(from))
                     {
@@ -118,12 +118,12 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost, ValidateAntiForgeryToken]
         public ActionResult Login(string username, string password, string valid, string remem)
         {
-            string validSession = HttpContext.Session.GetByRedis<string>("valid") ?? string.Empty; //将验证码从Session中取出来,用于登录验证比较
+            string validSession = HttpContext.Session.Get<string>("valid") ?? string.Empty; //将验证码从Session中取出来,用于登录验证比较
             if (string.IsNullOrEmpty(validSession) || !valid.Trim().Equals(validSession, StringComparison.InvariantCultureIgnoreCase))
             {
                 return ResultData(null, false, "验证码错误");
             }
-            HttpContext.Session.RemoveByRedis("valid"); //验证成功就销毁验证码Session,非常重要
+            HttpContext.Session.Remove("valid"); //验证成功就销毁验证码Session,非常重要
             if (string.IsNullOrEmpty(username.Trim()) || string.IsNullOrEmpty(password.Trim()))
             {
                 return ResultData(null, false, "用户名或密码不能为空");
@@ -131,7 +131,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             var userInfo = UserInfoService.Login(username, password);
             if (userInfo != null)
             {
-                HttpContext.Session.SetByRedis(SessionKey.UserInfo, userInfo);
+                HttpContext.Session.Set(SessionKey.UserInfo, userInfo);
                 if (remem.Trim().Contains(new[] { "on", "true" })) //是否记住登录
                 {
                     Response.Cookies.Append("username", HttpUtility.UrlEncode(username.Trim()), new CookieOptions() { Expires = DateTime.Now.AddDays(7) });
@@ -151,7 +151,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult ValidateCode()
         {
             string code = Tools.Strings.ValidateCode.CreateValidateCode(6);
-            HttpContext.Session.SetByRedis("valid", code); //将验证码生成到Session中
+            HttpContext.Session.Set("valid", code); //将验证码生成到Session中
             var buffer = HttpContext.CreateValidateGraphic(code);
             return this.ResumeFile(buffer, "image/jpeg");
         }
@@ -164,7 +164,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost]
         public ActionResult CheckValidateCode(string code)
         {
-            string validSession = HttpContext.Session.GetByRedis<string>("valid");
+            string validSession = HttpContext.Session.Get<string>("valid");
             if (string.IsNullOrEmpty(validSession) || !code.Trim().Equals(validSession, StringComparison.InvariantCultureIgnoreCase))
             {
                 return ResultData(null, false, "验证码错误");
@@ -178,7 +178,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <returns></returns>
         public ActionResult GetUserInfo()
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             if (_env.IsDevelopment())
             {
                 user = UserInfoService.GetByUsername("masuit").Mapper<UserInfoOutputDto>();
@@ -192,7 +192,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <returns></returns>
         public ActionResult Logout()
         {
-            HttpContext.Session.RemoveByRedis(SessionKey.UserInfo);
+            HttpContext.Session.Remove(SessionKey.UserInfo);
             Response.Cookies.Delete("username");
             Response.Cookies.Delete("password");
             HttpContext.Session.Clear();

+ 9 - 72
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -14,6 +14,7 @@ using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.DateTimeExt;
 using Masuit.Tools.Html;
 using Masuit.Tools.Security;
@@ -83,7 +84,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             if (post != null)
             {
                 ViewBag.Keyword = post.Keyword + "," + post.Label;
-                UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+                UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
                 DateTime modifyDate = post.ModifyDate;
                 ViewBag.Next = PostService.GetFirstEntityNoTracking(p => p.ModifyDate > modifyDate && (p.Status == Status.Pended || user.IsAdmin), p => p.ModifyDate);
                 ViewBag.Prev = PostService.GetFirstEntityNoTracking(p => p.ModifyDate < modifyDate && (p.Status == Status.Pended || user.IsAdmin), p => p.ModifyDate, false);
@@ -101,10 +102,10 @@ namespace Masuit.MyBlogs.Core.Controllers
                     return RedirectToAction("Post", "Home");
                 }
 
-                if (!HttpContext.Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.GetByRedis<string>("post" + id)))
+                if (!HttpContext.Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get<string>("post" + id)))
                 {
                     HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.RecordPostVisit), args: id);
-                    HttpContext.Session.SetByRedis("post" + id, id.ToString());
+                    HttpContext.Session.Set("post" + id, id.ToString());
                 }
 
                 return View(post);
@@ -153,7 +154,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("{id:int}/history/{hid:int}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "id", "hid" }, VaryByHeader = HeaderNames.Cookie)]
         public ActionResult HistoryVersion(int id, int hid)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             var post = PostHistoryVersionService.GetById(hid);
             if (post is null)
             {
@@ -268,7 +269,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 }
             });
             ViewBag.Category = CategoryService.LoadEntitiesNoTracking(c => c.Status == Status.Available).ToList();
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             if (user != null)
             {
                 return View("Publish_Admin", result.Distinct().OrderBy(s => s));
@@ -285,7 +286,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost, ValidateAntiForgeryToken]
         public ActionResult Publish(PostInputDto post)
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             if (!CategoryService.Any(c => c.Id == post.CategoryId && c.Status == Status.Available))
             {
                 return ResultData(null, message: "请选择一个分类");
@@ -372,7 +373,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("all"), ResponseCache(Duration = 600, VaryByHeader = HeaderNames.Cookie)]
         public ActionResult All()
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             List<string> tags = PostService.GetAll().Select(p => p.Label).ToList(); //tag
             List<string> result = new List<string>();
             tags.ForEach(s =>
@@ -414,7 +415,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             var s = RedisHelper.Get("ArticleViewToken");
             if (token.Equals(s))
             {
-                HttpContext.Session.SetByRedis("ArticleViewToken", token);
+                HttpContext.Session.Set("ArticleViewToken", token);
                 return ResultData(null);
             }
 
@@ -976,70 +977,6 @@ namespace Masuit.MyBlogs.Core.Controllers
             return ResultData(null, false, "文章发表失败!");
         }
 
-        /// <summary>
-        /// 获取头图文章
-        /// </summary>
-        /// <returns></returns>
-        public ActionResult GetTops()
-        {
-            var list = PostService.LoadEntities<DateTime, PostOutputDto>(p => p.Status == Status.Pended && p.IsBanner, p => p.ModifyDate, false).Select(p => new
-            {
-                p.Id,
-                p.Description,
-                p.Title,
-                p.ImageUrl
-            }).ToList();
-            return ResultData(list);
-        }
-
-        /// <summary>
-        /// 获取非头图页文章
-        /// </summary>
-        /// <returns></returns>
-        public ActionResult GetNotTops()
-        {
-            var list = PostService.LoadEntitiesNoTracking(p => p.Status == Status.Pended && !p.IsBanner).GroupBy(p => p.Category.Name).Select(g => new
-            {
-                text = g.Key,
-                children = g.OrderBy(p => p.Title).Select(p => new
-                {
-                    id = p.Id,
-                    text = p.Title
-                })
-            }).ToList();
-            return ResultData(list);
-        }
-
-        /// <summary>
-        /// 添加头图页
-        /// </summary>
-        /// <param name="p"></param>
-        /// <returns></returns>
-        [HttpPost, Authority]
-        public ActionResult AddTop(PostOutputDto p)
-        {
-            Post post = PostService.GetById(p.Id);
-            post.IsBanner = true;
-            post.Description = p.Description;
-            post.ImageUrl = p.ImageUrl;
-            bool b = PostService.UpdateEntitySaved(post);
-            return ResultData(null, b, b ? "添加头图页成功" : "添加头图页失败!");
-        }
-
-        /// <summary>
-        /// 取消头图页
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        [Authority, HttpPost]
-        public ActionResult RemoveTop(int id)
-        {
-            Post post = PostService.GetById(id);
-            post.IsBanner = false;
-            bool b = PostService.UpdateEntitySaved(post);
-            return ResultData(null, b, b ? "取消头图页成功" : "取消头图页失败!");
-        }
-
         /// <summary>
         /// 添加专题
         /// </summary>

+ 2 - 1
src/Masuit.MyBlogs.Core/Controllers/SeminarController.cs

@@ -5,6 +5,7 @@ using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Net.Http.Headers;
 using System;
@@ -55,7 +56,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult Index(int id, int page = 1, int size = 15, OrderBy orderBy = OrderBy.ModifyDate)
         {
             IList<Post> posts;
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             var s = SeminarService.GetById(id);
             if (s is null)
             {

+ 2 - 2
src/Masuit.MyBlogs.Core/Controllers/UploadController.cs

@@ -1,13 +1,13 @@
 using Common;
 using Hangfire;
 using Masuit.MyBlogs.Core.Common;
-using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Extensions.UEditor;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
 using Masuit.Tools.AspNetCore.Mime;
 using Masuit.Tools.AspNetCore.ResumeFileResults.Extensions;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Masuit.Tools.Logging;
 using Masuit.Tools.Systems;
@@ -174,7 +174,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("fileuploader")]
         public ActionResult UeditorFileUploader()
         {
-            UserInfoOutputDto user = HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             Handler action = new NotSupportedHandler(HttpContext);
             switch (Request.Query["action"])//通用
             {

+ 3 - 2
src/Masuit.MyBlogs.Core/Extensions/AuthorityAttribute.cs

@@ -2,6 +2,7 @@
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
@@ -27,7 +28,7 @@ namespace Masuit.MyBlogs.Core.Extensions
                 return;
             }
 #if !DEBUG
-            UserInfoOutputDto user = filterContext.HttpContext.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+            UserInfoOutputDto user = filterContext.HttpContext.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
             if (user == null || !user.IsAdmin)
             {
                 //先尝试自动登录
@@ -41,7 +42,7 @@ namespace Masuit.MyBlogs.Core.Extensions
                     {
                         filterContext.HttpContext.Response.Cookies.Append("username", name, new CookieOptions() { Expires = DateTime.Now.AddDays(7) });
                         filterContext.HttpContext.Response.Cookies.Append("password", filterContext.HttpContext.Request.Cookies["password"], new CookieOptions() { Expires = DateTime.Now.AddDays(7) });
-                        filterContext.HttpContext.Session.SetByRedis(SessionKey.UserInfo, userInfo);
+                        filterContext.HttpContext.Session.Set(SessionKey.UserInfo, userInfo);
                     }
                     else
                     {

+ 1 - 1
src/Masuit.MyBlogs.Core/Extensions/FirewallMiddleware.cs

@@ -91,7 +91,7 @@ namespace Masuit.MyBlogs.Core.Extensions
                 if (t.IsCompletedSuccessfully)
                 {
                     var result = await t;
-                    if (result.Status == 0)
+                    if (result?.Status == 0)
                     {
                         foreach (var key in CommonHelper.DenyAreaIP.Keys)
                         {

+ 0 - 135
src/Masuit.MyBlogs.Core/Extensions/SessionExt.cs

@@ -1,135 +0,0 @@
-using Masuit.Tools;
-using Masuit.Tools.Core.Net;
-using Masuit.Tools.Logging;
-using Microsoft.AspNetCore.Http;
-using System;
-using System.Linq;
-
-namespace Masuit.MyBlogs.Core.Extensions
-{
-    /// <summary>
-    /// session扩展
-    /// </summary>
-    public static class SessionExt
-    {
-        /// <summary>
-        /// 将Session存到Redis,需要先在config中配置链接字符串,连接字符串在config配置文件中的ConnectionStrings节下配置,name固定为RedisHosts,值的格式:127.0.0.1:6379,allowadmin=true,若未正确配置,将按默认值“127.0.0.1:6379,allowadmin=true”进行操作,如:<br/>
-        /// &lt;connectionStrings&gt;<br/>
-        ///      &lt;add name = "RedisHosts" connectionString="127.0.0.1:6379,allowadmin=true"/&gt;<br/>
-        /// &lt;/connectionStrings&gt;
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="session"></param>
-        /// <param name="key">键</param>
-        /// <param name="obj">需要存的对象</param>
-        /// <param name="expire">过期时间,默认20分钟</param>
-        /// <returns></returns>
-        public static void SetByRedis<T>(this ISession session, string key, T obj, int expire = 20)
-        {
-            if (HttpContext2.Current is null)
-            {
-                throw new Exception("请确保此方法调用是在同步线程中执行!");
-            }
-            session?.SetString(key, obj.ToJsonString());
-
-            try
-            {
-                RedisHelper.HSet("Session:" + session.Id, key, obj); //存储数据到缓存服务器,这里将字符串"my value"缓存,key 是"test"
-                RedisHelper.Expire("Session:" + session.Id, TimeSpan.FromMinutes(expire));
-            }
-            catch
-            {
-                // ignored
-            }
-        }
-
-        /// <summary>
-        /// 从Redis取Session
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="session"></param>
-        /// <param name="key">键</param>
-        /// <param name="expire">过期时间,默认20分钟</param>
-        /// <returns></returns> 
-        public static T GetByRedis<T>(this ISession session, string key, int expire = 20) where T : class
-        {
-            if (HttpContext2.Current is null)
-            {
-                throw new Exception("请确保此方法调用是在同步线程中执行!");
-            }
-            T obj = default(T);
-            if (session != null)
-            {
-                obj = session.Get<T>(key);
-            }
-
-            if (obj == default(T))
-            {
-                try
-                {
-                    var sessionKey = "Session:" + session.Id;
-                    if (RedisHelper.Exists(sessionKey) && RedisHelper.HExists(sessionKey, key))
-                    {
-                        RedisHelper.Expire(sessionKey, TimeSpan.FromMinutes(expire));
-                        return RedisHelper.HGet<T>(sessionKey, key);
-                    }
-
-                    return default(T);
-                }
-                catch
-                {
-                    return default(T);
-                }
-            }
-
-            return obj;
-        }
-
-        /// <summary>
-        /// 从Redis移除对应键的Session
-        /// </summary>
-        /// <param name="session"></param>
-        /// <param name="key"></param>
-        /// <returns></returns>
-        public static void RemoveByRedis(this ISession session, string key)
-        {
-            if (HttpContext2.Current is null)
-            {
-                throw new Exception("请确保此方法调用是在同步线程中执行!");
-            }
-
-            session?.Remove(key);
-
-            try
-            {
-                var sessionKey = "Session:" + session.Id;
-                if (RedisHelper.Exists(sessionKey) && RedisHelper.HExists(sessionKey, key))
-                {
-                    RedisHelper.HDel(sessionKey, key);
-                }
-            }
-            catch (Exception e)
-            {
-                LogManager.Error(e);
-            }
-        }
-
-        /// <summary>
-        /// Session个数
-        /// </summary>
-        /// <param name="session"></param>
-        /// <returns></returns>
-        public static int SessionCount(this ISession session)
-        {
-            try
-            {
-                return RedisHelper.Keys("Session:*").Count();
-            }
-            catch (Exception e)
-            {
-                LogManager.Error(e);
-                return 0;
-            }
-        }
-    }
-}

+ 17 - 7
src/Masuit.MyBlogs.Core/Infrastructure/DataContext.cs

@@ -33,10 +33,18 @@ namespace Masuit.MyBlogs.Core.Infrastructure
             modelBuilder.Entity<PostHistoryVersion>().HasMany(e => e.Seminar).WithOne(s => s.PostHistoryVersion);
             modelBuilder.Entity<SearchDetails>().Property(e => e.KeyWords).IsUnicode();
             modelBuilder.Entity<UserInfo>().HasMany(e => e.LoginRecord).WithOne(e => e.UserInfo).OnDelete(DeleteBehavior.Cascade);
-            modelBuilder.Entity<SeminarPost>().HasKey(s => new { s.SeminarId, s.PostId });
+            modelBuilder.Entity<SeminarPost>().HasKey(s => new
+            {
+                s.SeminarId,
+                s.PostId
+            });
             modelBuilder.Entity<SeminarPost>().Property(s => s.SeminarId).HasColumnName("Seminar_Id");
             modelBuilder.Entity<SeminarPost>().Property(s => s.PostId).HasColumnName("Post_Id");
-            modelBuilder.Entity<SeminarPostHistoryVersion>().HasKey(s => new { s.SeminarId, s.PostHistoryVersionId });
+            modelBuilder.Entity<SeminarPostHistoryVersion>().HasKey(s => new
+            {
+                s.SeminarId,
+                s.PostHistoryVersionId
+            });
             modelBuilder.Entity<SeminarPostHistoryVersion>().Property(s => s.SeminarId).HasColumnName("Seminar_Id");
             modelBuilder.Entity<SeminarPostHistoryVersion>().Property(s => s.PostHistoryVersionId).HasColumnName("PostHistoryVersion_Id");
         }
@@ -49,6 +57,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure
             this.GetService<IEFCacheServiceProvider>().InvalidateCacheDependencies(changedEntityNames);
             return result;
         }
+
         public virtual DbSet<Broadcast> Broadcast { get; set; }
         public virtual DbSet<Category> Category { get; set; }
         public virtual DbSet<Comment> Comment { get; set; }
@@ -70,8 +79,9 @@ namespace Masuit.MyBlogs.Core.Infrastructure
         public virtual DbSet<PostAccessRecord> PostAccessRecord { get; set; }
         public virtual DbSet<InternalMessage> InternalMessage { get; set; }
         public virtual DbSet<FastShare> FastShare { get; set; }
-
+        public virtual DbSet<Banner> Banner { get; set; }
     }
+
     /// <summary>
     /// 勿删,数据库迁移时powershell会执行该方法
     /// </summary>
@@ -80,12 +90,12 @@ namespace Masuit.MyBlogs.Core.Infrastructure
         public DataContext CreateDbContext(string[] args)
         {
             //IConfigurationRoot config = new ConfigurationBuilder().AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
-            var conn = "Server=192.168.135.70;Database=matrixone_portfolio_test_db;Uid=portfolio;Pwd=portfolio@#$123;";
+            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");
+            builder.UseMySql(conn);
+            //builder.UseSqlServer("Data Source=.;Initial Catalog=CoreTest;Integrated Security=True");
 
             return new DataContext(builder.Options);
         }
     }
-}
+}

+ 2 - 40
src/Masuit.MyBlogs.Core/Infrastructure/Repository/BaseRepository.cs

@@ -1,13 +1,10 @@
 using AutoMapper.QueryableExtensions;
-using Dapper;
 using EFSecondLevelCache.Core;
 using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
 using Masuit.Tools.Systems;
 using Microsoft.EntityFrameworkCore;
 using System;
 using System.Collections.Generic;
-using System.Data;
-using System.Data.SqlClient;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Threading.Tasks;
@@ -22,11 +19,9 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Repository
     public class BaseRepository<T> : Disposable, IBaseRepository<T> where T : class, new()
     {
         public virtual DataContext DataContext { get; set; }
-        public IDbConnection DbConnection { get; set; }
-        public BaseRepository(DataContext dbContext, IDbConnection connection)
+        public BaseRepository(DataContext dbContext)
         {
             DataContext = dbContext;
-            DbConnection = connection;
         }
 
         /// <summary>
@@ -128,7 +123,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Repository
         /// <param name="orderby">排序字段</param>
         /// <param name="isAsc">是否升序</param>
         /// <returns>还未执行的SQL语句</returns>
-        public virtual IEnumerable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true)
+        public virtual EFCachedQueryable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true)
         {
             return GetAllNoTracking(orderby, isAsc).Cacheable();
         }
@@ -750,39 +745,6 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Repository
             return list;
         }
 
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <param name="parameters">参数</param>
-        /// <returns>泛型集合</returns>
-        public virtual IQueryable<T> SqlQuery(string sql, params SqlParameter[] parameters)
-        {
-            return DataContext.Set<T>().FromSql(sql, parameters);
-        }
-
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="sql"></param>
-        /// <param name="parameters">参数</param>
-        public IEnumerable<TS> SqlQuery<TS>(string sql, object parameters)
-        {
-            var raw = DbConnection.Query<TS>(sql, parameters);
-            return raw;
-        }
-
-        /// <summary>
-        /// 执行DML语句
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <param name="parameters"></param>
-        public virtual void ExecuteSql(string sql, params SqlParameter[] parameters)
-        {
-            DataContext.Database.ExecuteSqlCommand(sql, parameters);
-        }
-
         public override void Dispose(bool disposing)
         {
             DataContext?.Dispose();

+ 2 - 25
src/Masuit.MyBlogs.Core/Infrastructure/Repository/Interface/IBaseRepository.cs

@@ -2,7 +2,6 @@
 using Masuit.MyBlogs.Core.Models.Entity;
 using System;
 using System.Collections.Generic;
-using System.Data.SqlClient;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Threading.Tasks;
@@ -83,7 +82,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Repository.Interface
         /// <param name="orderby">排序字段</param>
         /// <param name="isAsc">是否升序</param>
         /// <returns>还未执行的SQL语句</returns>
-        IEnumerable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true);
+        EFCachedQueryable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true);
 
         /// <summary>
         /// 获取所有实体
@@ -508,29 +507,6 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Repository.Interface
         /// <returns>添加成功</returns>
         IEnumerable<T> AddEntities(IList<T> list);
 
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="sql"></param>
-        /// <param name="parameters">参数</param>
-        IQueryable<T> SqlQuery(string sql, params SqlParameter[] parameters);
-
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="sql"></param>
-        /// <param name="parameters">参数</param>
-        IEnumerable<TS> SqlQuery<TS>(string sql, object parameters);
-
-        /// <summary>
-        /// 执行DML语句
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <param name="parameters"></param>
-        void ExecuteSql(string sql, params SqlParameter[] parameters);
-
         void Dispose(bool disposing);
     }
 
@@ -573,5 +549,6 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Repository.Interface
     public partial interface IUserInfoRepository : IBaseRepository<UserInfo> { }
     public partial interface ISeminarPostRepository : IBaseRepository<SeminarPost> { }
     public partial interface ISeminarPostHistoryVersionRepository : IBaseRepository<SeminarPostHistoryVersion> { }
+    public partial interface IBannerRepository : IBaseRepository<Banner> { }
 
 }

+ 1 - 2
src/Masuit.MyBlogs.Core/Infrastructure/Repository/PostRepository.cs

@@ -1,12 +1,11 @@
 using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
 using Masuit.MyBlogs.Core.Models.Entity;
-using System.Data;
 
 namespace Masuit.MyBlogs.Core.Infrastructure.Repository
 {
     public partial class PostRepository : BaseRepository<Post>, IPostRepository
     {
-        public PostRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public PostRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }

+ 43 - 21
src/Masuit.MyBlogs.Core/Infrastructure/Repository/Repositories.cs

@@ -1,129 +1,151 @@
 using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
 using Masuit.MyBlogs.Core.Models.Entity;
-using System.Data;
 
 namespace Masuit.MyBlogs.Core.Infrastructure.Repository
 {
     public partial class BroadcastRepository : BaseRepository<Broadcast>, IBroadcastRepository
     {
-        public BroadcastRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public BroadcastRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class CategoryRepository : BaseRepository<Category>, ICategoryRepository
     {
-        public CategoryRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public CategoryRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class CommentRepository : BaseRepository<Comment>, ICommentRepository
     {
-        public CommentRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public CommentRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class DonateRepository : BaseRepository<Donate>, IDonateRepository
     {
-        public DonateRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public DonateRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class FastShareRepository : BaseRepository<FastShare>, IFastShareRepository
     {
-        public FastShareRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public FastShareRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class InternalMessageRepository : BaseRepository<InternalMessage>, IInternalMessageRepository
     {
-        public InternalMessageRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public InternalMessageRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
 
     public partial class LeaveMessageRepository : BaseRepository<LeaveMessage>, ILeaveMessageRepository
     {
-        public LeaveMessageRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public LeaveMessageRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class LinksRepository : BaseRepository<Links>, ILinksRepository
     {
-        public LinksRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public LinksRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class LoginRecordRepository : BaseRepository<LoginRecord>, ILoginRecordRepository
     {
-        public LoginRecordRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public LoginRecordRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class MenuRepository : BaseRepository<Menu>, IMenuRepository
     {
-        public MenuRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public MenuRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class MiscRepository : BaseRepository<Misc>, IMiscRepository
     {
-        public MiscRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public MiscRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class NoticeRepository : BaseRepository<Notice>, INoticeRepository
     {
-        public NoticeRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public NoticeRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
 
     public partial class PostAccessRecordRepository : BaseRepository<PostAccessRecord>, IPostAccessRecordRepository
     {
-        public PostAccessRecordRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public PostAccessRecordRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class PostHistoryVersionRepository : BaseRepository<PostHistoryVersion>, IPostHistoryVersionRepository
     {
-        public PostHistoryVersionRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public PostHistoryVersionRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class SearchDetailsRepository : BaseRepository<SearchDetails>, ISearchDetailsRepository
     {
-        public SearchDetailsRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public SearchDetailsRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class SeminarRepository : BaseRepository<Seminar>, ISeminarRepository
     {
-        public SeminarRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public SeminarRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class SystemSettingRepository : BaseRepository<SystemSetting>, ISystemSettingRepository
     {
-        public SystemSettingRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public SystemSettingRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class UserInfoRepository : BaseRepository<UserInfo>, IUserInfoRepository
     {
-        public UserInfoRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public UserInfoRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
 
     public partial class SeminarPostRepository : BaseRepository<SeminarPost>, ISeminarPostRepository
     {
-        public SeminarPostRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public SeminarPostRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }
+
     public partial class SeminarPostHistoryVersionRepository : BaseRepository<SeminarPostHistoryVersion>, ISeminarPostHistoryVersionRepository
     {
-        public SeminarPostHistoryVersionRepository(DataContext dbContext, IDbConnection connection) : base(dbContext, connection)
+        public SeminarPostHistoryVersionRepository(DataContext dbContext) : base(dbContext)
+        {
+        }
+    }
+
+    public partial class BannerRepository : BaseRepository<Banner>, IBannerRepository
+    {
+        public BannerRepository(DataContext dbContext) : base(dbContext)
         {
         }
     }

+ 3 - 38
src/Masuit.MyBlogs.Core/Infrastructure/Services/BaseService.cs

@@ -4,7 +4,6 @@ using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using System;
 using System.Collections.Generic;
-using System.Data.SqlClient;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Threading.Tasks;
@@ -20,6 +19,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         public virtual IBaseRepository<T> BaseDal { get; set; }
         protected readonly ISearchEngine<DataContext> _searchEngine;
         protected readonly ILuceneIndexSearcher _searcher;
+
         public BaseService(IBaseRepository<T> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher)
         {
             BaseDal = repository;
@@ -126,7 +126,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <param name="orderby">排序字段</param>
         /// <param name="isAsc">是否升序</param>
         /// <returns>还未执行的SQL语句</returns>
-        public virtual IEnumerable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true)
+        public virtual EFCachedQueryable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true)
         {
             return BaseDal.GetAllFromL2CacheNoTracking(orderby, isAsc);
         }
@@ -445,8 +445,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <param name="orderby">orderby Lambda条件表达式</param>
         /// <param name="isAsc">升序降序</param>
         /// <returns>还未执行的SQL语句</returns>
-        public virtual IQueryable<T> LoadPageEntities<TS>(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> where, Expression<Func<T, TS>> orderby,
-            bool isAsc = true)
+        public virtual IQueryable<T> LoadPageEntities<TS>(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> where, Expression<Func<T, TS>> orderby, bool isAsc = true)
         {
             return BaseDal.LoadPageEntities(pageIndex, pageSize, out totalCount, where, orderby, isAsc);
         }
@@ -852,40 +851,6 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
             return entities;
         }
 
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="sql"></param>
-        /// <param name="parameters">参数</param>
-        /// <returns>泛型集合</returns>
-        public virtual IQueryable<T> SqlQuery(string sql, params SqlParameter[] parameters)
-        {
-            return BaseDal.SqlQuery(sql, parameters);
-        }
-
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <typeparam name="TS"></typeparam>
-        /// <param name="sql"></param>
-        /// <param name="parameters">参数</param>
-        /// <returns>泛型集合</returns>
-        public virtual IEnumerable<TS> SqlQuery<TS>(string sql, object parameters = null)
-        {
-            return BaseDal.SqlQuery<TS>(sql, parameters);
-        }
-
-        /// <summary>
-        /// 执行DML语句
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <param name="parameters"></param>
-        public virtual void ExecuteSql(string sql, params SqlParameter[] parameters)
-        {
-            BaseDal.ExecuteSql(sql, parameters);
-        }
-
         /// <summary>
         /// 批量添加实体
         /// </summary>

+ 43 - 6
src/Masuit.MyBlogs.Core/Infrastructure/Services/CommentService.cs

@@ -9,14 +9,40 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
 {
     public partial class CommentService : BaseService<Comment>, ICommentService
     {
+        public CommentService(IBaseRepository<Comment> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher) : base(repository, searchEngine, searcher)
+        {
+        }
+
         /// <summary>
         /// 通过存储过程获得自己以及自己所有的子元素集合
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        public IQueryable<Comment> GetSelfAndAllChildrenCommentsByParentId(int id)
+        public List<Comment> GetSelfAndAllChildrenCommentsByParentId(int id)
         {
-            return SqlQuery("exec sp_getChildrenCommentByParentId " + id);
+            //return SqlQuery("exec sp_getChildrenCommentByParentId " + id);
+            Comment c = GetById(id);
+            var comments = new List<Comment>() { c };
+            GetSelfAndAllChildrenCommentsByParentId(c, comments);
+            return comments;
+        }
+
+        /// <summary>
+        /// 通过存储过程获得自己以及自己所有的子元素集合
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        private void GetSelfAndAllChildrenCommentsByParentId(Comment comment, List<Comment> list)
+        {
+            var comments = LoadEntitiesFromL2CacheNoTracking(x => x.ParentId == comment.Id).ToList();
+            if (comments.Any())
+            {
+                list.AddRange(comments);
+                foreach (var c in comments)
+                {
+                    GetSelfAndAllChildrenCommentsByParentId(c, list);
+                }
+            }
         }
 
         /// <summary>
@@ -26,16 +52,27 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         public int GetParentCommentIdByChildId(int id)
         {
-            IEnumerable<int> raw = SqlQuery<int>("exec sp_getParentCommentIdByChildId " + id);
-            if (raw.Any())
+            Comment comment = GetById(id);
+            if (comment != null)
             {
-                return raw.FirstOrDefault();
+                return GetParentCommentIdByChildId(comment);
             }
             return 0;
         }
 
-        public CommentService(IBaseRepository<Comment> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher) : base(repository, searchEngine, searcher)
+        /// <summary>
+        /// 根据无级子级找顶级父级评论id
+        /// </summary>
+        /// <param name="com"></param>
+        /// <returns></returns>
+        private int GetParentCommentIdByChildId(Comment com)
         {
+            Comment comment = GetFirstEntity(c => c.Id == com.ParentId);
+            if (comment != null)
+            {
+                return GetParentCommentIdByChildId(comment);
+            }
+            return com.Id;
         }
     }
 }

+ 1 - 25
src/Masuit.MyBlogs.Core/Infrastructure/Services/Interface/IBaseService.cs

@@ -1,7 +1,6 @@
 using EFSecondLevelCache.Core;
 using System;
 using System.Collections.Generic;
-using System.Data.SqlClient;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Threading.Tasks;
@@ -82,7 +81,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services.Interface
         /// <param name="orderby">排序字段</param>
         /// <param name="isAsc">是否升序</param>
         /// <returns>还未执行的SQL语句</returns>
-        IEnumerable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true);
+        EFCachedQueryable<T> GetAllFromL2CacheNoTracking<TS>(Expression<Func<T, TS>> @orderby, bool isAsc = true);
 
         /// <summary>
         /// 获取所有实体
@@ -598,29 +597,6 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services.Interface
         /// <returns>添加成功</returns>
         Task<IEnumerable<T>> AddEntitiesAsync(IList<T> list);
 
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="sql"></param>
-        /// <param name="parameters">参数</param>
-        IQueryable<T> SqlQuery(string sql, params SqlParameter[] parameters);
-
-        /// <summary>
-        /// 执行查询语句
-        /// </summary>
-        /// <typeparam name="TS"></typeparam>
-        /// <param name="sql"></param>
-        /// <param name="parameters"></param>
-        /// <returns></returns>
-        IEnumerable<TS> SqlQuery<TS>(string sql, object parameters = null);
-        /// <summary>
-        /// 执行DML语句
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <param name="parameters"></param>
-        void ExecuteSql(string sql, params SqlParameter[] parameters);
-
         /// <summary>
         /// 批量添加实体
         /// </summary>

+ 2 - 2
src/Masuit.MyBlogs.Core/Infrastructure/Services/Interface/ICommentService.cs

@@ -1,5 +1,5 @@
 using Masuit.MyBlogs.Core.Models.Entity;
-using System.Linq;
+using System.Collections.Generic;
 
 namespace Masuit.MyBlogs.Core.Infrastructure.Services.Interface
 {
@@ -10,7 +10,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services.Interface
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        IQueryable<Comment> GetSelfAndAllChildrenCommentsByParentId(int id);
+        List<Comment> GetSelfAndAllChildrenCommentsByParentId(int id);
 
         /// <summary>
         /// 根据无级子级找顶级父级评论

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

@@ -30,5 +30,6 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services.Interface
 
     public partial interface ISeminarPostService : IBaseService<SeminarPost> { }
     public partial interface ISeminarPostHistoryVersionService : IBaseService<SeminarPostHistoryVersion> { }
+    public partial interface IBannerService : IBaseService<Banner> { }
 
 }

+ 45 - 5
src/Masuit.MyBlogs.Core/Infrastructure/Services/LeaveMessageService.cs

@@ -9,12 +9,41 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
 {
     public partial class LeaveMessageService : BaseService<LeaveMessage>, ILeaveMessageService
     {
+        public LeaveMessageService(IBaseRepository<LeaveMessage> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher) : base(repository, searchEngine, searcher)
+        {
+        }
+
+        /// <summary>
+        /// 通过存储过程获得自己以及自己所有的子元素集合
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public IEnumerable<LeaveMessage> GetSelfAndAllChildrenMessagesByParentId(int id)
+        {
+            //return SqlQuery<LeaveMessage>("exec sp_getChildrenLeaveMsgByParentId " + id);
+            LeaveMessage c = GetById(id);
+            var msgs = new List<LeaveMessage>() { c };
+            GetSelfAndAllChildrenMessagesByParentId(c, msgs);
+            return msgs;
+        }
+
         /// <summary>
         /// 通过存储过程获得自己以及自己所有的子元素集合
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        public IEnumerable<LeaveMessage> GetSelfAndAllChildrenMessagesByParentId(int id) => SqlQuery<LeaveMessage>("exec sp_getChildrenLeaveMsgByParentId " + id);
+        private void GetSelfAndAllChildrenMessagesByParentId(LeaveMessage msg, List<LeaveMessage> list)
+        {
+            var msgs = LoadEntitiesFromL2CacheNoTracking(x => x.ParentId == msg.Id).ToList();
+            if (msgs.Any())
+            {
+                list.AddRange(msgs);
+                foreach (var c in msgs)
+                {
+                    GetSelfAndAllChildrenMessagesByParentId(c, list);
+                }
+            }
+        }
 
         /// <summary>
         /// 根据无级子级找顶级父级留言id
@@ -23,16 +52,27 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         public int GetParentMessageIdByChildId(int id)
         {
-            var raw = SqlQuery<int>("exec sp_getParentMessageIdByChildId " + id);
-            if (raw.Any())
+            LeaveMessage msg = GetById(id);
+            if (msg != null)
             {
-                return raw.FirstOrDefault();
+                return GetParentMessageIdByChildId(msg);
             }
             return 0;
         }
 
-        public LeaveMessageService(IBaseRepository<LeaveMessage> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher) : base(repository, searchEngine, searcher)
+        /// <summary>
+        /// 根据无级子级找顶级父级评论id
+        /// </summary>
+        /// <param name="m"></param>
+        /// <returns></returns>
+        private int GetParentMessageIdByChildId(LeaveMessage m)
         {
+            LeaveMessage msg = GetFirstEntity(c => c.Id == m.ParentId);
+            if (msg != null)
+            {
+                return GetParentMessageIdByChildId(msg);
+            }
+            return m.Id;
         }
     }
 }

+ 26 - 2
src/Masuit.MyBlogs.Core/Infrastructure/Services/MenuService.cs

@@ -3,11 +3,16 @@ using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.Entity;
 using System.Collections.Generic;
+using System.Linq;
 
 namespace Masuit.MyBlogs.Core.Infrastructure.Services
 {
     public partial class MenuService : BaseService<Menu>, IMenuService
     {
+        public MenuService(IBaseRepository<Menu> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher) : base(repository, searchEngine, searcher)
+        {
+        }
+
         /// <summary>
         /// 通过存储过程获得自己以及自己所有的子元素集合
         /// </summary>
@@ -15,11 +20,30 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         public IEnumerable<Menu> GetChildrenMenusByParentId(int id)
         {
-            return SqlQuery<Menu>("exec sp_getChildrenMenusByParentId " + id);
+            //return SqlQuery<Menu>("exec sp_getChildrenMenusByParentId " + id);
+            Menu c = GetById(id);
+            var menus = new List<Menu>() { c };
+            GetChildrenMenusByParentId(c, menus);
+            return menus;
         }
 
-        public MenuService(IBaseRepository<Menu> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher) : base(repository, searchEngine, searcher)
+        /// <summary>
+        /// 通过存储过程获得自己以及自己所有的子元素集合
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        private void GetChildrenMenusByParentId(Menu menu, List<Menu> list)
         {
+            var menus = LoadEntitiesFromL2CacheNoTracking(x => x.ParentId == menu.Id).ToList();
+            if (menus.Any())
+            {
+                list.AddRange(menus);
+                foreach (var c in menus)
+                {
+                    GetChildrenMenusByParentId(c, list);
+                }
+            }
         }
+
     }
 }

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

@@ -109,4 +109,10 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         {
         }
     }
+    public partial class BannerService : BaseService<Banner>, IBannerService
+    {
+        public BannerService(IBaseRepository<Banner> repository, ISearchEngine<DataContext> searchEngine, ILuceneIndexSearcher searcher) : base(repository, searchEngine, searcher)
+        {
+        }
+    }
 }

+ 3 - 2
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -67,11 +67,12 @@
     <PackageReference Include="AutoMapper" Version="8.0.0" />
     <PackageReference Include="CacheManager.Microsoft.Extensions.Caching.Memory" Version="1.2.0" />
     <PackageReference Include="CacheManager.Serialization.Json" Version="1.2.0" />
-    <PackageReference Include="CSRedisCore" Version="3.0.45" />
+    <PackageReference Include="CSRedisCore" Version="3.0.46" />
     <PackageReference Include="Dapper" Version="1.60.1" />
     <PackageReference Include="EFSecondLevelCache.Core" Version="1.7.1" />
     <PackageReference Include="Hangfire" Version="1.6.23" />
     <PackageReference Include="Hangfire.Autofac" Version="2.3.1" />
+    <PackageReference Include="Hangfire.MemoryStorage" Version="1.6.0" />
     <PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.0" />
     <PackageReference Include="htmldiff.net-core" Version="1.3.6" />
     <PackageReference Include="Microsoft.AspNetCore.App" />
@@ -81,7 +82,7 @@
     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
     <PackageReference Include="WilderMinds.RssSyndication" Version="1.5.0" />
-    <PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.1.56" />
+    <PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.1.58" />
     <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.8.18" />
     <PackageReference Include="Z.ExtensionMethods" Version="2.1.1" />
   </ItemGroup>

+ 96 - 203
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml

@@ -299,6 +299,40 @@
             <param name="total">总条数</param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.AdminController.OnActionExecuting(Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext)">
+            <summary>在调用操作方法前调用。</summary>
+            <param name="filterContext">有关当前请求和操作的信息。</param>
+        </member>
+        <member name="T:Masuit.MyBlogs.Core.Controllers.BannerController">
+            <summary>
+            banner
+            </summary>
+        </member>
+        <member name="P:Masuit.MyBlogs.Core.Controllers.BannerController.BannerService">
+            <summary>
+            bannerService
+            </summary>
+        </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.BannerController.Get">
+            <summary>
+            获取全部
+            </summary>
+            <returns></returns>
+        </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.BannerController.Save(Masuit.MyBlogs.Core.Models.Entity.Banner)">
+            <summary>
+            保存banner
+            </summary>
+            <param name="banner"></param>
+            <returns></returns>
+        </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.BannerController.Delete(System.Int32)">
+            <summary>
+            删除banner
+            </summary>
+            <param name="id"></param>
+            <returns></returns>
+        </member>
         <member name="T:Masuit.MyBlogs.Core.Controllers.BaseController">
             <summary>
             基本父控制器
@@ -696,16 +730,10 @@
             快速分享
             </summary>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.HomeController.#ctor(Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IPostService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.ICategoryService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.ISearchDetailsService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.INoticeService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IPostAccessRecordService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IFastShareService)">
+        <member name="P:Masuit.MyBlogs.Core.Controllers.HomeController.BannerService">
             <summary>
-            首页
+            banner
             </summary>
-            <param name="postService"></param>
-            <param name="categoryService"></param>
-            <param name="searchDetailsService"></param>
-            <param name="noticeService"></param>
-            <param name="postAccessRecordService"></param>
-            <param name="fastShareService"></param>
         </member>
         <member name="M:Masuit.MyBlogs.Core.Controllers.HomeController.Index(Masuit.MyBlogs.Core.Models.Enum.OrderBy)">
             <summary>
@@ -1423,32 +1451,6 @@
             <param name="schedule"></param>
             <returns></returns>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.PostController.GetTops">
-            <summary>
-            获取头图文章
-            </summary>
-            <returns></returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.PostController.GetNotTops">
-            <summary>
-            获取非头图页文章
-            </summary>
-            <returns></returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.PostController.AddTop(Masuit.MyBlogs.Core.Models.DTO.PostOutputDto)">
-            <summary>
-            添加头图页
-            </summary>
-            <param name="p"></param>
-            <returns></returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.PostController.RemoveTop(System.Int32)">
-            <summary>
-            取消头图页
-            </summary>
-            <param name="id"></param>
-            <returns></returns>
-        </member>
         <member name="M:Masuit.MyBlogs.Core.Controllers.PostController.AddSeminar(System.Int32,System.Int32)">
             <summary>
             添加专题
@@ -2237,50 +2239,6 @@
             </summary>
             <param name="next"></param>
         </member>
-        <member name="T:Masuit.MyBlogs.Core.Extensions.SessionExt">
-            <summary>
-            session扩展
-            </summary>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Extensions.SessionExt.SetByRedis``1(Microsoft.AspNetCore.Http.ISession,System.String,``0,System.Int32)">
-            <summary>
-            将Session存到Redis,需要先在config中配置链接字符串,连接字符串在config配置文件中的ConnectionStrings节下配置,name固定为RedisHosts,值的格式:127.0.0.1:6379,allowadmin=true,若未正确配置,将按默认值“127.0.0.1:6379,allowadmin=true”进行操作,如:<br/>
-            &lt;connectionStrings&gt;<br/>
-                 &lt;add name = "RedisHosts" connectionString="127.0.0.1:6379,allowadmin=true"/&gt;<br/>
-            &lt;/connectionStrings&gt;
-            </summary>
-            <typeparam name="T"></typeparam>
-            <param name="session"></param>
-            <param name="key">键</param>
-            <param name="obj">需要存的对象</param>
-            <param name="expire">过期时间,默认20分钟</param>
-            <returns></returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Extensions.SessionExt.GetByRedis``1(Microsoft.AspNetCore.Http.ISession,System.String,System.Int32)">
-            <summary>
-            从Redis取Session
-            </summary>
-            <typeparam name="T"></typeparam>
-            <param name="session"></param>
-            <param name="key">键</param>
-            <param name="expire">过期时间,默认20分钟</param>
-            <returns></returns> 
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Extensions.SessionExt.RemoveByRedis(Microsoft.AspNetCore.Http.ISession,System.String)">
-            <summary>
-            从Redis移除对应键的Session
-            </summary>
-            <param name="session"></param>
-            <param name="key"></param>
-            <returns></returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Extensions.SessionExt.SessionCount(Microsoft.AspNetCore.Http.ISession)">
-            <summary>
-            Session个数
-            </summary>
-            <param name="session"></param>
-            <returns></returns>
-        </member>
         <member name="T:Masuit.MyBlogs.Core.Extensions.UEditor.ConfigHandler">
             <summary>
             Config 的摘要说明
@@ -2956,29 +2914,6 @@
             <param name="list">实体集合</param>
             <returns>添加成功</returns>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Repository.BaseRepository`1.SqlQuery(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行查询语句
-            </summary>
-            <param name="sql"></param>
-            <param name="parameters">参数</param>
-            <returns>泛型集合</returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Repository.BaseRepository`1.SqlQuery``1(System.String,System.Object)">
-            <summary>
-            执行查询语句
-            </summary>
-            <typeparam name="T"></typeparam>
-            <param name="sql"></param>
-            <param name="parameters">参数</param>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Repository.BaseRepository`1.ExecuteSql(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行DML语句
-            </summary>
-            <param name="sql"></param>
-            <param name="parameters"></param>
-        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Repository.Interface.IBaseRepository`1.GetAll">
             <summary>
             获取所有实体
@@ -3476,29 +3411,6 @@
             <param name="list">实体集合</param>
             <returns>添加成功</returns>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Repository.Interface.IBaseRepository`1.SqlQuery(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行查询语句
-            </summary>
-            <typeparam name="T"></typeparam>
-            <param name="sql"></param>
-            <param name="parameters">参数</param>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Repository.Interface.IBaseRepository`1.SqlQuery``1(System.String,System.Object)">
-            <summary>
-            执行查询语句
-            </summary>
-            <typeparam name="T"></typeparam>
-            <param name="sql"></param>
-            <param name="parameters">参数</param>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Repository.Interface.IBaseRepository`1.ExecuteSql(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行DML语句
-            </summary>
-            <param name="sql"></param>
-            <param name="parameters"></param>
-        </member>
         <member name="T:Masuit.MyBlogs.Core.Infrastructure.Services.BaseService`1">
             <summary>
             业务层基类
@@ -4094,31 +4006,6 @@
             <param name="list">实体集合</param>
             <returns>添加成功</returns>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.BaseService`1.SqlQuery(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行查询语句
-            </summary>
-            <typeparam name="T"></typeparam>
-            <param name="sql"></param>
-            <param name="parameters">参数</param>
-            <returns>泛型集合</returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.BaseService`1.SqlQuery``1(System.String,System.Object)">
-            <summary>
-            执行查询语句
-            </summary>
-            <typeparam name="TS"></typeparam>
-            <param name="sql"></param>
-            <param name="parameters">参数</param>
-            <returns>泛型集合</returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.BaseService`1.ExecuteSql(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行DML语句
-            </summary>
-            <param name="sql"></param>
-            <param name="parameters"></param>
-        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.BaseService`1.BulkInsert(System.Collections.Generic.IEnumerable{`0})">
             <summary>
             批量添加实体
@@ -4145,6 +4032,13 @@
             <param name="id"></param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.CommentService.GetSelfAndAllChildrenCommentsByParentId(Masuit.MyBlogs.Core.Models.Entity.Comment,System.Collections.Generic.List{Masuit.MyBlogs.Core.Models.Entity.Comment})">
+            <summary>
+            通过存储过程获得自己以及自己所有的子元素集合
+            </summary>
+            <param name="id"></param>
+            <returns></returns>
+        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.CommentService.GetParentCommentIdByChildId(System.Int32)">
             <summary>
             根据无级子级找顶级父级评论id
@@ -4152,6 +4046,13 @@
             <param name="id"></param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.CommentService.GetParentCommentIdByChildId(Masuit.MyBlogs.Core.Models.Entity.Comment)">
+            <summary>
+            根据无级子级找顶级父级评论id
+            </summary>
+            <param name="com"></param>
+            <returns></returns>
+        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IBaseService`1.GetAll">
             <summary>
             获取所有实体
@@ -4741,30 +4642,6 @@
             <param name="list">实体集合</param>
             <returns>添加成功</returns>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IBaseService`1.SqlQuery(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行查询语句
-            </summary>
-            <typeparam name="T"></typeparam>
-            <param name="sql"></param>
-            <param name="parameters">参数</param>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IBaseService`1.SqlQuery``1(System.String,System.Object)">
-            <summary>
-            执行查询语句
-            </summary>
-            <typeparam name="TS"></typeparam>
-            <param name="sql"></param>
-            <param name="parameters"></param>
-            <returns></returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IBaseService`1.ExecuteSql(System.String,System.Data.SqlClient.SqlParameter[])">
-            <summary>
-            执行DML语句
-            </summary>
-            <param name="sql"></param>
-            <param name="parameters"></param>
-        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IBaseService`1.BulkInsert(System.Collections.Generic.IEnumerable{`0})">
             <summary>
             批量添加实体
@@ -4877,6 +4754,13 @@
             <param name="id"></param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.LeaveMessageService.GetSelfAndAllChildrenMessagesByParentId(Masuit.MyBlogs.Core.Models.Entity.LeaveMessage,System.Collections.Generic.List{Masuit.MyBlogs.Core.Models.Entity.LeaveMessage})">
+            <summary>
+            通过存储过程获得自己以及自己所有的子元素集合
+            </summary>
+            <param name="id"></param>
+            <returns></returns>
+        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.LeaveMessageService.GetParentMessageIdByChildId(System.Int32)">
             <summary>
             根据无级子级找顶级父级留言id
@@ -4884,6 +4768,13 @@
             <param name="id"></param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.LeaveMessageService.GetParentMessageIdByChildId(Masuit.MyBlogs.Core.Models.Entity.LeaveMessage)">
+            <summary>
+            根据无级子级找顶级父级评论id
+            </summary>
+            <param name="m"></param>
+            <returns></returns>
+        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.MenuService.GetChildrenMenusByParentId(System.Int32)">
             <summary>
             通过存储过程获得自己以及自己所有的子元素集合
@@ -4891,6 +4782,13 @@
             <param name="id"></param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.MenuService.GetChildrenMenusByParentId(Masuit.MyBlogs.Core.Models.Entity.Menu,System.Collections.Generic.List{Masuit.MyBlogs.Core.Models.Entity.Menu})">
+            <summary>
+            通过存储过程获得自己以及自己所有的子元素集合
+            </summary>
+            <param name="id"></param>
+            <returns></returns>
+        </member>
         <member name="M:Masuit.MyBlogs.Core.Infrastructure.Services.PostService.AddEntitySaved(Masuit.MyBlogs.Core.Models.Entity.Post)">
             <summary>
             添加实体并保存
@@ -5759,21 +5657,6 @@
             反对数
             </summary>
         </member>
-        <member name="P:Masuit.MyBlogs.Core.Models.DTO.PostOutputDto.IsBanner">
-            <summary>
-            是否是头图文章
-            </summary>
-        </member>
-        <member name="P:Masuit.MyBlogs.Core.Models.DTO.PostOutputDto.Description">
-            <summary>
-            描述
-            </summary>
-        </member>
-        <member name="P:Masuit.MyBlogs.Core.Models.DTO.PostOutputDto.ImageUrl">
-            <summary>
-            图片地址
-            </summary>
-        </member>
         <member name="P:Masuit.MyBlogs.Core.Models.DTO.PostOutputDto.CommentCount">
             <summary>
             评论数
@@ -5964,6 +5847,31 @@
             用户头像
             </summary>
         </member>
+        <member name="T:Masuit.MyBlogs.Core.Models.Entity.Banner">
+            <summary>
+            banner
+            </summary>
+        </member>
+        <member name="P:Masuit.MyBlogs.Core.Models.Entity.Banner.Title">
+            <summary>
+            标题
+            </summary>
+        </member>
+        <member name="P:Masuit.MyBlogs.Core.Models.Entity.Banner.Description">
+            <summary>
+            描述
+            </summary>
+        </member>
+        <member name="P:Masuit.MyBlogs.Core.Models.Entity.Banner.Url">
+            <summary>
+            banner指向地址
+            </summary>
+        </member>
+        <member name="P:Masuit.MyBlogs.Core.Models.Entity.Banner.ImageUrl">
+            <summary>
+            图片地址
+            </summary>
+        </member>
         <member name="T:Masuit.MyBlogs.Core.Models.Entity.BaseEntity">
             <summary>
             基类型
@@ -6444,21 +6352,6 @@
             反对数
             </summary>
         </member>
-        <member name="P:Masuit.MyBlogs.Core.Models.Entity.Post.IsBanner">
-            <summary>
-            是否是头图文章
-            </summary>
-        </member>
-        <member name="P:Masuit.MyBlogs.Core.Models.Entity.Post.Description">
-            <summary>
-            描述
-            </summary>
-        </member>
-        <member name="P:Masuit.MyBlogs.Core.Models.Entity.Post.ImageUrl">
-            <summary>
-            图片地址
-            </summary>
-        </member>
         <member name="P:Masuit.MyBlogs.Core.Models.Entity.Post.AverageViewCount">
             <summary>
             每日平均访问量

+ 51 - 52
src/Masuit.MyBlogs.Core/Migrations/20190303120416_Init.Designer.cs → src/Masuit.MyBlogs.Core/Migrations/20190321050816_Init.Designer.cs

@@ -1,30 +1,55 @@
 // <auto-generated />
+using System;
 using Masuit.MyBlogs.Core.Infrastructure;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
 using Microsoft.EntityFrameworkCore.Migrations;
-using System;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
 
 namespace Masuit.MyBlogs.Core.Migrations
 {
     [DbContext(typeof(DataContext))]
-    [Migration("20190303120416_Init")]
+    [Migration("20190321050816_Init")]
     partial class Init
     {
         protected override void BuildTargetModel(ModelBuilder modelBuilder)
         {
 #pragma warning disable 612, 618
             modelBuilder
-                .HasAnnotation("ProductVersion", "2.2.2-servicing-10034")
-                .HasAnnotation("Relational:MaxIdentifierLength", 128)
-                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                .HasAnnotation("ProductVersion", "2.2.3-servicing-35854")
+                .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+            modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Banner", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd();
+
+                    b.Property<string>("Description")
+                        .IsRequired()
+                        .HasMaxLength(255);
+
+                    b.Property<string>("ImageUrl")
+                        .IsRequired()
+                        .HasMaxLength(255);
+
+                    b.Property<int>("Status");
+
+                    b.Property<string>("Title")
+                        .IsRequired();
+
+                    b.Property<string>("Url")
+                        .IsRequired()
+                        .HasMaxLength(255);
+
+                    b.HasKey("Id");
+
+                    b.ToTable("Banner");
+                });
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Broadcast", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Email");
 
@@ -44,8 +69,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Category", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Description");
 
@@ -63,8 +87,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Comment", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<int>("AgainstCount");
 
@@ -109,8 +132,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Donate", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Amount");
 
@@ -138,8 +160,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.FastShare", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Link");
 
@@ -157,8 +178,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.InternalMessage", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Content");
 
@@ -180,8 +200,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.LeaveMessage", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Browser")
                         .HasMaxLength(255);
@@ -217,8 +236,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Links", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<bool>("Except");
 
@@ -240,8 +258,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.LoginRecord", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("IP");
 
@@ -267,8 +284,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Menu", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Icon");
 
@@ -296,8 +312,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Misc", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Content")
                         .IsRequired();
@@ -319,8 +334,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Notice", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Content")
                         .IsRequired();
@@ -344,8 +358,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Post", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Author")
                         .IsRequired()
@@ -358,20 +371,12 @@ namespace Masuit.MyBlogs.Core.Migrations
                     b.Property<string>("Content")
                         .IsRequired();
 
-                    b.Property<string>("Description")
-                        .HasMaxLength(255);
-
                     b.Property<string>("Email")
                         .IsRequired()
                         .IsUnicode(true);
 
                     b.Property<string>("IP");
 
-                    b.Property<string>("ImageUrl")
-                        .HasMaxLength(255);
-
-                    b.Property<bool>("IsBanner");
-
                     b.Property<bool>("IsFixedTop");
 
                     b.Property<bool>("IsWordDocument");
@@ -413,8 +418,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.PostAccessRecord", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<DateTime>("AccessTime");
 
@@ -434,8 +438,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.PostHistoryVersion", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<int>("CategoryId");
 
@@ -478,8 +481,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.SearchDetails", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("IP");
 
@@ -497,8 +499,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Seminar", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Description")
                         .IsRequired();
@@ -548,8 +549,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.SystemSetting", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("Name")
                         .IsRequired();
@@ -567,8 +567,7 @@ namespace Masuit.MyBlogs.Core.Migrations
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.UserInfo", b =>
                 {
                     b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                        .ValueGeneratedOnAdd();
 
                     b.Property<string>("AccessToken");
 

+ 35 - 23
src/Masuit.MyBlogs.Core/Migrations/20190303120416_Init.cs → src/Masuit.MyBlogs.Core/Migrations/20190321050816_Init.cs

@@ -8,9 +8,22 @@ namespace Masuit.MyBlogs.Core.Migrations
     {
         protected override void Up(MigrationBuilder migrationBuilder)
         {
+            migrationBuilder.CreateTable(name: "Banner", columns: table => new
+            {
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+                Status = table.Column<int>(nullable: false),
+                Title = table.Column<string>(nullable: false),
+                Description = table.Column<string>(maxLength: 255, nullable: false),
+                Url = table.Column<string>(maxLength: 255, nullable: false),
+                ImageUrl = table.Column<string>(maxLength: 255, nullable: false)
+            }, constraints: table =>
+            {
+                table.PrimaryKey("PK_Banner", x => x.Id);
+            });
+
             migrationBuilder.CreateTable(name: "Broadcast", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Email = table.Column<string>(nullable: true),
                 ValidateCode = table.Column<string>(nullable: true),
@@ -23,7 +36,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Category", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Name = table.Column<string>(maxLength: 64, nullable: false),
                 Description = table.Column<string>(nullable: true)
@@ -34,7 +47,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Donate", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 NickName = table.Column<string>(nullable: true),
                 Email = table.Column<string>(nullable: true),
@@ -51,7 +64,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "FastShare", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Title = table.Column<string>(nullable: true),
                 Link = table.Column<string>(nullable: true),
@@ -63,7 +76,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "InternalMessage", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Title = table.Column<string>(nullable: true),
                 Content = table.Column<string>(nullable: true),
@@ -77,7 +90,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "LeaveMessage", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 NickName = table.Column<string>(nullable: false),
                 Content = table.Column<string>(nullable: false),
@@ -96,7 +109,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Links", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Name = table.Column<string>(nullable: false),
                 Url = table.Column<string>(nullable: false),
@@ -109,7 +122,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Menu", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Name = table.Column<string>(nullable: false),
                 Icon = table.Column<string>(nullable: true),
@@ -125,7 +138,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Misc", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Title = table.Column<string>(nullable: false),
                 Content = table.Column<string>(nullable: false),
@@ -138,7 +151,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Notice", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Title = table.Column<string>(nullable: false),
                 Content = table.Column<string>(nullable: false),
@@ -152,7 +165,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "SearchDetails", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 KeyWords = table.Column<string>(nullable: false),
                 SearchTime = table.Column<DateTime>(nullable: false),
                 IP = table.Column<string>(nullable: true)
@@ -163,7 +176,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Seminar", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Title = table.Column<string>(nullable: false),
                 SubTitle = table.Column<string>(nullable: true),
@@ -175,7 +188,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "SystemSetting", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Name = table.Column<string>(nullable: false),
                 Value = table.Column<string>(nullable: false)
@@ -186,7 +199,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "UserInfo", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Username = table.Column<string>(nullable: false),
                 NickName = table.Column<string>(nullable: false),
@@ -204,7 +217,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Post", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Title = table.Column<string>(nullable: false),
                 Author = table.Column<string>(maxLength: 24, nullable: false),
@@ -221,9 +234,6 @@ namespace Masuit.MyBlogs.Core.Migrations
                 Keyword = table.Column<string>(maxLength: 256, nullable: true),
                 VoteUpCount = table.Column<int>(nullable: false),
                 VoteDownCount = table.Column<int>(nullable: false),
-                IsBanner = table.Column<bool>(nullable: false),
-                Description = table.Column<string>(maxLength: 255, nullable: true),
-                ImageUrl = table.Column<string>(maxLength: 255, nullable: true),
                 AverageViewCount = table.Column<double>(nullable: false),
                 TotalViewCount = table.Column<int>(nullable: false),
                 IP = table.Column<string>(nullable: true)
@@ -235,7 +245,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "LoginRecord", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 IP = table.Column<string>(nullable: true),
                 LoginTime = table.Column<DateTime>(nullable: false),
@@ -251,7 +261,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "Comment", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 NickName = table.Column<string>(maxLength: 24, nullable: false),
                 Email = table.Column<string>(nullable: true),
@@ -274,7 +284,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "PostAccessRecord", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 PostId = table.Column<int>(nullable: false),
                 AccessTime = table.Column<DateTime>(nullable: false),
@@ -287,7 +297,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             migrationBuilder.CreateTable(name: "PostHistoryVersion", columns: table => new
             {
-                Id = table.Column<int>(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+                Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                 Status = table.Column<int>(nullable: false),
                 Title = table.Column<string>(maxLength: 64, nullable: false),
                 Content = table.Column<string>(nullable: false),
@@ -333,7 +343,7 @@ namespace Masuit.MyBlogs.Core.Migrations
                     x.Seminar_Id,
                     x.PostHistoryVersion_Id
                 });
-                table.ForeignKey(name: "FK_SeminarPostHistoryVersion_PostHistoryVersion_PostHistoryVersion_Id", column: x => x.PostHistoryVersion_Id, principalTable: "PostHistoryVersion", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
+                table.ForeignKey(name: "FK_SeminarPostHistoryVersion_PostHistoryVersion_PostHistoryVers~", column: x => x.PostHistoryVersion_Id, principalTable: "PostHistoryVersion", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
                 table.ForeignKey(name: "FK_SeminarPostHistoryVersion_Seminar_Seminar_Id", column: x => x.Seminar_Id, principalTable: "Seminar", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
             });
 
@@ -356,6 +366,8 @@ namespace Masuit.MyBlogs.Core.Migrations
 
         protected override void Down(MigrationBuilder migrationBuilder)
         {
+            migrationBuilder.DropTable(name: "Banner");
+
             migrationBuilder.DropTable(name: "Broadcast");
 
             migrationBuilder.DropTable(name: "Comment");

+ 39 - 27
src/Masuit.MyBlogs.Core/Migrations/DataContextModelSnapshot.cs

@@ -3,7 +3,6 @@
 using Masuit.MyBlogs.Core.Infrastructure;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
 using System;
 
 namespace Masuit.MyBlogs.Core.Migrations
@@ -14,11 +13,30 @@ namespace Masuit.MyBlogs.Core.Migrations
         protected override void BuildModel(ModelBuilder modelBuilder)
         {
 #pragma warning disable 612, 618
-            modelBuilder.HasAnnotation("ProductVersion", "2.2.2-servicing-10034").HasAnnotation("Relational:MaxIdentifierLength", 128).HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+            modelBuilder.HasAnnotation("ProductVersion", "2.2.3-servicing-35854").HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+            modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Banner", b =>
+            {
+                b.Property<int>("Id").ValueGeneratedOnAdd();
+
+                b.Property<string>("Description").IsRequired().HasMaxLength(255);
+
+                b.Property<string>("ImageUrl").IsRequired().HasMaxLength(255);
+
+                b.Property<int>("Status");
+
+                b.Property<string>("Title").IsRequired();
+
+                b.Property<string>("Url").IsRequired().HasMaxLength(255);
+
+                b.HasKey("Id");
+
+                b.ToTable("Banner");
+            });
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Broadcast", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Email");
 
@@ -37,7 +55,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Category", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Description");
 
@@ -52,7 +70,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Comment", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<int>("AgainstCount");
 
@@ -91,7 +109,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Donate", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Amount");
 
@@ -118,7 +136,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.FastShare", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Link");
 
@@ -135,7 +153,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.InternalMessage", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Content");
 
@@ -156,7 +174,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.LeaveMessage", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Browser").HasMaxLength(255);
 
@@ -187,7 +205,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Links", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<bool>("Except");
 
@@ -206,7 +224,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.LoginRecord", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("IP");
 
@@ -231,7 +249,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Menu", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Icon");
 
@@ -256,7 +274,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Misc", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Content").IsRequired();
 
@@ -275,7 +293,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Notice", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Content").IsRequired();
 
@@ -296,7 +314,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Post", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Author").IsRequired().HasMaxLength(24);
 
@@ -306,16 +324,10 @@ namespace Masuit.MyBlogs.Core.Migrations
 
                 b.Property<string>("Content").IsRequired();
 
-                b.Property<string>("Description").HasMaxLength(255);
-
                 b.Property<string>("Email").IsRequired().IsUnicode(true);
 
                 b.Property<string>("IP");
 
-                b.Property<string>("ImageUrl").HasMaxLength(255);
-
-                b.Property<bool>("IsBanner");
-
                 b.Property<bool>("IsFixedTop");
 
                 b.Property<bool>("IsWordDocument");
@@ -351,7 +363,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.PostAccessRecord", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<DateTime>("AccessTime");
 
@@ -370,7 +382,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.PostHistoryVersion", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<int>("CategoryId");
 
@@ -407,7 +419,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.SearchDetails", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("IP");
 
@@ -422,7 +434,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.Seminar", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Description").IsRequired();
 
@@ -465,7 +477,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.SystemSetting", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("Name").IsRequired();
 
@@ -480,7 +492,7 @@ namespace Masuit.MyBlogs.Core.Migrations
 
             modelBuilder.Entity("Masuit.MyBlogs.Core.Models.Entity.UserInfo", b =>
             {
-                b.Property<int>("Id").ValueGeneratedOnAdd().HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+                b.Property<int>("Id").ValueGeneratedOnAdd();
 
                 b.Property<string>("AccessToken");
 

+ 0 - 17
src/Masuit.MyBlogs.Core/Models/DTO/PostOutputDto.cs

@@ -1,5 +1,4 @@
 using System;
-using System.ComponentModel.DataAnnotations;
 
 namespace Masuit.MyBlogs.Core.Models.DTO
 {
@@ -93,22 +92,6 @@ namespace Masuit.MyBlogs.Core.Models.DTO
         /// </summary>
         public int VoteDownCount { get; set; }
 
-        /// <summary>
-        /// 是否是头图文章
-        /// </summary>
-        public bool IsBanner { get; set; }
-
-        /// <summary>
-        /// 描述
-        /// </summary>
-        [StringLength(255, ErrorMessage = "描述文本不能超过255个字")]
-        public string Description { get; set; }
-
-        /// <summary>
-        /// 图片地址
-        /// </summary>
-        public string ImageUrl { get; set; }
-
         ///// <summary>
         ///// 评论
         ///// </summary>

+ 36 - 0
src/Masuit.MyBlogs.Core/Models/Entity/Banner.cs

@@ -0,0 +1,36 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace Masuit.MyBlogs.Core.Models.Entity
+{
+    /// <summary>
+    /// banner
+    /// </summary>
+    [Table("Banner")]
+    public class Banner : BaseEntity
+    {
+        /// <summary>
+        /// 标题
+        /// </summary>
+        [Required(ErrorMessage = "Banner标题不能为空!")]
+        public string Title { get; set; }
+
+        /// <summary>
+        /// 描述
+        /// </summary>
+        [Required(ErrorMessage = "banner描述不能为空!"), StringLength(255)]
+        public string Description { get; set; }
+
+        /// <summary>
+        /// banner指向地址
+        /// </summary>
+        [Required(ErrorMessage = "banner目标地址不能为空!"), StringLength(255)]
+        public string Url { get; set; }
+
+        /// <summary>
+        /// 图片地址
+        /// </summary>
+        [Required(ErrorMessage = "banner图片不能为空!"), StringLength(255)]
+        public string ImageUrl { get; set; }
+    }
+}

+ 0 - 18
src/Masuit.MyBlogs.Core/Models/Entity/Post.cs

@@ -112,24 +112,6 @@ namespace Masuit.MyBlogs.Core.Models.Entity
         [DatabaseGenerated(DatabaseGeneratedOption.Computed), DefaultValue(0)]
         public int VoteDownCount { get; set; }
 
-        /// <summary>
-        /// 是否是头图文章
-        /// </summary>
-        [Required]
-        [DefaultValue(false)]
-        public bool IsBanner { get; set; }
-        /// <summary>
-        /// 描述
-        /// </summary>
-        [StringLength(255)]
-        public string Description { get; set; }
-
-        /// <summary>
-        /// 图片地址
-        /// </summary>
-        [StringLength(255)]
-        public string ImageUrl { get; set; }
-
         /// <summary>
         /// 每日平均访问量
         /// </summary>

+ 2 - 1
src/Masuit.MyBlogs.Core/Models/ViewModel/IndexPageViewModel.cs

@@ -1,4 +1,5 @@
 using Masuit.MyBlogs.Core.Models.DTO;
+using Masuit.MyBlogs.Core.Models.Entity;
 using System.Collections.Generic;
 using System.Linq;
 
@@ -67,6 +68,6 @@ namespace Masuit.MyBlogs.Core.Models.ViewModel
         /// <summary>
         /// banner文章
         /// </summary>
-        public List<PostOutputDto> Banner { get; set; }
+        public List<Banner> Banner { get; set; }
     }
 }

+ 8 - 7
src/Masuit.MyBlogs.Core/Startup.cs

@@ -6,6 +6,7 @@ using CSRedis;
 using EFSecondLevelCache.Core;
 using Hangfire;
 using Hangfire.Dashboard;
+using Hangfire.MemoryStorage;
 using JiebaNet.Segmenter;
 using Masuit.LuceneEFCore.SearchEngine;
 using Masuit.LuceneEFCore.SearchEngine.Extensions;
@@ -18,6 +19,7 @@ using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.AspNetCore.Mime;
 using Masuit.Tools.Core.AspNetCore;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Systems;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
@@ -36,8 +38,6 @@ using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 using Swashbuckle.AspNetCore.Swagger;
 using System;
-using System.Data;
-using System.Data.SqlClient;
 using System.IO;
 using System.Linq;
 using System.Reflection;
@@ -82,9 +82,9 @@ namespace Masuit.MyBlogs.Core
             }); //配置Cookie策略
             services.AddDbContext<DataContext>(opt =>
             {
-                //opt.UseMySql(AppConfig.ConnString);
-                opt.UseSqlServer(AppConfig.ConnString);
-            }).AddTransient<IDbConnection>(p => new SqlConnection(AppConfig.ConnString)); //配置数据库
+                opt.UseMySql(AppConfig.ConnString);
+                //opt.UseSqlServer(AppConfig.ConnString);
+            }); //配置数据库
             services.AddCors(opt =>
             {
                 opt.AddDefaultPolicy(p =>
@@ -116,7 +116,8 @@ namespace Masuit.MyBlogs.Core
             }); //配置请求长度
 
             services.AddSession(); //注入Session
-            services.AddHangfire(x => x.UseRedisStorage(AppConfig.Redis)); //配置hangfire
+            //services.AddHangfire(x => x.UseRedisStorage(AppConfig.Redis)); //配置hangfire
+            services.AddHangfire(x => x.UseMemoryStorage()); //配置hangfire
 
             services.AddSevenZipCompressor().AddResumeFileResult().AddSearchEngine<DataContext>(new LuceneIndexerOptions() { Path = "lucene" });// 配置7z和断点续传和Redis和Lucene搜索引擎
             RedisHelper.Initialization(new CSRedisClient(AppConfig.Redis));
@@ -259,7 +260,7 @@ namespace Masuit.MyBlogs.Core
 #if DEBUG
             return true;
 #endif
-            UserInfoOutputDto user = context.GetHttpContext().Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+            UserInfoOutputDto user = context.GetHttpContext().Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
             return user.IsAdmin;
         }
     }

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

@@ -1,6 +1,7 @@
 @using Masuit.MyBlogs.Core.Extensions
 @using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.ViewModel
+@using Masuit.Tools.Core.Net
 @model Masuit.MyBlogs.Core.Models.ViewModel.IndexPageViewModel
 @{
     ViewBag.Title = "分类_" + ViewBag.CategoryName;
@@ -48,6 +49,6 @@
     </div>
 </div>
 @{
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
     await Html.RenderPartialAsync(user.IsAdmin ? "_MainContainer_Admin" : "_MainContainer", Model);
 }

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

@@ -3,6 +3,7 @@
 @using Masuit.MyBlogs.Core.Models.Entity
 @using Masuit.MyBlogs.Core.Models.ViewModel
 @using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @using Masuit.Tools.Win32
 @using Microsoft.AspNetCore.Http
 @model Masuit.MyBlogs.Core.Models.ViewModel.IndexPageViewModel
@@ -49,7 +50,7 @@
                             <div class="slide-text @style[r.StrictNext(style.Length)]">
                                 <h2 data-animation="animated @ani[r.StrictNext(ani.Length)]">@p.Title</h2>
                                 <p data-animation="animated @ani[r.StrictNext(ani.Length)]">@p.Description</p>
-                                <a href="/@p.Id" target="_blank" class="btn btn-default" data-animation="animated @ani[r.StrictNext(ani.Length)]">查看详情</a>
+                                <a href="@p.Url" target="_blank" class="btn btn-default" data-animation="animated @ani[r.StrictNext(ani.Length)]">查看详情</a>
                             </div>
                         </div>
                     </div>
@@ -130,7 +131,7 @@
     </div>
 }
 @{
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
     await Html.RenderPartialAsync(user.IsAdmin ? "_MainContainer_Admin" : "_MainContainer", Model);
 }
 <script type="text/javascript">

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

@@ -5,7 +5,7 @@
 }
 @using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.ViewModel
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @model IndexPageViewModel
 <div class="container">
     <ol class="cd-breadcrumb triangle">
@@ -14,6 +14,6 @@
     </ol>
 </div>
 @{
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
     await Html.RenderPartialAsync(user.IsAdmin ? "_MainContainer_Admin" : "_MainContainer", Model);
 }

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

@@ -1,6 +1,6 @@
 @using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.ViewModel
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @model IndexPageViewModel
 @{
     ViewBag.Title = "标签_" + ViewBag.Tag;
@@ -13,6 +13,6 @@
     </ol>
 </div>
 @{
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
     await Html.RenderPartialAsync(user.IsAdmin ? "_MainContainer_Admin" : "_MainContainer", Model);
 }

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Msg/Index_Admin.cshtml

@@ -1,10 +1,10 @@
 @using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.ViewModel
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @{
     ViewBag.Title = "留言板";
     Layout = "~/Views/Shared/_Layout.cshtml";
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
     string cid = string.IsNullOrEmpty(Context.Request.Query["cid"]) ? "0" : Context.Request.Query["cid"].ToString();
 }
 <link href="~/Assets/layui/css/layui.min.css" rel="stylesheet" />

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Notice/Details.cshtml

@@ -2,7 +2,7 @@
 @using Common
 @using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.ViewModel
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @model Masuit.MyBlogs.Core.Models.Entity.Notice
 @{
     ViewBag.Title = Model.Title;
@@ -54,7 +54,7 @@
                     <div class="btn-group">
                         @Html.ActionLink("<<返回公告列表页", "Index", "Notice", null, new { @class = "btn btn-info" })
                         @{
-                            UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+                            UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
                             if (user.IsAdmin)
                             {
                                 <a class="btn btn-primary" href="/dashboard#/notice/[email protected]" target="_blank">修改</a>

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/Details.cshtml

@@ -3,7 +3,7 @@
 @using Common
 @using Masuit.MyBlogs.Core.Models.Entity
 @using Masuit.MyBlogs.Core.Models.Enum
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @using Masuit.Tools.Win32
 @model Masuit.MyBlogs.Core.Models.Entity.Post
 @{
@@ -86,7 +86,7 @@
                             @if (!string.IsNullOrEmpty(Model.ProtectContent))
                             {
                                 <div class="row protected">
-                                    @if (string.IsNullOrEmpty(Context.Session.GetByRedis<string>("ArticleViewToken")))
+                                    @if (string.IsNullOrEmpty(Context.Session.Get<string>("ArticleViewToken")))
                                     {
                                         <p class="text-red text-center size24 margin-bot10">↓↓↓恭喜你发现镇站之宝,请注意,前方高能!非战斗人员请及时撤离,这不是演习!↓↓↓</p>
                                         <div class="col-md-12">

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/Details_Admin.cshtml

@@ -4,7 +4,7 @@
 @using Masuit.MyBlogs.Core.Models.Entity
 @using Masuit.MyBlogs.Core.Models.Enum
 @using Masuit.MyBlogs.Core.Models.ViewModel
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @using Masuit.Tools.Systems
 @using Masuit.Tools.Win32
 @model Masuit.MyBlogs.Core.Models.Entity.Post
@@ -12,7 +12,7 @@
     ViewBag.Title = Model.Title;
     Layout = "~/Views/Shared/_Layout.cshtml";
     string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
     string cid = string.IsNullOrEmpty(Context.Request.Query["cid"]) ? "0" : Context.Request.Query["cid"].ToString();
 }
 <style>

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/HistoryVersion.cshtml

@@ -2,7 +2,7 @@
 @using System.Web
 @using Common
 @using Masuit.MyBlogs.Core.Models.Entity
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @using Masuit.Tools.Win32
 @model Masuit.MyBlogs.Core.Models.Entity.PostHistoryVersion
 @{
@@ -74,7 +74,7 @@
                             @if (!string.IsNullOrEmpty(Model.ProtectContent))
                             {
                                 <div class="row protected">
-                                    @if (string.IsNullOrEmpty(Context.Session.GetByRedis<string>("ArticleViewToken")))
+                                    @if (string.IsNullOrEmpty(Context.Session.Get<string>("ArticleViewToken")))
                                     {
                                         <p class="text-red text-center size24 margin-bot10">↓↓↓恭喜你发现镇站之宝,请注意,前方高能!非战斗人员请及时撤离,这不是演习!↓↓↓</p>
                                         <div class="col-md-6">

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/Publish_Admin.cshtml

@@ -2,13 +2,13 @@
 @using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.Entity
 @using Masuit.MyBlogs.Core.Models.ViewModel
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @using Masuit.Tools.Win32
 @{
     ViewBag.Title = "投稿";
     Layout = "~/Views/Shared/_Layout.cshtml";
     string[] colors = { "success", "info", "warning", "danger", "default" };
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo);
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo);
     List<Category> cats = ViewBag.Category;
 }
 <link href="~/Assets/fileupload/filestyle.css" rel="stylesheet" />

+ 3 - 4
src/Masuit.MyBlogs.Core/Views/Seminar/Index.cshtml

@@ -1,12 +1,11 @@
-@using AngleSharp.Network.Default
-@using Masuit.MyBlogs.Core.Models.DTO
+@using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.ViewModel
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @model IList<Masuit.MyBlogs.Core.Models.DTO.PostOutputDto>
 @{
     Layout = "~/Views/Shared/_Layout.cshtml";
     Random r = new Random();
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
 }
 <style>
     .bg-title {

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Shared/_Layout.cshtml

@@ -3,12 +3,12 @@
 @using Masuit.MyBlogs.Core.Models.Enum
 @using Masuit.MyBlogs.Core.Models.ViewModel
 @using Masuit.Tools
-@using Masuit.MyBlogs.Core.Extensions
+@using Masuit.Tools.Core.Net
 @using Masuit.Tools.Win32
 @{
     string[] colors = { "success", "info", "warning", "danger", "default" };
     IList<MenuOutputDto> menus = ViewBag.menus;
-    UserInfoOutputDto user = Context.Session.GetByRedis<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
+    UserInfoOutputDto user = Context.Session.Get<UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto();
     PageFootViewModel footer = ViewBag.Footer;
 }
 

+ 4 - 4
src/Masuit.MyBlogs.Core/appsettings.json

@@ -1,4 +1,4 @@
-{
+{
     "Logging": {
         "LogLevel": {
             "Default": "Error"
@@ -9,8 +9,8 @@
         "path": "App_Data/cert/server.pfx",
         "password": "cEHlnUGu"
     },
-    //"ConnString": "Server=127.0.0.1;Port=3306;Database=MyBlogs;Uid=root;Pwd=;Charset=utf8mb4",
-    "ConnString": "Data Source=.;Initial Catalog=MyBlogs;Integrated Security=True",
-    "BaiduAK": "ÄúµÄBaiduAK",
+    "ConnString": "Server=127.0.0.1;Port=3306;Database=MyBlogs;Uid=root;Pwd=;Charset=utf8mb4",
+    //"ConnString": "Data Source=.;Initial Catalog=MyBlogs;Integrated Security=True",
+    "BaiduAK": "您的BaiduAK",
     "Redis": "127.0.0.1:6379,allowadmin=true,connectTimeout=20000,connectRetry=1,responseTimeout=20000,syncTimeout=10000"
 }

+ 15 - 31
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/post.js

@@ -662,24 +662,17 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 	$scope.isAdd = true;
 	$scope.allowUpload=false;
 	$scope.loading();
-	$scope.post = {};
+	$scope.banner = {};
 	$scope.getdata = function() {
-		$scope.request("/post/gettops", null, function(data) {
-			$scope.tops = data.Data;
-		});
-		$scope.request("/post/getnottops", null, function(data) {
-			$('#post').select3({
-				allowClear: true,
-				items: data.Data,
-				placeholder: '请选择一篇文章'
-			});
+		$scope.request("/banner/get", null, function(data) {
+			$scope.banners = data.Data;
 		});
 	}
 	$scope.getdata();
-	$scope.remove = function(post) {
+	$scope.remove = function(banner) {
 		swal({
-			title: '确定取消头图页吗?',
-			text: post.Title,
+			title: '确定移除这个banner吗?',
+			text: banner.Title,
 			type: 'warning',
 			showCancelButton: true,
 			confirmButtonColor: '#3085d6',
@@ -689,9 +682,7 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 		}).then(function(isConfirm) {
 			if (isConfirm) {
 				$scope.loading();
-				$scope.request("/post/RemoveTop", {
-					id: post.Id
-				}, function(data) {
+				$scope.request("/banner/delete/"+banner.Id, null, function(data) {
 					swal(data.Message, null, 'success');
 					$scope.getdata();
 				});
@@ -699,12 +690,7 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 		}).catch(swal.noop);
 	}
 	$scope.add = function() {
-		//Custombox.open({
-		//	target: '#modal',
-		//	zIndex: 100,
-		//	height: 900
-		//});
-		$scope.post = {};
+		$scope.banner = {};
 		$scope.isAdd = true;
 		$scope.allowUpload=false;
 		layer.open({
@@ -712,7 +698,6 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 			zIndex: 20,
 			title: '设置头图页文章',
 			area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
-			//area: ['650px', '300px'], //宽高
 			content: $("#modal"),
 			cancel: function(index, layero) {
 				setTimeout(function() {
@@ -723,7 +708,7 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 		});
 	}
 	$scope.edit = function (item) {
-		$scope.post = item;
+		$scope.banner = item;
 		$scope.isAdd = false;
 		$scope.allowUpload=false;
 		layer.open({
@@ -731,7 +716,6 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 			zIndex: 20,
 			title: '设置头图页文章',
 			area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
-			//area: ['650px', '250px'], //宽高
 			content: $("#modal"),
 			cancel: function(index, layero) {
 				setTimeout(function() {
@@ -747,11 +731,11 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 			$("#modal").css("display", "none");
 		}, 500);
 	}
-	$scope.submit = function(post) {
+	$scope.submit = function(banner) {
 		if ($scope.isAdd) {
-			post.Id = $('#post').select3("val");
+			banner.Id = 0;
 		}
-		$scope.request("/post/AddTop", post, function(data) {
+		$scope.request("/banner/save", banner, function(data) {
 			//Custombox.close();
 			$scope.closeAll();
 			window.notie.alert({
@@ -760,8 +744,8 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 				time: 4
 			});
 			$scope.getdata();
-			$scope.post.ImageUrl = "";
-			$scope.post.Description = "";
+			$scope.banner.ImageUrl = "";
+			$scope.banner.Description = "";
 		});
 	}
 	$scope.uploadImage = function() {
@@ -774,7 +758,7 @@ myApp.controller("toppost", ["$scope", "$http", "$location", "$timeout", functio
 				document.getElementById("coverform").reset();
 				$scope.$apply(function () {
 			      $scope.allowUpload=false;
-					$scope.post.ImageUrl = data.Data;
+					$scope.banner.ImageUrl = data.Data;
 			    });
 			}
 		});

+ 19 - 11
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/post/top.html

@@ -13,7 +13,7 @@
     <div class="card-body">
         <div class="card-body card-padding">
             <div class="row">
-                <div class="col-sm-6 col-md-3" ng-repeat="item in tops">
+                <div class="col-sm-6 col-md-3" ng-repeat="item in banners">
                     <div class="card" style="max-height: 500px;overflow: hidden;">
                         <div class="card-header ch-alt">
                             <h4>{{item.Title}}</h4>
@@ -48,30 +48,38 @@
 <div id="modal" class="modal">
     <div class="container-fluid" style="margin: 15px 0;">
         <div class="card-body bgm-white">
-            <div class="form-group" ng-show="isAdd">
+            <div class="form-group">
                 <div class="input-group">
-                    <label for="desc" class="input-group-addon control-label">选择文章:</label>
+                    <label for="desc" class="input-group-addon control-label">banner标题:</label>
                     <div class="fg-line">
-                        <div id="post" class="select3-input example-input form-control"></div>
+                        <input type="text" class="form-control" id="title" placeholder="请输入banner标题" ng-model="banner.Title">
+                    </div>
+                </div>
+            </div>
+            <div class="form-group">
+                <div class="input-group">
+                    <label for="desc" class="input-group-addon control-label">banner地址:</label>
+                    <div class="fg-line">
+                        <input type="text" class="form-control" id="url" placeholder="请输入banner目标地址" ng-model="banner.Url">
                     </div>
                 </div>
             </div>
             <div ng-show="!isAdd">
-                <input type="hidden" ng-model="post.Id">
+                <input type="hidden" ng-model="banner.Id">
             </div>
             <div class="form-group">
                 <div class="input-group">
-                    <label for="desc" class="input-group-addon control-label">文章描述:</label>
+                    <label for="desc" class="input-group-addon control-label">banner描述:</label>
                     <div class="fg-line">
-                        <textarea type="text" class="form-control" id="desc" placeholder="请输入文章描述" ng-model="post.Description" rows="5"></textarea>
+                        <textarea type="text" class="form-control" id="desc" placeholder="请输入banner描述" ng-model="banner.Description" rows="5"></textarea>
                     </div>
                 </div>
             </div>
             <div class="form-group">
                 <div class="input-group">
-                    <label for="desc" class="input-group-addon control-label">文章头图地址:</label>
+                    <label for="desc" class="input-group-addon control-label">banner图片:</label>
                     <div class="fg-line">
-                        <input type="text" class="form-control" id="desc" placeholder="请输入头图URL" ng-model="post.ImageUrl">
+                        <input type="text" class="form-control" id="imgurl" placeholder="请输入头图URL" ng-model="banner.ImageUrl">
                     </div>
                     <span class="input-group-btn">
                         <button class="btn btn-success" ng-click="upload()">上传本地图片</button>
@@ -90,14 +98,14 @@
                             <input type="file" class="uploadFile" name="file" onchange="getFile(this, 'file0')" />
                             <span class="input-group-btn"><button type="button" class="btn btn-primary" ng-click="uploadImage()"> 开始上传图片 </button></span>
                         </div>
-                        </div>
+                    </div>
                 </form>
             </div>
             <div class="form-group">
                 <div class="col-xs-12">
                     <div class="fg-line">
                         <div class="btn-group">
-                            <button type="button" class="btn btn-info" ng-click="submit(post)">
+                            <button type="button" class="btn btn-info" ng-click="submit(banner)">
                                 确认添加
                             </button>
                             <button type="button" class="btn btn-danger" ng-click="closeAll()">