diff --git a/README.md b/README.md index 2537318f..868ac601 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,6 @@

集大成者,终究轮子

[English](README-en.md) | 简体中文 - -![sdk](https://img.shields.io/badge/sdk-8.0.0-d.svg)![License MIT](https://img.shields.io/badge/license-Apache-blue.svg?style=flat-square) - **** ### 简介: YiFramework是一个基于.Net8+Abp.vNext+SqlSugar的DDD领域驱动设计后端开源框架 @@ -59,12 +56,11 @@ Rbac演示地址:https://ccnetcore.com:1000 (用户cc、密码123456) **** ### 详细到爆炸的Yi框架教程导航: -(既然选择开源,就本该怀揣着最纯粹分享的内心,我们全套打包分享,开源包括且不仅仅是:文档、框架代码、模块代码、运维CICD等,希望能够帮助到您) 1. [框架快速开始教程](https://ccnetcore.com/article/aaa00329-7f35-d3fe-d258-3a0f8380b742)(已完成) 2. [框架功能模块教程](https://ccnetcore.com/article/8c464ab3-8ba5-2761-a4b0-3a0f83a9f312)(已完成) 3. [实战演练开发教程](https://ccnetcore.com/article/e89c9593-f337-ada7-d108-3a0f83ae48e6) -4. [橙子运维CICD教程](https://ccnetcore.com/article/6b80ed42-50cd-db15-c073-3a0fa8f7fd77)(已完成) + **** ### 它的理念: diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs index 5afefc8b..ec5df132 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs @@ -7,8 +7,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss public string Title { get; set; } public string? Types { get; set; } public string? Introduction { get; set; } - public int AgreeNum { get; set; } - public int SeeNum { get; set; } public string Content { get; set; } public string? Color { get; set; } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/ArticleEntity.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/ArticleEntity.cs index 21652fc6..a46c8cb4 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/ArticleEntity.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/ArticleEntity.cs @@ -33,6 +33,11 @@ namespace Yi.Framework.Bbs.Domain.Entities public Guid? LastModifierId { get; set; } public DateTime? LastModificationTime { get; set; } + + /// + /// 排序 + /// + public int OrderNum { get; set; } = 0; } public static class ArticleEntityExtensions diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/AbstractArticleImport.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/AbstractArticleImport.cs index c39b5dec..85de471d 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/AbstractArticleImport.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/AbstractArticleImport.cs @@ -3,20 +3,29 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; using Yi.Framework.Bbs.Domain.Entities; using Yi.Framework.Bbs.Domain.Shared.Model; +using Yi.Framework.Core.Data; namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport { public abstract class AbstractArticleImport { - public virtual List Import(Guid discussId,Guid articleParentId, List fileObjs) + public void SetLogger(ILoggerFactory loggerFactory) + { + LoggerFactory = loggerFactory; + } + protected ILoggerFactory LoggerFactory { get; set; } + public virtual List Import(Guid discussId, Guid articleParentId, List fileObjs) { var articles = Convert(fileObjs); + var orderNum = 0; articles.ForEach(article => { article.DiscussId = discussId; article.ParentId = articleParentId; + article.OrderNum = ++orderNum; }); return articles; } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/VuePressArticleImport.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/VuePressArticleImport.cs index 6ebb0626..e6186748 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/VuePressArticleImport.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ArticleImport/VuePressArticleImport.cs @@ -1,8 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; using Yi.Framework.Bbs.Domain.Entities; using Yi.Framework.Bbs.Domain.Shared.Model; @@ -12,6 +13,8 @@ namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport { public override List Convert(List fileObjs) { + var logger = LoggerFactory.CreateLogger(); + //排序及处理目录名称 var fileNameHandler = fileObjs.OrderBy(x => x.FileName).Select(x => { @@ -24,36 +27,44 @@ namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport //处理内容 - var fileContentHandler= fileNameHandler.Select(x => - { - var f = new FileObject { FileName = x.FileName }; - var lines = x.Content.SplitToLines(); + var fileContentHandler = fileNameHandler.Select(x => + { + logger.LogError($"老的值:{x.Content}"); + var f = new FileObject { FileName = x.FileName }; + var lines = x.Content.SplitToLines(); - var num = 0; - var startIndex = 0; - for (int i = 0; i < lines.Length; i++) - { - if (lines[i] == "---") - { - num++; - if (num == 2) - { - startIndex = i; + var num = 0; + var startIndex = 0; + for (int i = 0; i < lines.Length; i++) + { + //编码问题 + if (lines[i] == "---") + { + num++; + if (num == 2) + { + startIndex = i; + break; + } - break; - } + } - } - - } - var linesRef = lines.ToList(); - - linesRef.RemoveRange(0, startIndex+1); - var result = string.Join(Environment.NewLine, linesRef); - f.Content = result; - return f; - }); + } + var linesRef = lines.ToList(); + if (startIndex != 0) + { + linesRef.RemoveRange(0, startIndex + 1); + } + else + { + //去除头部 + linesRef.RemoveRange(0,6); + } + var result = string.Join(Environment.NewLine, linesRef); + f.Content = result; + return f; + }); var output = fileContentHandler.Select(x => new ArticleEntity() { Content = x.Content, Name = x.FileName }).ToList(); return output; diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs index 8e57f5b4..8dc50597 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs @@ -67,7 +67,7 @@ namespace Yi.Framework.Bbs.Domain.Managers default: abstractArticleImport = new DefaultArticleImport(); break; } - + abstractArticleImport.SetLogger(LoggerFactory); var articleHandled = abstractArticleImport.Import(discussId, articleParentId, fileObjs); await _articleRepository.InsertManyAsync(articleHandled); diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.SqlSugarCore/Repositories/ArticleRepository.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.SqlSugarCore/Repositories/ArticleRepository.cs index ea3e47f4..1b0a200c 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.SqlSugarCore/Repositories/ArticleRepository.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.SqlSugarCore/Repositories/ArticleRepository.cs @@ -15,7 +15,7 @@ namespace Yi.Framework.Bbs.SqlSugarCore.Repositories public async Task> GetTreeAsync(Expression> where) { - return await _DbQueryable.Where(where).OrderBy(x=>x.CreationTime).ToTreeAsync(x => x.Children, x => x.ParentId, Guid.Empty); + return await _DbQueryable.Where(where).OrderBy(x=>x.OrderNum).OrderBy(x=>x.CreationTime).ToTreeAsync(x => x.Children, x => x.ParentId, Guid.Empty); } } } diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs index 428bf158..2379373f 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs @@ -2,7 +2,7 @@ using Serilog; using Serilog.Events; using Yi.Abp.Web; -//־,ʹ{SourceContext}¼ +//创建日志,可使用{SourceContext}记录 Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) @@ -15,7 +15,7 @@ Log.Logger = new LoggerConfiguration() try { - Log.Information("Yi-Abp.vNext"); + Log.Information("Yi框架-Abp.vNext,启动!"); var builder = WebApplication.CreateBuilder(args); builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]); @@ -28,7 +28,7 @@ try } catch (Exception ex) { - Log.Fatal(ex, "Yi-Abp.vNextը"); + Log.Fatal(ex, "Yi框架-Abp.vNext,爆炸!"); } finally {