Merge branch 'abp' into digital-collectibles

This commit is contained in:
橙子
2025-01-19 15:42:10 +08:00
16 changed files with 182 additions and 56 deletions

View File

@@ -35,6 +35,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
/// <summary>
/// 标签
/// </summary>
public HashSet<Guid>? DiscussLables { get; set; }
public List<Guid>? DiscussLables { get; set; }
}
}

View File

@@ -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<Guid>? PermissionUserIds { get; set; }
public BbsUserGetListOutputDto User { get; set; }
public List<Guid>? DiscussLables { get; set; } = new List<Guid>();
public List<DiscussLableGetOutputDto> Lables { get; set; } = new List<DiscussLableGetOutputDto>();
public void SetBan()
{
Title = DiscussConst.Privacy;

View File

@@ -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<Guid>
{
/// <summary>
/// <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>۴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// 是否禁止评论创建功能
/// </summary>
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; }
//<EFBFBD>Ƿ<EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD>false
//是否置顶,默认false
public bool IsTop { get; set; }
/// <summary>
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// 封面
/// </summary>
public string? Cover { get; set; }
//<EFBFBD>Ƿ<EFBFBD>˽<EFBFBD>У<EFBFBD>Ĭ<EFBFBD><EFBFBD>false
//是否私有,默认false
public bool IsPrivate { get; set; }
//˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ж<EFBFBD>codeȨ<EFBFBD><EFBFBD>
//私有需要判断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<Guid>? DiscussLables { get; set; } = new List<Guid>();
public List<DiscussLableGetOutputDto> Lables { get; set; } =new List<DiscussLableGetOutputDto>();
}
}

View File

@@ -15,15 +15,20 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public DiscussPermissionTypeEnum PermissionType { get; set; }
/// <summary>
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// 封面
/// </summary>
public string? Cover { get; set; }
public int OrderNum { get; set; }
/// <summary>
/// <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>۴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// 是否禁止评论创建功能
/// </summary>
public bool IsDisableCreateComment { get; set; }
/// <summary>
/// 标签
/// </summary>
public List<Guid>? DiscussLables { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
using Volo.Abp.Application.Dtos;
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.DiscussLable;
public class DiscussLableGetOutputDto:EntityDto<Guid>
{
public Guid Id { get; set; }
public string Name { get; set; }
public string? Color { get; set; }
public string? BackgroundColor { get; set; }
}

View File

@@ -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<DiscussTopEntity> _discussTopRepository;
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
private BbsUserManager _bbsUserManager;
private IDiscussLableRepository _discussLableRepository;
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager,
ISqlSugarRepository<DiscussTopEntity> discussTopRepository,
ISqlSugarRepository<PlateAggregateRoot> plateEntityRepository, ILocalEventBus localEventBus,
ISqlSugarRepository<AgreeEntity> agreeRepository) : base(forumManager._discussRepository)
ISqlSugarRepository<AgreeEntity> 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<PlateAggregateRoot> _plateEntityRepository { get; set; }
/// <summary>
/// 单查
/// </summary>
@@ -65,7 +71,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
public async override Task<DiscussGetOutputDto> GetAsync(Guid id)
{
//查询主题发布 浏览主题 事件,浏览数+1
var item = await _forumManager._discussRepository._DbQueryable
var output = await _forumManager._discussRepository._DbQueryable
.LeftJoin<UserAggregateRoot>((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
.LeftJoin<PlateAggregateRoot>((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<DiscussLableGetOutputDto>());
}
}
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<DiscussLableGetOutputDto>());
}
}
});
return new PagedResultDto<DiscussGetListOutputDto>(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<DiscussLableGetOutputDto>());
}
}
});
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<DiscussGetOutputDto> UpdateAsync(Guid id, DiscussUpdateInputVo input)
{
return base.UpdateAsync(id, input);
}
}
}

View File

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

View File

@@ -0,0 +1,6 @@
namespace Yi.Framework.Bbs.Domain.Shared.Consts;
public class DiscussLableConst
{
public const string DiscussLableCacheKey="DiscussLable:All";
}

View File

@@ -67,7 +67,7 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
public List<Guid>? PermissionUserIds { get; set; }
[SugarColumn(IsJson = true)]//使用json处理
public HashSet<Guid>? DiscussLables{ get; set; }
public List<Guid>? DiscussLables{ get; set; }
/// <summary>
/// 是否禁止评论创建功能

View File

@@ -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<DiscussLableAggregateRoot,Guid>
{
/// <summary>
/// 获取所有分类的字典
/// </summary>
/// <returns></returns>
Task<Dictionary<Guid, DiscussLableCacheItem>> GetDiscussLableCacheMapAsync();
}

View File

