From 4b7abd4fe0f93ac96d4582ea46fc836779a951c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com>
Date: Sat, 26 Oct 2024 15:11:45 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=BE=E5=87=BA=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/Comment/CommentGetOutputDto.cs | 8 +-
.../IServices/ICommentService.cs | 3 +-
.../Services/Forum/CommentService.cs | 132 +++--------
.../YiFrameworkRbacDomainModule.cs | 10 +-
.../Services/TestService.cs | 175 +-------------
.../Yi.Abp.Web/AbpUnitOfWorkMiddleware2.cs | 65 ++++++
Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs | 6 +-
Yi.Abp.Net8/src/Yi.Abp.Web/TestService.cs | 42 ++++
Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs | 214 ++----------------
9 files changed, 175 insertions(+), 480 deletions(-)
create mode 100644 Yi.Abp.Net8/src/Yi.Abp.Web/AbpUnitOfWorkMiddleware2.cs
create mode 100644 Yi.Abp.Net8/src/Yi.Abp.Web/TestService.cs
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetOutputDto.cs
index cd348c86..9cd36d9e 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetOutputDto.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetOutputDto.cs
@@ -5,7 +5,7 @@ using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Comment
{
///
- /// 单返回,返回单条评论即可
+ /// 鍗曡繑鍥烇紝杩斿洖鍗曟潯璇勮鍗冲彲
///
public class CommentGetOutputDto : EntityDto
{
@@ -17,17 +17,17 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Comment
///
- /// 用户id联表为用户对象
+ /// 鐢ㄦ埛id鑱旇〃涓虹敤鎴峰璞
///
public BbsUserGetOutputDto User { get; set; }
///
- /// 根节点的评论id
+ /// 鏍硅妭鐐圭殑璇勮id
///
public Guid RootId { get; set; }
///
- /// 被回复的CommentId
+ /// 琚洖澶嶇殑CommentId
///
public Guid ParentId { get; set; }
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/IServices/ICommentService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/IServices/ICommentService.cs
index 4b787dab..7837de29 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/IServices/ICommentService.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/IServices/ICommentService.cs
@@ -6,8 +6,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.IServices
///
/// Comment鏈嶅姟鎶借薄
///
- public interface ICommentService : IYiCrudAppService
- {
+ public interface ICommentService{
///
/// 鍙戣〃璇勮
///
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs
index c0fc717d..63ab7dbb 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs
@@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Comment;
using Yi.Framework.Bbs.Application.Contracts.IServices;
@@ -21,19 +23,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
///
/// 璇勮
///
- public class CommentService : YiCrudAppService,
+ public class CommentService : ApplicationService,
ICommentService
{
private readonly ISqlSugarRepository _repository;
private readonly BbsUserManager _bbsUserManager;
- public CommentService(ForumManager forumManager, ISqlSugarRepository discussRepository, IDiscussService discussService, ISqlSugarRepository CommentRepository, BbsUserManager bbsUserManager) : base(CommentRepository)
- {
- _forumManager = forumManager;
- _discussRepository = discussRepository;
- _discussService = discussService;
- _repository = CommentRepository;
- _bbsUserManager = bbsUserManager;
- }
private ForumManager _forumManager { get; set; }
@@ -42,90 +36,20 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private ISqlSugarRepository _discussRepository { get; set; }
private IDiscussService _discussService { get; set; }
- ///
- /// 鑾峰彇鏀逛富棰樹笅鐨勮瘎璁,缁撴瀯涓轰簩缁村垪琛紝璇ユ煡璇㈡棤鍒嗛〉
- /// Todo: 鍙斁鍏ラ鍩熷眰
- ///
- ///
- ///
- ///
- public async Task> GetDiscussIdAsync([FromRoute] Guid discussId, [FromQuery] CommentGetListInputVo input)
+
+
+ public async Task Create2Async(CommentCreateInputVo input)
{
- await _discussService.VerifyDiscussPermissionAsync(discussId);
-
- var entities = await _repository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Content), x => x.Content.Contains(input.Content))
- .Where(x => x.DiscussId == discussId)
- .Includes(x => x.CreateUser)
- .ToListAsync();
-
- //璇ュ疄浣撻渶瑕佽繘琛岃浆鎹
-
- //鍚屾椂涓烘墍鏈夌敤鎴穒d杩涜bbs鐨勬墿灞曞嵆鍙
- List userIds = entities.Where(x => x.CreatorId != null).Select(x => x.CreatorId ?? Guid.Empty).ToList();
- var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
-
-
-
-
-
- //------鏁版嵁鏌ヨ瀹屾垚------
-
-
-
-
-
- //浠庢牴鐩綍寮濮嬬粍瑁
- //缁撴灉鍒濆鍊硷紝绗竴灞傜瓑浜庡叏閮ㄦ牴鑺傜偣
- var allOutPut = entities.OrderByDescending(x => x.CreationTime).ToList();
-
- //鑾峰彇鍏ㄩ噺涓婚璇勮锛 鍏堣幏鍙栭《绾х殑锛屽皢鍏朵粬瀛愮粍鍚堝埌椤剁骇涓嬶紝褰㈡垚涓涓簩缁,鍏堣浆鎴恉to
- List allOutoutDto = await MapToGetListOutputDtosAsync(allOutPut);
-
- //寮濮嬫槧灏勯澶栫敤鎴蜂俊鎭瓧娈
- allOutoutDto?.ForEach(x => x.CreateUser = bbsUserInfoDic[x.CreatorId ?? Guid.Empty].Adapt());
-
- //寮濮嬬粍瑁卍to鐨勫眰绾у叧绯
- //灏嗗叏閮ㄦ暟鎹繘琛宧ash
- var dic = allOutoutDto.ToDictionary(x => x.Id);
-
- foreach (var comment in allOutoutDto)
- {
- //涓嶆槸鏍硅妭鐐癸紝闇瑕佽祴鍊 琚瘎璁鸿呯敤鎴蜂俊鎭瓑
- if (comment.ParentId != Guid.Empty)
- {
- if (dic.ContainsKey(comment.ParentId))
- {
- var parentComment = dic[comment.ParentId];
- comment.CommentedUser = parentComment.CreateUser;
- }
- else
- {
- continue;
- }
- }
- //root鎴栬卲arent id锛屾牴鑺傜偣閮芥槸绛変簬0鐨
- var id = comment.RootId;
- if (id != Guid.Empty)
- {
- dic[id].Children.Add(comment);
- }
-
- }
-
- //瀛愮被闇瑕佹帓搴
- var rootOutoutDto = allOutoutDto.Where(x => x.ParentId == Guid.Empty).ToList();
- rootOutoutDto?.ForEach(x =>
- {
- x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();
-
- });
-
-
-
- return new PagedResultDto(entities.Count(), rootOutoutDto);
+ var entity = new CommentAggregateRoot(Guid.Empty);
+ return new CommentGetOutputDto();
}
-
+ [HttpGet("Create22")]
+ public async Task Create22Async(CommentCreateInputVo input)
+ {
+ var entity = new CommentAggregateRoot(Guid.Empty);
+ return new CommentGetOutputDto();
+ }
///
/// 鍙戣〃璇勮
///
@@ -134,24 +58,28 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
///
// [Permission("bbs:comment:add")]
// [Authorize]
- public override async Task CreateAsync(CommentCreateInputVo input)
+ public async Task CreateAsync(CommentCreateInputVo input)
{
- var discuess = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId);
- if (discuess is null)
- {
- throw new UserFriendlyException(DiscussConst.No_Exist);
- }
+ // var discuess = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId);
+ // if (discuess is null)
+ // {
+ // throw new UserFriendlyException(DiscussConst.No_Exist);
+ // }
//涓嶆槸瓒呯骇绠$悊鍛橈紝涓斾富棰樺紑鍚姝㈣瘎璁
- if (discuess.IsDisableCreateComment == true && !CurrentUser.GetPermissions().Contains(UserConst.AdminPermissionCode))
- {
- throw new UserFriendlyException("璇ヤ富棰樺凡绂佹璇勮鍔熻兘");
- }
+ // if (discuess.IsDisableCreateComment == true && !CurrentUser.GetPermissions().Contains(UserConst.AdminPermissionCode))
+ // {
+ // throw new UserFriendlyException("璇ヤ富棰樺凡绂佹璇勮鍔熻兘");
+ // }
- var entity = await _forumManager.CreateCommentAsync(input.DiscussId, input.ParentId, input.RootId, input.Content);
- return await MapToGetOutputDtoAsync(entity);
+ // var entity = await _forumManager.CreateCommentAsync(input.DiscussId, input.ParentId, input.RootId, input.Content);
+ var entity = new CommentAggregateRoot(Guid.Empty);
+ return new CommentGetOutputDto();
}
+ public CommentService(IRepository repository)
+ {
+ }
}
}
diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/YiFrameworkRbacDomainModule.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/YiFrameworkRbacDomainModule.cs
index a5568c1e..07d3f261 100644
--- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/YiFrameworkRbacDomainModule.cs
+++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/YiFrameworkRbacDomainModule.cs
@@ -26,11 +26,11 @@ namespace Yi.Framework.Rbac.Domain
{
var service = context.Services;
var configuration = context.Services.GetConfiguration();
- service.AddControllers(options =>
- {
- options.Filters.Add();
- options.Filters.Add();
- });
+ // service.AddControllers(options =>
+ // {
+ // options.Filters.Add();
+ // // options.Filters.Add();
+ // });
//閰嶇疆闃块噷浜戠煭淇
Configure(configuration.GetSection(nameof(AliyunOptions)));
diff --git a/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs b/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs
index 409db5dc..cf9b0089 100644
--- a/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs
+++ b/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs
@@ -21,178 +21,15 @@ namespace Yi.Abp.Application.Services
///
public class TestService : ApplicationService
{
- ///
- /// 灞炴ф敞鍏
- /// 涓嶆帹鑽愶紝鍧戝お澶氾紝瀹规槗鎶婅嚜宸辩帺姝伙紝绠鍗曠殑涓滆タ鍙互鐢ㄤ竴鐢
- ///
- public ISqlSugarRepository sqlSugarRepository { get; set; }
-
- private ICommentService _commentService;
- public readonly ISqlSugarRepository _commentRepository;
- public TestService(ICommentService commentService, ISqlSugarRepository commentRepository)
+ [HttpGet("hello-world/string")]
+ public async Task GetHelloWorld1(string? name)
{
- _commentService = commentService;
- _commentRepository = commentRepository;
+ return "1";
}
-
- public async Task GetAbpUnitOfWorkMiddleware()
+ [HttpGet("hello-world/dto")]
+ public async Task GetHelloWorld2(string? name)
{
- var entity = new CommentAggregateRoot(Guid.Empty);
- entity.Content = "娴嬭瘯";
- entity.ParentId = Guid.Empty;
- entity.RootId = Guid.Empty;
- await _commentRepository.InsertAsync(entity);
- return "yes";
+ return new CommentGetOutputDto();
}
-
- ///
- /// 鍔ㄦ丄pi
- ///
- ///
- ///
- [HttpGet("hello-world")]
- public string GetHelloWorld(string? name)
- {
- //浼氳嚜鍔ㄦ坊鍔犲墠缂锛岃屼笉鏄噸缃紝鏇寸鍚堜範鎯
- //濡傛灉闇瑕侀噸缃互"/"鏍圭洰褰曞紑澶村嵆鍙
- //浣犲ソ涓栫晫
- return name ?? "HelloWord";
- }
-
- ///
- /// 寮傚父澶勭悊
- ///
- ///
- [HttpGet("error")]
- public string GetError()
- {
- throw new UserFriendlyException("涓氬姟寮傚父");
- throw new Exception("绯荤粺寮傚父");
- }
-
- ///
- /// SqlSugar
- ///
- ///
- public async Task