diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussCreateInputVo.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussCreateInputVo.cs
index 4c45a63a..3969db64 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussCreateInputVo.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussCreateInputVo.cs
@@ -35,6 +35,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
///
/// 标签
///
- public HashSet? DiscussLables { get; set; }
+ public List? DiscussLables { get; set; }
}
}
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs
index c3be2a81..8698315f 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs
@@ -1,5 +1,6 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
+using Yi.Framework.Bbs.Application.Contracts.Dtos.DiscussLable;
using Yi.Framework.Bbs.Domain.Shared.Consts;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
@@ -49,7 +50,8 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public List? PermissionUserIds { get; set; }
public BbsUserGetListOutputDto User { get; set; }
-
+ public List? DiscussLables { get; set; } = new List();
+ public List Lables { get; set; } = new List();
public void SetBan()
{
Title = DiscussConst.Privacy;
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetOutputDto.cs
index f05cbcf1..7630a087 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetOutputDto.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetOutputDto.cs
@@ -1,5 +1,6 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
+using Yi.Framework.Bbs.Application.Contracts.Dtos.DiscussLable;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
@@ -9,7 +10,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public class DiscussGetOutputDto : EntityDto
{
///
- /// Ƿֹ۴
+ /// 是否禁止评论创建功能
///
public bool IsDisableCreateComment { get; set; }
public string Title { get; set; }
@@ -21,17 +22,17 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public string? Color { get; set; }
public Guid PlateId { get; set; }
- //ǷöĬfalse
+ //是否置顶,默认false
public bool IsTop { get; set; }
///
- ///
+ /// 封面
///
public string? Cover { get; set; }
- //Ƿ˽УĬfalse
+ //是否私有,默认false
public bool IsPrivate { get; set; }
- //˽ҪжcodeȨ
+ //私有需要判断code权限
public string? PrivateCode { get; set; }
public DateTime CreationTime { get; set; }
public DiscussPermissionTypeEnum PermissionType { get; set; }
@@ -40,5 +41,8 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public BbsUserGetListOutputDto User { get; set; }
public PlateGetOutputDto Plate { get; set; }
+
+ public List? DiscussLables { get; set; } = new List();
+ public List Lables { get; set; } =new List();
}
}
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs
index ec5df132..474ca660 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussUpdateInputVo.cs
@@ -15,15 +15,20 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public DiscussPermissionTypeEnum PermissionType { get; set; }
///
- ///
+ /// 封面
///
public string? Cover { get; set; }
public int OrderNum { get; set; }
///
- /// Ƿֹ۴
+ /// 是否禁止评论创建功能
///
public bool IsDisableCreateComment { get; set; }
+
+ ///
+ /// 标签
+ ///
+ public List? DiscussLables { get; set; }
}
}
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/DiscussLable/DiscussLableGetOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/DiscussLable/DiscussLableGetOutputDto.cs
new file mode 100644
index 00000000..40ebe4c7
--- /dev/null
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/DiscussLable/DiscussLableGetOutputDto.cs
@@ -0,0 +1,11 @@
+using Volo.Abp.Application.Dtos;
+
+namespace Yi.Framework.Bbs.Application.Contracts.Dtos.DiscussLable;
+
+public class DiscussLableGetOutputDto:EntityDto
+{
+ public Guid Id { get; set; }
+ public string Name { get; set; }
+ public string? Color { get; set; }
+ public string? BackgroundColor { get; set; }
+}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs
index e0c8917e..c25b6880 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs
@@ -1,4 +1,5 @@
using System.Linq;
+using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
@@ -9,10 +10,12 @@ using Volo.Abp.EventBus.Local;
using Volo.Abp.Users;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss;
+using Yi.Framework.Bbs.Application.Contracts.Dtos.DiscussLable;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Managers;
+using Yi.Framework.Bbs.Domain.Repositories;
using Yi.Framework.Bbs.Domain.Shared.Consts;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.Bbs.Domain.Shared.Etos;
@@ -36,16 +39,17 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private ISqlSugarRepository _discussTopRepository;
private ISqlSugarRepository _agreeRepository;
private BbsUserManager _bbsUserManager;
-
+ private IDiscussLableRepository _discussLableRepository;
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager,
ISqlSugarRepository discussTopRepository,
ISqlSugarRepository plateEntityRepository, ILocalEventBus localEventBus,
- ISqlSugarRepository agreeRepository) : base(forumManager._discussRepository)
+ ISqlSugarRepository agreeRepository, IDiscussLableRepository discussLableRepository) : base(forumManager._discussRepository)
{
_forumManager = forumManager;
_plateEntityRepository = plateEntityRepository;
_localEventBus = localEventBus;
_agreeRepository = agreeRepository;
+ _discussLableRepository = discussLableRepository;
_discussTopRepository = discussTopRepository;
_bbsUserManager = bbsUserManager;
}
@@ -57,6 +61,8 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private ISqlSugarRepository _plateEntityRepository { get; set; }
+
+
///
/// 单查
///
@@ -65,7 +71,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
public async override Task GetAsync(Guid id)
{
//查询主题发布 浏览主题 事件,浏览数+1
- var item = await _forumManager._discussRepository._DbQueryable
+ var output = await _forumManager._discussRepository._DbQueryable
.LeftJoin((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin((discuss, user, info) => user.Id == info.UserId)
.LeftJoin((discuss, user, info, plate) => plate.Id == discuss.PlateId)
@@ -95,24 +101,34 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
}, true)
.FirstAsync(discuss => discuss.Id == id);
- if (item is null)
+ if (output is null)
{
throw new UserFriendlyException("该主题不存在", "404");
}
//组装点赞
var agreeCreatorList =
- (await _agreeRepository._DbQueryable.Where(x => x.DiscussId == item.Id).Select(x=>x.CreatorId).ToListAsync());
+ (await _agreeRepository._DbQueryable.Where(x => x.DiscussId == output.Id).Select(x=>x.CreatorId).ToListAsync());
//已登录
if (CurrentUser.Id is not null)
{
- item.IsAgree = agreeCreatorList.Contains(CurrentUser.Id);
+ output.IsAgree = agreeCreatorList.Contains(CurrentUser.Id);
}
-
- await _forumManager.VerifyDiscussPermissionAsync(item.Id,CurrentUser.Id);
+
+ //组装标签
+ var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
+ foreach (var lableId in output.DiscussLables)
+ {
+ if (lableDic.TryGetValue(lableId,out var item))
+ {
+ output.Lables.Add(item.Adapt());
+ }
+ }
+
+ await _forumManager.VerifyDiscussPermissionAsync(output.Id,CurrentUser.Id);
await _localEventBus.PublishAsync(new SeeDiscussEventArgs
- { DiscussId = item.Id, OldSeeNum = item.SeeNum });
- return item;
+ { DiscussId = output.Id, OldSeeNum = output.SeeNum });
+ return output;
}
@@ -168,7 +184,9 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
items.ApplyPermissionTypeFilter(CurrentUser.Id ?? Guid.Empty);
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
- //等级、是否点赞赋值
+ var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
+
+ //组装等级、是否点赞赋值、标签
items?.ForEach(x =>
{
x.User.LevelName = levelCacheDic[x.User.Level].Name;
@@ -180,6 +198,15 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
x.IsAgree = userIds.Contains(CurrentUser.Id);
}
}
+
+ foreach (var lableId in x.DiscussLables)
+ {
+ if (lableDic.TryGetValue(lableId,out var item))
+ {
+ x.Lables.Add(item.Adapt());
+ }
+ }
+
});
return new PagedResultDto(total, items);
}
@@ -223,7 +250,19 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
}, true)
.ToListAsync();
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
- output?.ForEach(x => x.User.LevelName = levelCacheDic[x.User.Level].Name);
+ var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
+
+ output?.ForEach(x =>
+ {
+ x.User.LevelName = levelCacheDic[x.User.Level].Name;
+ foreach (var lableId in x.DiscussLables)
+ {
+ if (lableDic.TryGetValue(lableId,out var item))
+ {
+ x.Lables.Add(item.Adapt());
+ }
+ }
+ });
return output;
}
@@ -260,5 +299,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
var entity = await _forumManager.CreateDiscussAsync(await MapToEntityAsync(input));
return await MapToGetOutputDtoAsync(entity);
}
+
+
+ public override Task UpdateAsync(Guid id, DiscussUpdateInputVo input)
+ {
+ return base.UpdateAsync(id, input);
+ }
}
}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Caches/DiscussLableCacheItem.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Caches/DiscussLableCacheItem.cs
new file mode 100644
index 00000000..3d374a7b
--- /dev/null
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Caches/DiscussLableCacheItem.cs
@@ -0,0 +1,9 @@
+namespace Yi.Framework.Bbs.Domain.Shared.Caches;
+
+public class DiscussLableCacheItem
+{
+ public Guid Id { get; set; }
+ public string Name { get; set; }
+ public string? Color { get; set; }
+ public string? BackgroundColor { get; set; }
+}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Consts/DiscussLableConst.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Consts/DiscussLableConst.cs
new file mode 100644
index 00000000..0c622228
--- /dev/null
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Consts/DiscussLableConst.cs
@@ -0,0 +1,6 @@
+namespace Yi.Framework.Bbs.Domain.Shared.Consts;
+
+public class DiscussLableConst
+{
+ public const string DiscussLableCacheKey="DiscussLable:All";
+}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs
index 781ec1a6..f2b1b695 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs
@@ -67,7 +67,7 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
public List? PermissionUserIds { get; set; }
[SugarColumn(IsJson = true)]//使用json处理
- public HashSet? DiscussLables{ get; set; }
+ public List? DiscussLables{ get; set; }
///
/// 是否禁止评论创建功能
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Repositories/IDiscussLableRepository.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Repositories/IDiscussLableRepository.cs
new file mode 100644
index 00000000..47ba8a5d
--- /dev/null
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Repositories/IDiscussLableRepository.cs
@@ -0,0 +1,14 @@
+using Yi.Framework.Bbs.Domain.Entities.Forum;
+using Yi.Framework.Bbs.Domain.Shared.Caches;
+using Yi.Framework.SqlSugarCore.Abstractions;
+
+namespace Yi.Framework.Bbs.Domain.Repositories;
+
+public interface IDiscussLableRepository: ISqlSugarRepository
+{
+ ///
+ /// 获取所有分类的字典
+ ///
+ ///
+ Task> GetDiscussLableCacheMapAsync();
+}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.SqlSugarCore/Repositories/DiscussLableRepository.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.SqlSugarCore/Repositories/DiscussLableRepository.cs
new file mode 100644
index 00000000..8a2020a8
--- /dev/null
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.SqlSugarCore/Repositories/DiscussLableRepository.cs
@@ -0,0 +1,37 @@
+using Mapster;
+using Volo.Abp.Caching;
+using Volo.Abp.DependencyInjection;
+using Yi.Framework.Bbs.Domain.Entities.Forum;
+using Yi.Framework.Bbs.Domain.Repositories;
+using Yi.Framework.Bbs.Domain.Shared.Caches;
+using Yi.Framework.Bbs.Domain.Shared.Consts;
+using Yi.Framework.SqlSugarCore.Abstractions;
+using Yi.Framework.SqlSugarCore.Repositories;
+
+namespace Yi.Framework.Bbs.SqlSugarCore.Repositories;
+
+public class DiscussLableRepository : SqlSugarRepository, IDiscussLableRepository,
+ ITransientDependency
+{
+ private readonly IDistributedCache> _lableCache;
+
+ public DiscussLableRepository(ISugarDbContextProvider sugarDbContextProvider,
+ IDistributedCache> lableCache) : base(sugarDbContextProvider)
+ {
+ _lableCache = lableCache;
+ }
+
+ ///
+ /// 获取所有分类的字典
+ ///
+ ///
+ public async Task> GetDiscussLableCacheMapAsync()
+ {
+ var cahce = await _lableCache.GetOrAddAsync(DiscussLableConst.DiscussLableCacheKey, async () =>
+ {
+ var entities = await _DbQueryable.ToListAsync();
+ return entities.Adapt>();
+ });
+ return cahce.ToDictionary(x => x.Id);
+ }
+}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs
index 50bc5d5b..cafc970b 100644
--- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs
+++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs
@@ -106,7 +106,7 @@ namespace Yi.Abp.Web
Configure(options =>
{
//默认关闭,开启会有大量的审计日志
- options.IsEnabled = true;
+ options.IsEnabled = false;
});
//忽略审计日志路径
Configure(options =>
diff --git a/Yi.Bbs.Vue3/src/assets/styles/index.scss b/Yi.Bbs.Vue3/src/assets/styles/index.scss
index cac88738..fe34cad5 100644
--- a/Yi.Bbs.Vue3/src/assets/styles/index.scss
+++ b/Yi.Bbs.Vue3/src/assets/styles/index.scss
@@ -129,7 +129,7 @@ table {
/* custom */
li {
- list-style: none;
+ //list-style: none;
}
button {
diff --git a/Yi.Bbs.Vue3/src/components/ArticleContentInfo.vue b/Yi.Bbs.Vue3/src/components/ArticleContentInfo.vue
index 93c8665c..597abc4a 100644
--- a/Yi.Bbs.Vue3/src/components/ArticleContentInfo.vue
+++ b/Yi.Bbs.Vue3/src/components/ArticleContentInfo.vue
@@ -1,10 +1,14 @@