更改逻辑删除问题
This commit is contained in:
@@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Yi.Framework.Core.Attributes;
|
using Yi.Framework.Core.Attributes;
|
||||||
@@ -64,7 +65,7 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories
|
|||||||
}
|
}
|
||||||
public override async Task<bool> DeleteAsync(List<T> deleteObjs)
|
public override async Task<bool> DeleteAsync(List<T> deleteObjs)
|
||||||
{
|
{
|
||||||
if (typeof(T) is ISoftDelete)
|
if (typeof(ISoftDelete).IsAssignableFrom(typeof(T)))
|
||||||
{
|
{
|
||||||
//反射赋值
|
//反射赋值
|
||||||
deleteObjs.ForEach(e => ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, e));
|
deleteObjs.ForEach(e => ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, e));
|
||||||
@@ -77,7 +78,7 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories
|
|||||||
}
|
}
|
||||||
public override async Task<bool> DeleteAsync(Expression<Func<T, bool>> whereExpression)
|
public override async Task<bool> DeleteAsync(Expression<Func<T, bool>> whereExpression)
|
||||||
{
|
{
|
||||||
if (typeof(T) is ISoftDelete)
|
if (typeof(ISoftDelete).IsAssignableFrom(typeof(T)))
|
||||||
{
|
{
|
||||||
var entities = await GetListAsync(whereExpression);
|
var entities = await GetListAsync(whereExpression);
|
||||||
//反射赋值
|
//反射赋值
|
||||||
@@ -91,8 +92,8 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories
|
|||||||
}
|
}
|
||||||
public override async Task<bool> DeleteByIdAsync(dynamic id)
|
public override async Task<bool> DeleteByIdAsync(dynamic id)
|
||||||
{
|
{
|
||||||
if (typeof(T) is ISoftDelete)
|
if (typeof(ISoftDelete).IsAssignableFrom(typeof(T)))
|
||||||
{
|
{
|
||||||
var entity = await GetByIdAsync(id);
|
var entity = await GetByIdAsync(id);
|
||||||
//反射赋值
|
//反射赋值
|
||||||
ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, entity);
|
ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, entity);
|
||||||
@@ -106,9 +107,13 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories
|
|||||||
}
|
}
|
||||||
public override async Task<bool> DeleteByIdsAsync(dynamic[] ids)
|
public override async Task<bool> DeleteByIdsAsync(dynamic[] ids)
|
||||||
{
|
{
|
||||||
if (typeof(T) is ISoftDelete)
|
if (typeof(ISoftDelete).IsAssignableFrom(typeof(T)))
|
||||||
{
|
{
|
||||||
var entities = await _DbQueryable.In(ids).ToListAsync();
|
var entities = await _DbQueryable.In(ids).ToListAsync();
|
||||||
|
if (entities.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//反射赋值
|
//反射赋值
|
||||||
entities.ForEach(e => ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, e));
|
entities.ForEach(e => ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, e));
|
||||||
return await UpdateRangeAsync(entities);
|
return await UpdateRangeAsync(entities);
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ namespace Yi.Framework.Ddd.Services.Abstract
|
|||||||
{
|
{
|
||||||
public interface IDeleteAppService<in TKey> : IApplicationService
|
public interface IDeleteAppService<in TKey> : IApplicationService
|
||||||
{
|
{
|
||||||
Task DeleteAsync(TKey id);
|
Task<bool> DeleteAsync(string id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -104,20 +106,40 @@ namespace Yi.Framework.Ddd.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删
|
/// 单、多删
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="ArgumentNullException"></exception>
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
public async Task DeleteAsync(TKey id)
|
public async Task<bool> DeleteAsync(string id)
|
||||||
{
|
{
|
||||||
if (id is null)
|
if (id is null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(id));
|
throw new ArgumentNullException(nameof(id));
|
||||||
}
|
}
|
||||||
await _repository.DeleteByIdAsync(id);
|
var idsValue = id.Split(',');
|
||||||
|
if (idsValue is null || idsValue.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(id));
|
||||||
|
}
|
||||||
|
return await _repository.DeleteByIdsAsync(idsValue.Select(x => (object)x!).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 删
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="id"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
///// <exception cref="ArgumentNullException"></exception>
|
||||||
|
//public async Task<bool> DeleteAsync(TKey id)
|
||||||
|
//{
|
||||||
|
// if (id is null)
|
||||||
|
// {
|
||||||
|
// throw new ArgumentNullException(nameof(id));
|
||||||
|
// }
|
||||||
|
// return await _repository.DeleteByIdAsync(id);
|
||||||
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 改
|
/// 改
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -131,7 +153,7 @@ namespace Yi.Framework.Ddd.Services
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(id));
|
throw new ArgumentNullException(nameof(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
var entity = await MapToEntityAsync(input);
|
var entity = await MapToEntityAsync(input);
|
||||||
entity.Id = id;
|
entity.Id = id;
|
||||||
await _repository.UpdateIgnoreNullAsync(entity);
|
await _repository.UpdateIgnoreNullAsync(entity);
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
<param name="input"></param>
|
<param name="input"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Yi.Framework.Ddd.Services.CrudAppService`7.DeleteAsync(`3)">
|
<member name="M:Yi.Framework.Ddd.Services.CrudAppService`7.DeleteAsync(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
删
|
单、多删
|
||||||
</summary>
|
</summary>
|
||||||
<param name="id"></param>
|
<param name="id"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ TemplateFactory templateFactory = new();
|
|||||||
//List<string> entityNames = new() { "Banner" };
|
//List<string> entityNames = new() { "Banner" };
|
||||||
string modelName = "Forum";
|
string modelName = "Forum";
|
||||||
string nameSpaces = "Yi.BBS";
|
string nameSpaces = "Yi.BBS";
|
||||||
List<string> entityNames = new() { "Comment" };
|
List<string> entityNames = new() { "_" };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
Banner抽象
|
Banner抽象
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.ArticleCreateInputVo">
|
||||||
|
<summary>
|
||||||
|
Article输入创建对象
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.CommentCreateInputVo">
|
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.CommentCreateInputVo">
|
||||||
<summary>
|
<summary>
|
||||||
Comment输入创建对象
|
Comment输入创建对象
|
||||||
@@ -24,11 +29,21 @@
|
|||||||
Discuss输入创建对象
|
Discuss输入创建对象
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.MyTypeCreateInputVo">
|
||||||
|
<summary>
|
||||||
|
Label输入创建对象
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.Plate.PlateCreateInputVo">
|
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.Plate.PlateCreateInputVo">
|
||||||
<summary>
|
<summary>
|
||||||
Plate输入创建对象
|
Plate输入创建对象
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Yi.BBS.Application.Contracts.Forum.IArticleService">
|
||||||
|
<summary>
|
||||||
|
Article服务抽象
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.BBS.Application.Contracts.Forum.ICommentService">
|
<member name="T:Yi.BBS.Application.Contracts.Forum.ICommentService">
|
||||||
<summary>
|
<summary>
|
||||||
Comment服务抽象
|
Comment服务抽象
|
||||||
@@ -39,6 +54,11 @@
|
|||||||
Discuss服务抽象
|
Discuss服务抽象
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Yi.BBS.Application.Contracts.Forum.ILabelService">
|
||||||
|
<summary>
|
||||||
|
Label服务抽象
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.BBS.Application.Contracts.Forum.IPlateService">
|
<member name="T:Yi.BBS.Application.Contracts.Forum.IPlateService">
|
||||||
<summary>
|
<summary>
|
||||||
Plate服务抽象
|
Plate服务抽象
|
||||||
|
|||||||
@@ -9,6 +9,27 @@
|
|||||||
Banner服务实现
|
Banner服务实现
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Yi.BBS.Application.Forum.ArticleService">
|
||||||
|
<summary>
|
||||||
|
Article服务实现
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.BBS.Application.Forum.ArticleService.GetDiscussIdAsync(System.Int64)">
|
||||||
|
<summary>
|
||||||
|
查询文章
|
||||||
|
</summary>
|
||||||
|
<param name="discussId"></param>
|
||||||
|
<returns></returns>
|
||||||
|
<exception cref="T:Yi.Framework.Core.Exceptions.UserFriendlyException"></exception>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.BBS.Application.Forum.ArticleService.CreateAsync(Yi.BBS.Application.Contracts.Forum.Dtos.ArticleCreateInputVo)">
|
||||||
|
<summary>
|
||||||
|
发表文章
|
||||||
|
</summary>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
<exception cref="T:Yi.Framework.Core.Exceptions.UserFriendlyException"></exception>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.BBS.Application.Forum.CommentService">
|
<member name="T:Yi.BBS.Application.Forum.CommentService">
|
||||||
<summary>
|
<summary>
|
||||||
Comment服务实现
|
Comment服务实现
|
||||||
@@ -50,6 +71,25 @@
|
|||||||
<param name="input"></param>
|
<param name="input"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Yi.BBS.Application.Forum.MyTypeService">
|
||||||
|
<summary>
|
||||||
|
Label服务实现
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.BBS.Application.Forum.MyTypeService.GetListCurrentAsync(Yi.BBS.Application.Contracts.Forum.Dtos.MyTypeGetListInputVo)">
|
||||||
|
<summary>
|
||||||
|
获取当前用户的主题类型
|
||||||
|
</summary>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.BBS.Application.Forum.MyTypeService.CreateAsync(Yi.BBS.Application.Contracts.Forum.Dtos.MyTypeCreateInputVo)">
|
||||||
|
<summary>
|
||||||
|
创建
|
||||||
|
</summary>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.BBS.Application.Forum.PlateService">
|
<member name="T:Yi.BBS.Application.Forum.PlateService">
|
||||||
<summary>
|
<summary>
|
||||||
Plate服务实现
|
Plate服务实现
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Yi.Framework.Core.Extensions;
|
|||||||
using Yi.BBS.Web;
|
using Yi.BBS.Web;
|
||||||
using Yi.BBS.Application;
|
using Yi.BBS.Application;
|
||||||
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Article输入创建对象
|
||||||
|
/// </summary>
|
||||||
|
public class ArticleCreateInputVo
|
||||||
|
{
|
||||||
|
public string Content { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public long DiscussId { get; set; }
|
||||||
|
public long ParentId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class ArticleGetListInputVo : PagedAndSortedResultRequestDto
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public long DiscussId { get; set; }
|
||||||
|
public long ParentId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class ArticleGetListOutputDto : IEntityDto<long>
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public long DiscussId { get; set; }
|
||||||
|
public long ParentId { get; set; }
|
||||||
|
|
||||||
|
public List<ArticleGetListOutputDto> Children { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class ArticleGetOutputDto : IEntityDto<long>
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public long DiscussId { get; set; }
|
||||||
|
public long ParentId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class ArticleUpdateInputVo
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public long DiscussId { get; set; }
|
||||||
|
public long ParentId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Label输入创建对象
|
||||||
|
/// </summary>
|
||||||
|
public class MyTypeCreateInputVo
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string? Color { get; set; }
|
||||||
|
public string? BackgroundColor { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class MyTypeGetListInputVo : PagedAndSortedResultRequestDto
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string? Color { get; set; }
|
||||||
|
public string? BackgroundColor { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class MyTypeGetListOutputDto : IEntityDto<long>
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string? Color { get; set; }
|
||||||
|
public string? BackgroundColor { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class MyTypeOutputDto : IEntityDto<long>
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string? Color { get; set; }
|
||||||
|
public string? BackgroundColor { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||||
|
{
|
||||||
|
public class MyTypeUpdateInputVo
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string? Color { get; set; }
|
||||||
|
public string? BackgroundColor { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||||
|
using Yi.Framework.Ddd.Services.Abstract;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Article服务抽象
|
||||||
|
/// </summary>
|
||||||
|
public interface IArticleService : ICrudAppService<ArticleGetOutputDto, ArticleGetListOutputDto, long, ArticleGetListInputVo, ArticleCreateInputVo, ArticleUpdateInputVo>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||||
|
using Yi.Framework.Ddd.Services.Abstract;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Contracts.Forum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Label服务抽象
|
||||||
|
/// </summary>
|
||||||
|
public interface ILabelService : ICrudAppService<MyTypeOutputDto, MyTypeGetListOutputDto, long, MyTypeGetListInputVo, MyTypeCreateInputVo, MyTypeUpdateInputVo>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
using Yi.BBS.Application.Contracts.Forum;
|
||||||
|
using NET.AutoWebApi.Setting;
|
||||||
|
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||||
|
using Yi.BBS.Domain.Forum.Entities;
|
||||||
|
using Yi.Framework.Ddd.Services;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Yi.BBS.Domain.Forum.Repositories;
|
||||||
|
using Yi.Framework.Ddd.Repositories;
|
||||||
|
using Yi.BBS.Domain.Shared.Forum.ConstClasses;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Forum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Article服务实现
|
||||||
|
/// </summary>
|
||||||
|
[AppService]
|
||||||
|
public class ArticleService : CrudAppService<ArticleEntity, ArticleGetOutputDto, ArticleGetListOutputDto, long, ArticleGetListInputVo, ArticleCreateInputVo, ArticleUpdateInputVo>,
|
||||||
|
IArticleService, IAutoApiService
|
||||||
|
{
|
||||||
|
[Autowired]
|
||||||
|
private IArticleRepository _articleRepository { get; set; }
|
||||||
|
|
||||||
|
[Autowired]
|
||||||
|
private IRepository<DiscussEntity> _discussRepository { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询文章
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="discussId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="UserFriendlyException"></exception>
|
||||||
|
public async Task<List<ArticleGetListOutputDto>> GetDiscussIdAsync([FromRoute] long discussId)
|
||||||
|
{
|
||||||
|
if (!await _discussRepository.IsAnyAsync(x => x.Id == discussId))
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||||
|
}
|
||||||
|
|
||||||
|
var entities = await _articleRepository.GetTreeAsync(x=>x.DiscussId==discussId);
|
||||||
|
var items = await MapToGetListOutputDtosAsync(entities);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发表文章
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="UserFriendlyException"></exception>
|
||||||
|
public async override Task<ArticleGetOutputDto> CreateAsync(ArticleCreateInputVo input)
|
||||||
|
{
|
||||||
|
if (!await _discussRepository.IsAnyAsync(x => x.Id == input.DiscussId))
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||||
|
}
|
||||||
|
if (input.ParentId != 0 && !await _repository.IsAnyAsync(x => x.Id == input.ParentId))
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException(ArticleConst.文章不存在);
|
||||||
|
}
|
||||||
|
return await base.CreateAsync(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||||
|
using Yi.BBS.Domain.Forum.Entities;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Forum.MapperConfig
|
||||||
|
{
|
||||||
|
public class ArticleProfile: Profile
|
||||||
|
{
|
||||||
|
public ArticleProfile()
|
||||||
|
{
|
||||||
|
CreateMap<ArticleGetListInputVo, ArticleEntity>();
|
||||||
|
CreateMap<ArticleCreateInputVo, ArticleEntity>();
|
||||||
|
CreateMap<ArticleUpdateInputVo, ArticleEntity>();
|
||||||
|
CreateMap<ArticleEntity, ArticleGetListOutputDto>();
|
||||||
|
CreateMap<ArticleEntity, ArticleGetOutputDto>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||||
|
using Yi.BBS.Domain.Forum.Entities;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Forum.MapperConfig
|
||||||
|
{
|
||||||
|
public class MyTypeProfile: Profile
|
||||||
|
{
|
||||||
|
public MyTypeProfile()
|
||||||
|
{
|
||||||
|
CreateMap<MyTypeGetListInputVo, MyTypeEntity>();
|
||||||
|
CreateMap<MyTypeCreateInputVo, MyTypeEntity>();
|
||||||
|
CreateMap<MyTypeUpdateInputVo, MyTypeEntity>();
|
||||||
|
CreateMap<MyTypeEntity, MyTypeGetListOutputDto>();
|
||||||
|
CreateMap<MyTypeEntity, MyTypeOutputDto>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using Yi.BBS.Application.Contracts.Forum;
|
||||||
|
using NET.AutoWebApi.Setting;
|
||||||
|
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||||
|
using Yi.BBS.Domain.Forum.Entities;
|
||||||
|
using Yi.Framework.Ddd.Services;
|
||||||
|
using Yi.Framework.Core.CurrentUsers;
|
||||||
|
using SqlSugar;
|
||||||
|
using Yi.Framework.Ddd.Dtos;
|
||||||
|
using Yi.Framework.Data.Filters;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Application.Forum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Label服务实现
|
||||||
|
/// </summary>
|
||||||
|
[AppService]
|
||||||
|
public class MyTypeService : CrudAppService<MyTypeEntity, MyTypeOutputDto, MyTypeGetListOutputDto, long, MyTypeGetListInputVo, MyTypeCreateInputVo, MyTypeUpdateInputVo>,
|
||||||
|
ILabelService, IAutoApiService
|
||||||
|
{
|
||||||
|
[Autowired]
|
||||||
|
private ICurrentUser _currentUser { get; set; }
|
||||||
|
|
||||||
|
[Autowired]
|
||||||
|
private IDataFilter _dataFilter { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前用户的主题类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<PagedResultDto<MyTypeGetListOutputDto>> GetListCurrentAsync(MyTypeGetListInputVo input)
|
||||||
|
{
|
||||||
|
|
||||||
|
_dataFilter.AddFilter<MyTypeEntity>(x => x.UserId == _currentUser.Id);
|
||||||
|
return base.GetListAsync(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<MyTypeOutputDto> CreateAsync(MyTypeCreateInputVo input)
|
||||||
|
{
|
||||||
|
var entity = await MapToEntityAsync(input);
|
||||||
|
entity.Id = SnowflakeHelper.NextId;
|
||||||
|
entity.UserId = _currentUser.Id;
|
||||||
|
entity.IsDeleted = false;
|
||||||
|
var outputEntity = await _repository.InsertReturnEntityAsync(entity);
|
||||||
|
return await MapToGetOutputDtoAsync(outputEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -62,7 +62,7 @@ namespace Yi.BBS.Application.GlobalSetting
|
|||||||
{
|
{
|
||||||
var dto = new List<ActionJwtDto>();
|
var dto = new List<ActionJwtDto>();
|
||||||
dto.Add(new ActionJwtDto { Router = "/index", ActionName = "首页" });
|
dto.Add(new ActionJwtDto { Router = "/index", ActionName = "首页" });
|
||||||
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
//dto.Add(new ActionJwtDto { Router = "/admLable", ActionName = "标签管理" });
|
||||||
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
||||||
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
||||||
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Domain.Shared.Forum.ConstClasses
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 常量定义
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public class ArticleConst
|
||||||
|
{
|
||||||
|
public const string 文章不存在 = "传入的文章id不存在";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Domain.Shared.Forum.ConstClasses
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 常量定义
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public class LabelConst
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Data.Entities;
|
||||||
|
using Yi.Framework.Ddd.Entities;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Domain.Forum.Entities
|
||||||
|
{
|
||||||
|
[SugarTable("Article")]
|
||||||
|
public class ArticleEntity : IEntity<long>, ISoftDelete
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
public bool IsDeleted { get; set; }
|
||||||
|
|
||||||
|
public string Content { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public long DiscussId { get; set; }
|
||||||
|
|
||||||
|
public long ParentId { get; set; }
|
||||||
|
|
||||||
|
public List<ArticleEntity> Children { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Entities;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Domain.Forum.Entities
|
||||||
|
{
|
||||||
|
[SugarTable("DiscussMyType")]
|
||||||
|
public class DiscussMyTypeEntity : IEntity<long>
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public long DiscussId { get; set; }
|
||||||
|
|
||||||
|
public long MyTypeId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Data.Entities;
|
||||||
|
using Yi.Framework.Ddd.Entities;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Domain.Forum.Entities
|
||||||
|
{
|
||||||
|
[SugarTable("MyType")]
|
||||||
|
public class MyTypeEntity : IEntity<long>, ISoftDelete
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
public bool IsDeleted { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string? Color { get; set; }
|
||||||
|
public string? BackgroundColor { get; set; }
|
||||||
|
|
||||||
|
public long UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.BBS.Domain.Forum.Entities;
|
||||||
|
using Yi.Framework.Ddd.Repositories;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Domain.Forum.Repositories
|
||||||
|
{
|
||||||
|
public interface IArticleRepository:IRepository<ArticleEntity>
|
||||||
|
{
|
||||||
|
Task<List<ArticleEntity>> GetTreeAsync(Expression<Func<ArticleEntity, bool>> where);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.BBS.Domain.Forum.Entities;
|
||||||
|
using Yi.BBS.Domain.Forum.Repositories;
|
||||||
|
using Yi.Framework.Core.Sqlsugar.Repositories;
|
||||||
|
using Yi.Framework.Ddd.Repositories;
|
||||||
|
|
||||||
|
namespace Yi.BBS.Sqlsugar.Repositories
|
||||||
|
{
|
||||||
|
[AppService]
|
||||||
|
public class ArticleRepository : SqlsugarRepository<ArticleEntity>, IArticleRepository
|
||||||
|
{
|
||||||
|
public ArticleRepository(ISqlSugarClient context) : base(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<ArticleEntity>> GetTreeAsync(Expression<Func<ArticleEntity, bool>> where)
|
||||||
|
{
|
||||||
|
return await _DbQueryable.Where(where).ToTreeAsync(x => x.Children, x => x.ParentId, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user