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/Yi.Abp.sln b/Yi.Abp.Net8/Yi.Abp.sln index 2c715929..d7d36b3d 100644 --- a/Yi.Abp.Net8/Yi.Abp.sln +++ b/Yi.Abp.Net8/Yi.Abp.sln @@ -70,7 +70,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Bbs.SqlSugarCo EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "audit-logging", "audit-logging", "{73CCF2C4-B9FD-44AB-8D4B-0A421805B094}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.AuditLogging.SqlSugarCore", "module\audit-logging\Yi.AuditLogging.SqlSugarCore\Yi.AuditLogging.SqlSugarCore.csproj", "{48806510-8E18-4E1E-9BAF-5B97E88C5FC3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.AuditLogging.SqlSugarCore", "module\audit-logging\Yi.AuditLogging.SqlSugarCore\Yi.AuditLogging.SqlSugarCore.csproj", "{48806510-8E18-4E1E-9BAF-5B97E88C5FC3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution 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.Application/Services/Authentication/QQAuthService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Authentication/QQAuthService.cs new file mode 100644 index 00000000..29695fdc --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Authentication/QQAuthService.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Quartz.Logging; +using Volo.Abp; +using Volo.Abp.DependencyInjection; + +namespace Yi.Framework.Bbs.Application.Services.Authentication +{ + public class QQAuthService : IRemoteService, ITransientDependency + { + private HttpContext HttpContext { get; set; } + private ILogger _logger; + public QQAuthService(IHttpContextAccessor httpContextAccessor, ILogger logger) + { + _logger = logger; + HttpContext = httpContextAccessor.HttpContext ?? throw new ApplicationException("未注册Http"); + } + [HttpGet("/auth/qq")] + public async Task AuthQQAsync() + { + var data = await HttpContext.AuthenticateAsync("QQ"); + _logger.LogError($"QQ回调信息:{Newtonsoft.Json.JsonConvert.SerializeObject(data)}"); + _logger.LogError($"QQ回调身份:{Newtonsoft.Json.JsonConvert.SerializeObject(data.Principal)}"); + } + } +} 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 { diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index c8633dae..e26117d2 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -66,7 +66,7 @@ namespace Yi.Abp.Web service.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; - options.SerializerSettings.Converters.Add(new StringEnumConverter()); + options.SerializerSettings.Converters.Add(new StringEnumConverter()); }); Configure(options => @@ -103,33 +103,33 @@ namespace Yi.Abp.Web //jwt鉴权 var jwtOptions = configuration.GetSection(nameof(JwtOptions)).Get(); context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - .AddJwtBearer(options => + .AddJwtBearer(options => + { + options.TokenValidationParameters = new TokenValidationParameters { - options.TokenValidationParameters = new TokenValidationParameters + ClockSkew = TimeSpan.Zero, + ValidateIssuer = true, + ValidateAudience = true, + ValidateLifetime = true, + ValidateIssuerSigningKey = true, + ValidIssuer = jwtOptions.Issuer, + ValidAudience = jwtOptions.Audience, + RequireExpirationTime = true, + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtOptions.SecurityKey)) + }; + options.Events = new JwtBearerEvents + { + OnMessageReceived = context => { - ClockSkew = TimeSpan.Zero, - ValidateIssuer = true, - ValidateAudience = true, - ValidateLifetime = true, - ValidateIssuerSigningKey = true, - ValidIssuer = jwtOptions.Issuer, - ValidAudience = jwtOptions.Audience, - RequireExpirationTime = true, - IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtOptions.SecurityKey)) - }; - options.Events = new JwtBearerEvents - { - OnMessageReceived = context => + var accessToken = context.Request.Query["access_token"]; + if (!string.IsNullOrEmpty(accessToken)) { - var accessToken = context.Request.Query["access_token"]; - if (!string.IsNullOrEmpty(accessToken)) - { - context.Token = accessToken; - } - return Task.CompletedTask; + context.Token = accessToken; } - }; - }); + return Task.CompletedTask; + } + }; + }); //授权 context.Services.AddAuthorization(); @@ -153,7 +153,7 @@ namespace Yi.Abp.Web //swagger app.UseYiSwagger(); - + //请求处理 app.UseYiApiHandlinge(); diff --git a/Yi.Bbs.Vue3/src/components/DisscussCard.vue b/Yi.Bbs.Vue3/src/components/DisscussCard.vue index 33b2b534..2410c510 100644 --- a/Yi.Bbs.Vue3/src/components/DisscussCard.vue +++ b/Yi.Bbs.Vue3/src/components/DisscussCard.vue @@ -1,5 +1,5 @@ + + diff --git a/Yi.Bbs.Vue3/src/views/Discuss.vue b/Yi.Bbs.Vue3/src/views/discuss/index.vue similarity index 88% rename from Yi.Bbs.Vue3/src/views/Discuss.vue rename to Yi.Bbs.Vue3/src/views/discuss/index.vue index acfb77b5..2c83264a 100644 --- a/Yi.Bbs.Vue3/src/views/Discuss.vue +++ b/Yi.Bbs.Vue3/src/views/discuss/index.vue @@ -47,28 +47,10 @@ - - - - - - - - - - -
- -
-
-
- + +
+ +