@@ -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<DiscussLableAggregateRoot, Guid>, IDiscussLableRepository,
ITransientDependency
{
private readonly IDistributedCache<List<DiscussLableCacheItem>> _lableCache;
public DiscussLableRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider,
IDistributedCache<List<DiscussLableCacheItem>> lableCache) : base(sugarDbContextProvider)
{
_lableCache = lableCache;
}
/// <summary>
/// 获取所有分类的字典
/// </summary>
/// <returns></returns>
public async Task<Dictionary<Guid, DiscussLableCacheItem>> GetDiscussLableCacheMapAsync()
{
var cahce = await _lableCache.GetOrAddAsync(DiscussLableConst.DiscussLableCacheKey, async () =>
{
var entities = await _DbQueryable.ToListAsync();
return entities.Adapt<List<DiscussLableCacheItem>>();
});
return cahce.ToDictionary(x => x.Id);
}
}

View File

@@ -106,7 +106,7 @@ namespace Yi.Abp.Web
Configure<AbpAuditingOptions>(options =>
{
//默认关闭,开启会有大量的审计日志
options.IsEnabled = true;
options.IsEnabled = false;
});
//忽略审计日志路径
Configure<AbpAspNetCoreAuditingOptions>(options =>

View File

@@ -129,7 +129,7 @@ table {
/* custom */
li {
list-style: none;
//list-style: none;
}
button {

View File

@@ -1,10 +1,14 @@
<style scoped lang="scss">
::v-deep(.li-list){
list-style: inside !important;
//list-style: decimal !important;
}
//::v-deep(ol .li-list){
// list-style: decimal;
//}
//::v-deep(ul .li-list){
// list-style: disc;
//}
::v-deep(.pre-out)
{
padding: 0;

View File

@@ -40,7 +40,8 @@
<!-- 底部 -->
<div class="item item-bottom">
<div class="tag-list">
<el-tag v-for="i in 4" :key="i">教程</el-tag>
<el-tag v-if="discuss.lables.length===0">暂无标签</el-tag>
<el-tag v-for="item in discuss.lables" :key="item.id">{{item.name}}</el-tag>
</div>
<el-space :size="10" :spacer="spacer">
<div class="item-description">
@@ -80,7 +81,8 @@ const discuss = reactive({
agreeNum: 0,
isAgree: false,
cover: "",
isBan: false
isBan: false,
lables:[]
});
const router = useRouter();
const spacer = h(ElDivider, { direction: "vertical" });
@@ -113,15 +115,6 @@ const agree = async () => {
}
};
onMounted(() => {
// id:'',
// title:"",
// introduction:"",
// creationTime:"",
// user:{},
// color:"",
// seeNum:0,
// agreeNum:0,
// isAgree:""
discuss.id = props.discuss.id;
discuss.title = props.discuss.title;
discuss.introduction = props.discuss.introduction;
@@ -133,8 +126,7 @@ onMounted(() => {
discuss.agreeNum = props.discuss.agreeNum;
discuss.isBan = props.discuss.isBan;
discuss.cover = props.discuss.cover;
discuss.value = props.isAgree;
discuss.value = props.agreeNum;
discuss.lables=props.discuss.lables
});
</script>
<style scoped lang="scss">

View File

@@ -99,9 +99,9 @@
>
<el-option
v-for="item in labelListData"
:key="item.value.id"
:label="item.label"
:value="item.value"
:key="item.id"
:label="item.name"
:value="item"
/>
</el-select>
</el-form-item>
@@ -201,12 +201,7 @@ const remoteMethod = async (query) => {
labelLoading.value = true
const {data} = await getLableAllList({name:query});
labelLoading.value = false
labelListData.value = data.items.map((item) => {
return {
value: item,
label: item.name
}
})
labelListData.value = data.items;
}
//文件上传成功后
@@ -279,6 +274,7 @@ const submit = async (formEl) => {
}
//主题更新
else if (route.query.operType == "update") {
discuss.discussLables=selectLabelList.value.map((item) =>item.id);
await discussUpdate(route.query.discussId, discuss);
ElMessage({
@@ -322,11 +318,6 @@ const submit = async (formEl) => {
router.push(routerPer);
}
}
//添加成功后跳转到该页面
// var routerPer = { path: `/discuss/${discuss.plateId}` };
// router.push(routerPer);
// ruleFormRef.value.resetFields();
// discuss.plateId = route.query.plateId;
}
});
};
@@ -351,6 +342,12 @@ const loadDiscuss = async () => {
editForm.content = res.content;
editForm.title = res.title;
editForm.introduction = res.introduction;
editForm.discussLables=res.discussLables;
//编辑状态,已选择的就是全部
labelListData.value=res.lables;
selectLabelList.value=res.lables;
discuss.plateId = res.plateId;
dialogImageUrl.value = res.cover;
perRadio.value = res.permissionType;