Merge branch 'abp' of https://gitee.com/ccnetcore/Yi into abp
This commit is contained in:
@@ -4,9 +4,6 @@
|
|||||||
<h2 align="center">集大成者,终究轮子</h2>
|
<h2 align="center">集大成者,终究轮子</h2>
|
||||||
|
|
||||||
[English](README-en.md) | 简体中文
|
[English](README-en.md) | 简体中文
|
||||||
|
|
||||||

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