feat:框架基础设施搭建
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Application.Contracts.Exhibition.Dtos.Argee;
|
||||
using Yi.BBS.Domain.Exhibition.Entities;
|
||||
using Yi.BBS.Domain.Forum.Entities;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.Framework.Ddd.Services.Abstract;
|
||||
using Yi.Framework.Uow;
|
||||
|
||||
namespace Yi.BBS.Application.Exhibition
|
||||
{
|
||||
/// <summary>
|
||||
/// 点赞功能
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class AgreeService : ApplicationService, IApplicationService, IAutoApiService
|
||||
{
|
||||
|
||||
[Autowired]
|
||||
private IRepository<AgreeEntity> _repository { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IRepository<DiscussEntity> _discssRepository { get; set; }
|
||||
[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IUnitOfWorkManager _unitOfWorkManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞,返回true为点赞+1,返回false为点赞-1
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<AgreeDto> PostOperateAsync(long discussId)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == _currentUser.Id);
|
||||
//判断是否已经点赞过
|
||||
if (entity is null)
|
||||
{
|
||||
using (var uow = _unitOfWorkManager.CreateContext())
|
||||
{
|
||||
//没点赞过,添加记录即可,,修改总点赞数量
|
||||
await _repository.InsertAsync(new AgreeEntity(discussId));
|
||||
var discussEntity = await _discssRepository.GetByIdAsync(discussId);
|
||||
if (discussEntity is null)
|
||||
{
|
||||
throw new UserFriendlyException("主题为空");
|
||||
}
|
||||
discussEntity.AgreeNum += 1;
|
||||
await _discssRepository.UpdateAsync(discussEntity);
|
||||
uow.Commit();
|
||||
}
|
||||
return new AgreeDto(true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var uow = _unitOfWorkManager.CreateContext())
|
||||
{
|
||||
//点赞过,删除即可,修改总点赞数量
|
||||
await _repository.DeleteByIdAsync(entity.Id);
|
||||
var discussEntity = await _discssRepository.GetByIdAsync(discussId);
|
||||
if (discussEntity is null)
|
||||
{
|
||||
throw new UserFriendlyException("主题为空");
|
||||
}
|
||||
discussEntity.AgreeNum -= 1;
|
||||
await _discssRepository.UpdateAsync(discussEntity);
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
return new AgreeDto(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Yi.BBS.Application.Contracts.Exhibition;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Application.Contracts.Exhibition.Dtos;
|
||||
using Yi.BBS.Domain.Exhibition.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner;
|
||||
|
||||
namespace Yi.BBS.Application.Exhibition
|
||||
{
|
||||
/// <summary>
|
||||
/// Banner服务实现
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class BannerService : CrudAppService<BannerEntity, BannerGetOutputDto, BannerGetListOutputDto, long, BannerGetListInputVo, BannerCreateInputVo, BannerUpdateInputVo>,
|
||||
IBannerService, IAutoApiService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using Yi.BBS.Application.Contracts.Forum;
|
||||
using Cike.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;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.RBAC.Domain.Shared.Identity.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; }
|
||||
|
||||
[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IDiscussService _discussService { get; set; }
|
||||
/// <summary>
|
||||
/// 获取文章全部平铺信息
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
[Route("/api/article/all/discuss-id/{discussId}")]
|
||||
public async Task<List<ArticleAllOutputDto>> GetAllAsync([FromRoute] long discussId)
|
||||
{
|
||||
await _discussService.VerifyDiscussPermissionAsync(discussId);
|
||||
|
||||
|
||||
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
|
||||
//var result = entities.Tile();
|
||||
var items = _mapper.Map<List<ArticleAllOutputDto>>(entities);
|
||||
return items;
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
var discuss = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId);
|
||||
if (discuss is null)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||
}
|
||||
if (input.ParentId != 0 && !await _repository.IsAnyAsync(x => x.Id == input.ParentId))
|
||||
{
|
||||
throw new UserFriendlyException(ArticleConst.文章不存在);
|
||||
}
|
||||
await VerifyDiscussCreateIdAsync(discuss.CreatorId);
|
||||
return await base.CreateAsync(input);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 效验创建权限
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task VerifyDiscussCreateIdAsync(long? userId)
|
||||
{
|
||||
//只有文章是特殊的,不能在其他主题下创建
|
||||
//主题的创建者不是当前用户,同时,没有权限或者超级管理
|
||||
|
||||
//false & true & false ,三个条件任意满意一个,即可成功使用||,最后取反,一个都不满足
|
||||
//
|
||||
if (userId != _currentUser.Id && !UserConst.Admin.Equals( _currentUser.UserName)&& !_currentUser.Permission.Contains("bbs:discuss:add"))
|
||||
{
|
||||
throw new UserFriendlyException("无权限在其他用户主题中创建子文章");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using Yi.BBS.Application.Contracts.Forum;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||
using Yi.BBS.Domain.Forum.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.BBS.Domain.Forum;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.BBS.Domain.Shared.Forum.ConstClasses;
|
||||
using Yi.BBS.Application.Contracts.Forum.Dtos.Discuss;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
using SqlSugar;
|
||||
using System.Security.AccessControl;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Yi.BBS.Application.Forum
|
||||
{
|
||||
/// <summary>
|
||||
/// 评论
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class CommentService : CrudAppService<CommentEntity, CommentGetOutputDto, CommentGetListOutputDto, long, CommentGetListInputVo, CommentCreateInputVo, CommentUpdateInputVo>,
|
||||
ICommentService, IAutoApiService
|
||||
{
|
||||
[Autowired]
|
||||
private ForumManager _forumManager { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IRepository<DiscussEntity> _discussRepository { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IDiscussService _discussService { get; set; }
|
||||
/// <summary>
|
||||
/// 获取改主题下的评论,结构为二维列表,该查询无分页
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PagedResultDto<CommentGetListOutputDto>> GetDiscussIdAsync([FromRoute] long discussId, [FromQuery] CommentGetListInputVo input)
|
||||
{
|
||||
await _discussService.VerifyDiscussPermissionAsync(discussId);
|
||||
|
||||
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Content), x => x.Content.Contains(input.Content))
|
||||
.Where(x => x.DiscussId == discussId)
|
||||
.Includes(x=>x.CreateUser)
|
||||
.ToListAsync();
|
||||
|
||||
//结果初始值,第一层等于全部根节点
|
||||
var outPut = entities.Where(x => x.ParentId == 0).OrderByDescending(x=>x.CreationTime).ToList();
|
||||
|
||||
//将全部数据进行hash
|
||||
var dic = entities.ToDictionary(x => x.Id);
|
||||
|
||||
|
||||
foreach (var comment in entities)
|
||||
{
|
||||
//不是根节点,需要赋值 被评论者用户信息等
|
||||
if (comment.ParentId != 0)
|
||||
{
|
||||
var parentComment = dic[comment.ParentId];
|
||||
comment.CommentedUser = parentComment.CreateUser;
|
||||
}
|
||||
|
||||
//root或者parent id,根节点都是等于0的
|
||||
var id = comment.RootId;
|
||||
if (id is not 0)
|
||||
{
|
||||
dic[id].Children.Add(comment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//子类需要排序
|
||||
outPut.ForEach(x =>
|
||||
{
|
||||
x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();
|
||||
|
||||
});
|
||||
|
||||
//获取全量主题评论, 先获取顶级的,将其他子组合到顶级下,形成一个二维,先转成dto
|
||||
List<CommentGetListOutputDto>? items = await MapToGetListOutputDtosAsync(outPut);
|
||||
return new PagedResultDto<CommentGetListOutputDto>(entities.Count(), items);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发表评论
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public override async Task<CommentGetOutputDto> CreateAsync(CommentCreateInputVo input)
|
||||
{
|
||||
if (!await _discussRepository.IsAnyAsync(x => x.Id == input.DiscussId))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||
}
|
||||
var entity = await _forumManager.CreateCommentAsync(input.DiscussId, input.ParentId,input.RootId, input.Content);
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using Yi.BBS.Application.Contracts.Forum;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||
using Yi.BBS.Domain.Forum.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.BBS.Application.Contracts.Forum.Dtos.Discuss;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
using Yi.BBS.Domain.Forum;
|
||||
using MapsterMapper;
|
||||
using SqlSugar;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Yi.BBS.Domain.Shared.Forum.ConstClasses;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.RBAC.Domain.Identity.Entities;
|
||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||
using Cike.EventBus.DistributedEvent;
|
||||
using Yi.BBS.Domain.Shared.Forum.Etos;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.BBS.Domain.Exhibition.Entities;
|
||||
|
||||
namespace Yi.BBS.Application.Forum
|
||||
{
|
||||
/// <summary>
|
||||
/// Discuss应用服务实现,用于参数效验、领域服务业务组合、日志记录、事务处理、账户信息
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class DiscussService : CrudAppService<DiscussEntity, DiscussGetOutputDto, DiscussGetListOutputDto, long, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>,
|
||||
IDiscussService, IAutoApiService
|
||||
{
|
||||
public DiscussService(ICurrentUser currentUser)
|
||||
{
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
[Autowired]
|
||||
private ForumManager _forumManager { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IRepository<PlateEntity> _plateEntityRepository { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IDistributedEventBus _distributedEventBus { get; set; }
|
||||
|
||||
//[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async override Task<DiscussGetOutputDto> GetAsync(long id)
|
||||
{
|
||||
|
||||
//查询主题发布 浏览主题 事件,浏览数+1
|
||||
var item = await _DbQueryable.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
|
||||
.Select((discuss, user) => new DiscussGetOutputDto
|
||||
{
|
||||
User = new UserGetListOutputDto() { UserName = user.UserName, Nick = user.Nick, Icon = user.Icon }
|
||||
}, true).SingleAsync(discuss => discuss.Id == id);
|
||||
|
||||
await VerifyDiscussPermissionAsync(item.Id);
|
||||
|
||||
if (item is not null)
|
||||
{
|
||||
_distributedEventBus.PublishAsync(new SeeDiscussEventArgs { DiscussId = item.Id, OldSeeNum = item.SeeNum });
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public override async Task<PagedResultDto<DiscussGetListOutputDto>> GetListAsync([FromQuery] DiscussGetListInputVo input)
|
||||
{
|
||||
//需要关联创建者用户
|
||||
RefAsync<int> total = 0;
|
||||
var items = await _DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
|
||||
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
|
||||
.Where(x => x.IsTop == input.IsTop)
|
||||
|
||||
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.New, discuss => discuss.CreationTime, OrderByType.Desc)
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.Host, discuss => discuss.SeeNum, OrderByType.Desc)
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc)
|
||||
.Select((discuss, user) => new DiscussGetListOutputDto
|
||||
{
|
||||
Id=discuss.Id,
|
||||
IsAgree = SqlFunc.Subqueryable<AgreeEntity>().Where(x => x.CreatorId == _currentUser.Id && x.DiscussId == discuss.Id).Any(),
|
||||
|
||||
User = new UserGetListOutputDto() { Id=user.Id, UserName = user.UserName, Nick = user.Nick, Icon = user.Icon }
|
||||
|
||||
}, true)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
|
||||
//查询完主题之后,要过滤一下私有的主题信息
|
||||
items.ApplyPermissionTypeFilter(_currentUser.Id);
|
||||
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建主题
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<DiscussGetOutputDto> CreateAsync(DiscussCreateInputVo input)
|
||||
{
|
||||
if (!await _plateEntityRepository.IsAnyAsync(x => x.Id == input.PlateId))
|
||||
{
|
||||
throw new UserFriendlyException(PlateConst.板块不存在);
|
||||
}
|
||||
var entity = await _forumManager.CreateDiscussAsync(await MapToEntityAsync(input));
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 效验主题查询权限
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public async Task VerifyDiscussPermissionAsync(long discussId)
|
||||
{
|
||||
var discuss = await _repository.GetFirstAsync(x => x.Id == discussId);
|
||||
if (discuss is null)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||
}
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.Oneself)
|
||||
{
|
||||
if (discuss.CreatorId != _currentUser.Id)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.私密);
|
||||
}
|
||||
}
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.User)
|
||||
{
|
||||
if (discuss.CreatorId != _currentUser.Id && !discuss.PermissionUserIds.Contains(_currentUser.Id))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.私密);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using Yi.BBS.Application.Contracts.Forum;
|
||||
using Cike.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Yi.BBS.Application.Contracts.Forum;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Application.Contracts.Forum.Dtos;
|
||||
using Yi.BBS.Domain.Forum.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.BBS.Application.Contracts.Forum.Dtos.Plate;
|
||||
|
||||
namespace Yi.BBS.Application.Forum
|
||||
{
|
||||
/// <summary>
|
||||
/// Plate服务实现
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class PlateService : CrudAppService<PlateEntity, PlateGetOutputDto, PlateGetListOutputDto, long, PlateGetListInputVo, PlateCreateInputVo, PlateUpdateInputVo>,
|
||||
IPlateService, IAutoApiService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Yi.BBS.Application.Contracts.GlobalSetting;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Domain.GlobalSetting.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
|
||||
namespace Yi.BBS.Application.GlobalSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// Setting服务实现
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class SettingService : ApplicationService,
|
||||
ISettingService, IAutoApiService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取配置标题
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public Task<string> GetTitleAsync()
|
||||
{
|
||||
return Task.FromResult("你好世界");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using Yi.BBS.Application.Contracts.GlobalSetting;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Domain.GlobalSetting.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.BBS.Application.Contracts.GlobalSetting.Dtos.Temp;
|
||||
using Yi.BBS.Domain.Shared;
|
||||
using Yi.Framework.Data.DataSeeds;
|
||||
using Yi.RBAC.Domain.Identity.Entities;
|
||||
|
||||
namespace Yi.BBS.Application.GlobalSetting
|
||||
{
|
||||
/// <summary>
|
||||
///临时服务,之后用其他模块代替
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class TempService : ApplicationService, IAutoApiService
|
||||
{
|
||||
|
||||
public TempService() {
|
||||
}
|
||||
///// <summary>
|
||||
///// 登录
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
///// <exception cref="NotImplementedException"></exception>
|
||||
//[Route("/api/account/login")]
|
||||
//public Task<LoginDto> PostLoginAsync()
|
||||
//{
|
||||
// bool loginSucces = true;
|
||||
// if (!loginSucces)
|
||||
// {
|
||||
// throw new UserFriendlyException("登录失败", (int)BbsHttpStatusEnum.LoginFailed, "用户或者密码错误");
|
||||
// }
|
||||
// var dto = new LoginDto("token");
|
||||
// dto.User = new LoginUserInfoDto { Icon = "", Id = 0, Level = 1, UserName = "橙子" };
|
||||
// return Task.FromResult(dto);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 判断是否有登录
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[Route("/api/account/logged")]
|
||||
//public Task<bool> PostLogged()
|
||||
//{
|
||||
// return Task.FromResult(true);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 退出登录
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[Route("/api/account/logout")]
|
||||
//public Task PostlogOut()
|
||||
//{
|
||||
// return Task.CompletedTask;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/account/user/{id}")]
|
||||
public Task<List<ActionJwtDto>> GetUserInfoByIdAsync(long id)
|
||||
{
|
||||
var dto = new List<ActionJwtDto>();
|
||||
dto.Add(new ActionJwtDto { Router = "/index", 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 = "" });
|
||||
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
|
||||
return Task.FromResult(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>./$(AssemblyName)SwaggerDoc.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Auth.JwtBearer\Yi.Framework.Auth.JwtBearer.csproj" />
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Uow\Yi.Framework.Uow.csproj" />
|
||||
<ProjectReference Include="..\..\rbac\Yi.RBAC.Application\Yi.RBAC.Application.csproj" />
|
||||
<ProjectReference Include="..\Yi.BBS.Application.Contracts\Yi.BBS.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Yi.BBS.Domain\Yi.BBS.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Yi.BBS.ApplicationSwaggerDoc.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.BBS.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.BBS.Application.Exhibition.AgreeService">
|
||||
<summary>
|
||||
点赞功能
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Exhibition.AgreeService.PostOperateAsync(System.Int64)">
|
||||
<summary>
|
||||
点赞,返回true为点赞+1,返回false为点赞-1
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Exhibition.BannerService">
|
||||
<summary>
|
||||
Banner服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Forum.ArticleService">
|
||||
<summary>
|
||||
Article服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.ArticleService.GetAllAsync(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.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="M:Yi.BBS.Application.Forum.ArticleService.VerifyDiscussCreateIdAsync(System.Nullable{System.Int64})">
|
||||
<summary>
|
||||
效验创建权限
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Forum.CommentService">
|
||||
<summary>
|
||||
评论
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.CommentService.GetDiscussIdAsync(System.Int64,Yi.BBS.Application.Contracts.Forum.Dtos.CommentGetListInputVo)">
|
||||
<summary>
|
||||
获取改主题下的评论,结构为二维列表,该查询无分页
|
||||
</summary>
|
||||
<param name="discussId"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.CommentService.CreateAsync(Yi.BBS.Application.Contracts.Forum.Dtos.CommentCreateInputVo)">
|
||||
<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.DiscussService">
|
||||
<summary>
|
||||
Discuss应用服务实现,用于参数效验、领域服务业务组合、日志记录、事务处理、账户信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.GetAsync(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.GetListAsync(Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListInputVo)">
|
||||
<summary>
|
||||
查询
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.CreateAsync(Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussCreateInputVo)">
|
||||
<summary>
|
||||
创建主题
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.VerifyDiscussPermissionAsync(System.Int64)">
|
||||
<summary>
|
||||
效验主题查询权限
|
||||
</summary>
|
||||
<param name="discussId"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Core.Exceptions.UserFriendlyException"></exception>
|
||||
</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服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.GlobalSetting.SettingService">
|
||||
<summary>
|
||||
Setting服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.GlobalSetting.SettingService.GetTitleAsync">
|
||||
<summary>
|
||||
获取配置标题
|
||||
</summary>
|
||||
<returns></returns>
|
||||
<exception cref="T:System.NotImplementedException"></exception>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.GlobalSetting.TempService">
|
||||
<summary>
|
||||
临时服务,之后用其他模块代替
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.GlobalSetting.TempService.GetUserInfoByIdAsync(System.Int64)">
|
||||
<summary>
|
||||
获取用户信息
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StartupModules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.BBS.Application.Contracts;
|
||||
using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Data;
|
||||
using Yi.Framework.Ddd;
|
||||
using Yi.BBS.Domain;
|
||||
using Yi.RBAC.Application;
|
||||
|
||||
namespace Yi.BBS.Application
|
||||
{
|
||||
[DependsOn(
|
||||
|
||||
typeof(YiBBSApplicationContractsModule),
|
||||
typeof(YiBBSDomainModule),
|
||||
typeof(YiFrameworkAuthJwtBearerModule),
|
||||
typeof(YiRBACApplicationModule)
|
||||
)]
|
||||
public class YiBBSApplicationModule : IStartupModule
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user