feat:完成仅自己可见功能
@@ -94,11 +94,36 @@
|
||||
Discuss输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussCreateInputVo.PermissionType">
|
||||
<summary>
|
||||
默认公开
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussCreateInputVo.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListOutputDto.IsAgree">
|
||||
<summary>
|
||||
是否已点赞
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListOutputDto.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussUpdateInputVo.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.DiscussGetOutputDto.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.MyTypeCreateInputVo">
|
||||
<summary>
|
||||
Label输入创建对象
|
||||
|
||||
@@ -49,6 +49,13 @@
|
||||
<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>
|
||||
评论
|
||||
@@ -96,6 +103,14 @@
|
||||
<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服务实现
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.BBS.Domain.Shared.Forum.EnumClasses
|
||||
{
|
||||
public enum DiscussPermissionTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认:公开
|
||||
/// </summary>
|
||||
Public = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 仅自己可见
|
||||
/// </summary>
|
||||
Oneself,
|
||||
|
||||
/// <summary>
|
||||
/// 部分用户可见
|
||||
/// </summary>
|
||||
User
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ namespace Yi.BBS.Domain.DataSeed
|
||||
public override List<MenuEntity> GetSeedData()
|
||||
{
|
||||
List<MenuEntity> entities = new List<MenuEntity>();
|
||||
|
||||
//BBS
|
||||
MenuEntity bbs = new MenuEntity()
|
||||
{
|
||||
@@ -39,6 +40,76 @@ namespace Yi.BBS.Domain.DataSeed
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(bbs);
|
||||
|
||||
|
||||
//评论管理
|
||||
MenuEntity comment = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论管理",
|
||||
PermissionCode = "bbs:comment:list",
|
||||
MenuType = MenuTypeEnum.Menu,
|
||||
Router = "comment",
|
||||
IsShow = true,
|
||||
IsLink = false,
|
||||
IsCache = true,
|
||||
Component = "bbs/comment/index",
|
||||
MenuIcon = "education",
|
||||
OrderNum = 100,
|
||||
ParentId = bbs.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(comment);
|
||||
|
||||
MenuEntity commentQuery = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论查询",
|
||||
PermissionCode = "bbs:comment:query",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentQuery);
|
||||
|
||||
MenuEntity commentAdd = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论新增",
|
||||
PermissionCode = "bbs:comment:add",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentAdd);
|
||||
|
||||
MenuEntity commentEdit = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论修改",
|
||||
PermissionCode = "bbs:comment:edit",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentEdit);
|
||||
|
||||
MenuEntity commentRemove = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论删除",
|
||||
PermissionCode = "bbs:comment:remove",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentRemove);
|
||||
|
||||
|
||||
//文章管理
|
||||
MenuEntity article = new MenuEntity()
|
||||
{
|
||||
|
||||
@@ -46,6 +46,11 @@
|
||||
被评论的用户信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Domain.Forum.Entities.DiscussEntity.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Domain.Forum.ForumManager">
|
||||
<summary>
|
||||
论坛模块的领域服务
|
||||
|
||||
@@ -13,6 +13,7 @@ using Yi.Framework.Data.Json;
|
||||
using Yi.Framework.OperLogManager;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
@@ -30,7 +31,8 @@ namespace Yi.BBS.Web
|
||||
services.AddControllers().AddJsonOptions(opt => {
|
||||
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
opt.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
|
||||
});
|
||||
opt.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
});
|
||||
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"Audience": "yi",
|
||||
"Issuer": "localhost:19002",
|
||||
"Subject": "yiframwork",
|
||||
"ExpSecond": 3600
|
||||
"ExpSecond": 259200
|
||||
},
|
||||
|
||||
//开启种子数据
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
@@ -94,11 +94,36 @@
|
||||
Discuss输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussCreateInputVo.PermissionType">
|
||||
<summary>
|
||||
默认公开
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussCreateInputVo.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListOutputDto.IsAgree">
|
||||
<summary>
|
||||
是否已点赞
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListOutputDto.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussUpdateInputVo.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.DiscussGetOutputDto.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.MyTypeCreateInputVo">
|
||||
<summary>
|
||||
Label输入创建对象
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
|
||||
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
{
|
||||
@@ -19,5 +20,14 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public string? Color { get; set; }
|
||||
|
||||
public long plateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认公开
|
||||
/// </summary>
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; } = DiscussPermissionTypeEnum.Public;
|
||||
/// <summary>
|
||||
/// 封面
|
||||
/// </summary>
|
||||
public string? Cover { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
//Ĭ<>ϲ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD>ö<EFBFBD>
|
||||
public bool IsTop { get; set; } = false;
|
||||
|
||||
|
||||
//<2F><>ѯ<EFBFBD><D1AF>ʽ
|
||||
public QueryDiscussTypeEnum Type { get; set; } = QueryDiscussTypeEnum.New;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.BBS.Domain.Shared.Forum.ConstClasses;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||
|
||||
@@ -32,13 +34,58 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
//<2F>Ƿ<EFBFBD><C7B7>ö<EFBFBD><C3B6><EFBFBD>Ĭ<EFBFBD><C4AC>false
|
||||
public bool IsTop { get; set; }
|
||||
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ֹ<EFBFBD><D6B9>Ĭ<EFBFBD><C4AC>false
|
||||
public bool IsBan { get; set; }
|
||||
|
||||
//<2F>Ƿ<EFBFBD>˽<EFBFBD>У<EFBFBD>Ĭ<EFBFBD><C4AC>false
|
||||
public bool IsPrivate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public string? Cover { get; set; }
|
||||
|
||||
//˽<><CBBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ж<EFBFBD>codeȨ<65><C8A8>
|
||||
public string? PrivateCode { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
|
||||
|
||||
public UserGetListOutputDto User { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public static class DiscussGetListOutputDtoExtension
|
||||
{
|
||||
|
||||
public static void ApplyPermissionTypeFilter(this List<DiscussGetListOutputDto> dtos, long userId)
|
||||
{
|
||||
dtos?.ForEach(dto =>
|
||||
{
|
||||
switch (dto.PermissionType)
|
||||
{
|
||||
case DiscussPermissionTypeEnum.Public:
|
||||
break;
|
||||
case DiscussPermissionTypeEnum.Oneself:
|
||||
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD>Լ<EFBFBD><D4BC>ɼ<EFBFBD><C9BC><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>¼<EFBFBD>û<EFBFBD>
|
||||
if (dto.User.Id != userId)
|
||||
{
|
||||
dto.Title = DiscussConst.˽<EFBFBD><EFBFBD>;
|
||||
dto.Introduction= "";
|
||||
dto.Cover = null;
|
||||
//<2F><><EFBFBD><EFBFBD>ֹ
|
||||
dto.IsBan = true;
|
||||
}
|
||||
break;
|
||||
case DiscussPermissionTypeEnum.User:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||
|
||||
@@ -25,14 +26,17 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
//<2F>Ƿ<EFBFBD><C7B7>ö<EFBFBD><C3B6><EFBFBD>Ĭ<EFBFBD><C4AC>false
|
||||
public bool IsTop { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public string? Cover { get; set; }
|
||||
//<2F>Ƿ<EFBFBD>˽<EFBFBD>У<EFBFBD>Ĭ<EFBFBD><C4AC>false
|
||||
public bool IsPrivate { get; set; }
|
||||
|
||||
//˽<><CBBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ж<EFBFBD>codeȨ<65><C8A8>
|
||||
public string? PrivateCode { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
public UserGetListOutputDto User { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
|
||||
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
{
|
||||
@@ -15,5 +16,13 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public int SeeNum { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public string? Cover { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ namespace Yi.BBS.Application.Contracts.Forum
|
||||
/// </summary>
|
||||
public interface IDiscussService : ICrudAppService<DiscussGetOutputDto, DiscussGetListOutputDto, long, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>
|
||||
{
|
||||
|
||||
Task VerifyDiscussPermissionAsync(long discussId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@
|
||||
<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>
|
||||
评论
|
||||
@@ -96,6 +103,14 @@
|
||||
<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服务实现
|
||||
|
||||
@@ -8,6 +8,9 @@ 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
|
||||
{
|
||||
@@ -26,6 +29,11 @@ namespace Yi.BBS.Application.Forum
|
||||
[Autowired]
|
||||
private IRepository<DiscussEntity> _discussRepository { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IDiscussService _discussService { get; set; }
|
||||
/// <summary>
|
||||
/// 获取文章全部平铺信息
|
||||
/// </summary>
|
||||
@@ -35,10 +43,8 @@ namespace Yi.BBS.Application.Forum
|
||||
[Route("/api/article/all/discuss-id/{discussId}")]
|
||||
public async Task<List<ArticleAllOutputDto>> GetAllAsync([FromRoute] long discussId)
|
||||
{
|
||||
if (!await _discussRepository.IsAnyAsync(x => x.Id == discussId))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||
}
|
||||
await _discussService.VerifyDiscussPermissionAsync(discussId);
|
||||
|
||||
|
||||
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
|
||||
//var result = entities.Tile();
|
||||
@@ -72,7 +78,8 @@ namespace Yi.BBS.Application.Forum
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public async override Task<ArticleGetOutputDto> CreateAsync(ArticleCreateInputVo input)
|
||||
{
|
||||
if (!await _discussRepository.IsAnyAsync(x => x.Id == input.DiscussId))
|
||||
var discuss = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId);
|
||||
if (discuss is null)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||
}
|
||||
@@ -80,7 +87,27 @@ namespace Yi.BBS.Application.Forum
|
||||
{
|
||||
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("无权限在其他用户主题中创建子文章");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace Yi.BBS.Application.Forum
|
||||
[Autowired]
|
||||
private IRepository<DiscussEntity> _discussRepository { get; set; }
|
||||
|
||||
|
||||
[Autowired]
|
||||
private IDiscussService _discussService { get; set; }
|
||||
/// <summary>
|
||||
/// 获取改主题下的评论,结构为二维列表,该查询无分页
|
||||
/// </summary>
|
||||
@@ -43,6 +44,7 @@ namespace Yi.BBS.Application.Forum
|
||||
/// <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)
|
||||
|
||||
@@ -29,6 +29,10 @@ namespace Yi.BBS.Application.Forum
|
||||
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; }
|
||||
|
||||
@@ -38,7 +42,7 @@ namespace Yi.BBS.Application.Forum
|
||||
[Autowired]
|
||||
private IDistributedEventBus _distributedEventBus { get; set; }
|
||||
|
||||
[Autowired]
|
||||
//[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
/// <summary>
|
||||
/// 单查
|
||||
@@ -47,12 +51,16 @@ namespace Yi.BBS.Application.Forum
|
||||
/// <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 });
|
||||
@@ -84,9 +92,14 @@ namespace Yi.BBS.Application.Forum
|
||||
{
|
||||
Id=discuss.Id,
|
||||
IsAgree = SqlFunc.Subqueryable<AgreeEntity>().Where(x => x.CreatorId == _currentUser.Id && x.DiscussId == discuss.Id).Any(),
|
||||
User = new UserGetListOutputDto() { UserName = user.UserName, Nick = user.Nick, Icon = user.Icon }
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -101,8 +114,33 @@ namespace Yi.BBS.Application.Forum
|
||||
{
|
||||
throw new UserFriendlyException(PlateConst.板块不存在);
|
||||
}
|
||||
var entity = await _forumManager.CreateDiscussAsync(input.plateId, input.Title, input.Types, input.Content, input.Introduction);
|
||||
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.私密);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ namespace Yi.BBS.Domain.Shared.Forum.ConstClasses
|
||||
public class ArticleConst
|
||||
{
|
||||
public const string 文章不存在 = "传入的文章id不存在";
|
||||
|
||||
public const string 文章无权限 = "该文章无权限";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ namespace Yi.BBS.Domain.Shared.Forum.ConstClasses
|
||||
public class DiscussConst
|
||||
{
|
||||
public const string 主题不存在 = "传入的主题id不存在";
|
||||
|
||||
public const string 私密 = "【私密】您无该主题权限";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Yi.BBS.Domain.DataSeed
|
||||
public override List<MenuEntity> GetSeedData()
|
||||
{
|
||||
List<MenuEntity> entities = new List<MenuEntity>();
|
||||
|
||||
//BBS
|
||||
MenuEntity bbs = new MenuEntity()
|
||||
{
|
||||
@@ -39,6 +40,76 @@ namespace Yi.BBS.Domain.DataSeed
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(bbs);
|
||||
|
||||
|
||||
//评论管理
|
||||
MenuEntity comment = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论管理",
|
||||
PermissionCode = "bbs:comment:list",
|
||||
MenuType = MenuTypeEnum.Menu,
|
||||
Router = "comment",
|
||||
IsShow = true,
|
||||
IsLink = false,
|
||||
IsCache = true,
|
||||
Component = "bbs/comment/index",
|
||||
MenuIcon = "education",
|
||||
OrderNum = 100,
|
||||
ParentId = bbs.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(comment);
|
||||
|
||||
MenuEntity commentQuery = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论查询",
|
||||
PermissionCode = "bbs:comment:query",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentQuery);
|
||||
|
||||
MenuEntity commentAdd = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论新增",
|
||||
PermissionCode = "bbs:comment:add",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentAdd);
|
||||
|
||||
MenuEntity commentEdit = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论修改",
|
||||
PermissionCode = "bbs:comment:edit",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentEdit);
|
||||
|
||||
MenuEntity commentRemove = new MenuEntity()
|
||||
{
|
||||
Id = SnowflakeHelper.NextId,
|
||||
MenuName = "评论删除",
|
||||
PermissionCode = "bbs:comment:remove",
|
||||
MenuType = MenuTypeEnum.Component,
|
||||
OrderNum = 100,
|
||||
ParentId = comment.Id,
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(commentRemove);
|
||||
|
||||
|
||||
//文章管理
|
||||
MenuEntity article = new MenuEntity()
|
||||
{
|
||||
|
||||
@@ -46,6 +46,11 @@
|
||||
被评论的用户信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Domain.Forum.Entities.DiscussEntity.Cover">
|
||||
<summary>
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Domain.Forum.ForumManager">
|
||||
<summary>
|
||||
论坛模块的领域服务
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
using Yi.Framework.Data.Auditing;
|
||||
using Yi.Framework.Data.Entities;
|
||||
using Yi.Framework.Ddd.Entities;
|
||||
@@ -12,10 +13,10 @@ using Yi.Framework.Ddd.Entities;
|
||||
namespace Yi.BBS.Domain.Forum.Entities
|
||||
{
|
||||
[SugarTable("Discuss")]
|
||||
public class DiscussEntity : IEntity<long>, ISoftDelete,IAuditedObject
|
||||
public class DiscussEntity : IEntity<long>, ISoftDelete, IAuditedObject
|
||||
{
|
||||
public DiscussEntity()
|
||||
{
|
||||
{
|
||||
}
|
||||
public DiscussEntity(long plateId)
|
||||
{
|
||||
@@ -29,7 +30,10 @@ namespace Yi.BBS.Domain.Forum.Entities
|
||||
public string? Introduction { get; set; }
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 封面
|
||||
/// </summary>
|
||||
public string? Cover { get; set; }
|
||||
public string Content { get; set; }
|
||||
|
||||
public string? Color { get; set; }
|
||||
@@ -39,12 +43,8 @@ namespace Yi.BBS.Domain.Forum.Entities
|
||||
//是否置顶,默认false
|
||||
public bool IsTop { get; set; }
|
||||
|
||||
|
||||
//是否私有,默认false
|
||||
public bool IsPrivate { get; set; }
|
||||
|
||||
//私有需要判断code权限
|
||||
public string? PrivateCode { get; set; }
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
|
||||
public long PlateId { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
@@ -26,14 +26,9 @@ namespace Yi.BBS.Domain.Forum
|
||||
}
|
||||
|
||||
//主题是不能直接创建的,需要由领域服务统一创建
|
||||
public async Task<DiscussEntity> CreateDiscussAsync(long plateId, string title, string types, string content, string? introduction = null)
|
||||
public async Task<DiscussEntity> CreateDiscussAsync(DiscussEntity entity)
|
||||
{
|
||||
var entity = new DiscussEntity(plateId);
|
||||
entity.Id = SnowflakeHelper.NextId;
|
||||
entity.Title = title;
|
||||
entity.Types = types;
|
||||
entity.Introduction = introduction;
|
||||
entity.Content = content;
|
||||
entity.CreationTime = DateTime.Now;
|
||||
entity.AgreeNum = 0;
|
||||
entity.SeeNum = 0;
|
||||
|
||||
@@ -13,6 +13,7 @@ using Yi.Framework.Data.Json;
|
||||
using Yi.Framework.OperLogManager;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
@@ -30,7 +31,8 @@ namespace Yi.BBS.Web
|
||||
services.AddControllers().AddJsonOptions(opt => {
|
||||
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
opt.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
|
||||
});
|
||||
opt.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
});
|
||||
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"Audience": "yi",
|
||||
"Issuer": "localhost:19002",
|
||||
"Subject": "yiframwork",
|
||||
"ExpSecond": 3600
|
||||
"ExpSecond": 259200
|
||||
},
|
||||
|
||||
//开启种子数据
|
||||
|
||||