更改逻辑删除问题
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
Banner抽象
|
||||
</summary>
|
||||
</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">
|
||||
<summary>
|
||||
Comment输入创建对象
|
||||
@@ -24,11 +29,21 @@
|
||||
Discuss输入创建对象
|
||||
</summary>
|
||||
</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">
|
||||
<summary>
|
||||
Plate输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Contracts.Forum.IArticleService">
|
||||
<summary>
|
||||
Article服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Contracts.Forum.ICommentService">
|
||||
<summary>
|
||||
Comment服务抽象
|
||||
@@ -39,6 +54,11 @@
|
||||
Discuss服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Contracts.Forum.ILabelService">
|
||||
<summary>
|
||||
Label服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Contracts.Forum.IPlateService">
|
||||
<summary>
|
||||
Plate服务抽象
|
||||
|
||||
@@ -9,6 +9,27 @@
|
||||
Banner服务实现
|
||||
</summary>
|
||||
</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">
|
||||
<summary>
|
||||
Comment服务实现
|
||||
@@ -50,6 +71,25 @@
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</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">
|
||||
<summary>
|
||||
Plate服务实现
|
||||
|
||||
@@ -5,7 +5,6 @@ using Yi.Framework.Core.Extensions;
|
||||
using Yi.BBS.Web;
|
||||
using Yi.BBS.Application;
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
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>();
|
||||
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 = "" });
|
||||
|
||||
@@ -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