更改逻辑删除问题

This commit is contained in:
橙子
2023-01-27 16:21:35 +08:00
parent c7e74774de
commit 0a003359ea
33 changed files with 633 additions and 16 deletions

View File

@@ -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);
}
}
}

View File

@@ -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>();
}
}
}

View File

@@ -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>();
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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 = "" });