feat: 完善标签分类功能
This commit is contained in:
@@ -35,6 +35,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标签
|
/// 标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HashSet<Guid>? DiscussLables { get; set; }
|
public List<Guid>? DiscussLables { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Volo.Abp.Application.Dtos;
|
using Volo.Abp.Application.Dtos;
|
||||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
|
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.Consts;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
|
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 List<Guid>? PermissionUserIds { get; set; }
|
||||||
|
|
||||||
public BbsUserGetListOutputDto User { 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()
|
public void SetBan()
|
||||||
{
|
{
|
||||||
Title = DiscussConst.Privacy;
|
Title = DiscussConst.Privacy;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Volo.Abp.Application.Dtos;
|
using Volo.Abp.Application.Dtos;
|
||||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
|
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.Application.Contracts.Dtos.Plate;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
|
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>
|
public class DiscussGetOutputDto : EntityDto<Guid>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>۴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
/// 是否禁止评论创建功能
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDisableCreateComment { get; set; }
|
public bool IsDisableCreateComment { get; set; }
|
||||||
public string Title { 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 string? Color { get; set; }
|
||||||
|
|
||||||
public Guid PlateId { get; set; }
|
public Guid PlateId { get; set; }
|
||||||
//<EFBFBD>Ƿ<EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD>false
|
//是否置顶,默认false
|
||||||
public bool IsTop { get; set; }
|
public bool IsTop { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
/// 封面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Cover { get; set; }
|
public string? Cover { get; set; }
|
||||||
//<EFBFBD>Ƿ<EFBFBD>˽<EFBFBD>У<EFBFBD>Ĭ<EFBFBD><EFBFBD>false
|
//是否私有,默认false
|
||||||
public bool IsPrivate { get; set; }
|
public bool IsPrivate { get; set; }
|
||||||
|
|
||||||
//˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ж<EFBFBD>codeȨ<EFBFBD><EFBFBD>
|
//私有需要判断code权限
|
||||||
public string? PrivateCode { get; set; }
|
public string? PrivateCode { get; set; }
|
||||||
public DateTime CreationTime { get; set; }
|
public DateTime CreationTime { get; set; }
|
||||||
public DiscussPermissionTypeEnum PermissionType { 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 BbsUserGetListOutputDto User { get; set; }
|
||||||
|
|
||||||
public PlateGetOutputDto Plate { 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>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,15 +15,20 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
|||||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
/// 封面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Cover { get; set; }
|
public string? Cover { get; set; }
|
||||||
|
|
||||||
public int OrderNum { get; set; }
|
public int OrderNum { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>۴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
/// 是否禁止评论创建功能
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDisableCreateComment { get; set; }
|
public bool IsDisableCreateComment { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签
|
||||||
|
/// </summary>
|
||||||
|
public List<Guid>? DiscussLables { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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; }
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
@@ -9,10 +10,12 @@ using Volo.Abp.EventBus.Local;
|
|||||||
using Volo.Abp.Users;
|
using Volo.Abp.Users;
|
||||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
|
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
|
||||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss;
|
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.Application.Contracts.IServices;
|
||||||
using Yi.Framework.Bbs.Domain.Entities;
|
using Yi.Framework.Bbs.Domain.Entities;
|
||||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||||
using Yi.Framework.Bbs.Domain.Managers;
|
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.Consts;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||||
@@ -36,16 +39,17 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
private ISqlSugarRepository<DiscussTopEntity> _discussTopRepository;
|
private ISqlSugarRepository<DiscussTopEntity> _discussTopRepository;
|
||||||
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
||||||
private BbsUserManager _bbsUserManager;
|
private BbsUserManager _bbsUserManager;
|
||||||
|
private IDiscussLableRepository _discussLableRepository;
|
||||||
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager,
|
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager,
|
||||||
ISqlSugarRepository<DiscussTopEntity> discussTopRepository,
|
ISqlSugarRepository<DiscussTopEntity> discussTopRepository,
|
||||||
ISqlSugarRepository<PlateAggregateRoot> plateEntityRepository, ILocalEventBus localEventBus,
|
ISqlSugarRepository<PlateAggregateRoot> plateEntityRepository, ILocalEventBus localEventBus,
|
||||||
ISqlSugarRepository<AgreeEntity> agreeRepository) : base(forumManager._discussRepository)
|
ISqlSugarRepository<AgreeEntity> agreeRepository, IDiscussLableRepository discussLableRepository) : base(forumManager._discussRepository)
|
||||||
{
|
{
|
||||||
_forumManager = forumManager;
|
_forumManager = forumManager;
|
||||||
_plateEntityRepository = plateEntityRepository;
|
_plateEntityRepository = plateEntityRepository;
|
||||||
_localEventBus = localEventBus;
|
_localEventBus = localEventBus;
|
||||||
_agreeRepository = agreeRepository;
|
_agreeRepository = agreeRepository;
|
||||||
|
_discussLableRepository = discussLableRepository;
|
||||||
_discussTopRepository = discussTopRepository;
|
_discussTopRepository = discussTopRepository;
|
||||||
_bbsUserManager = bbsUserManager;
|
_bbsUserManager = bbsUserManager;
|
||||||
}
|
}
|
||||||
@@ -57,6 +61,8 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
private ISqlSugarRepository<PlateAggregateRoot> _plateEntityRepository { get; set; }
|
private ISqlSugarRepository<PlateAggregateRoot> _plateEntityRepository { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单查
|
/// 单查
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -65,7 +71,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
public async override Task<DiscussGetOutputDto> GetAsync(Guid id)
|
public async override Task<DiscussGetOutputDto> GetAsync(Guid id)
|
||||||
{
|
{
|
||||||
//查询主题发布 浏览主题 事件,浏览数+1
|
//查询主题发布 浏览主题 事件,浏览数+1
|
||||||
var item = await _forumManager._discussRepository._DbQueryable
|
var output = await _forumManager._discussRepository._DbQueryable
|
||||||
.LeftJoin<UserAggregateRoot>((discuss, user) => discuss.CreatorId == user.Id)
|
.LeftJoin<UserAggregateRoot>((discuss, user) => discuss.CreatorId == user.Id)
|
||||||
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
|
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
|
||||||
.LeftJoin<PlateAggregateRoot>((discuss, user, info, plate) => plate.Id == discuss.PlateId)
|
.LeftJoin<PlateAggregateRoot>((discuss, user, info, plate) => plate.Id == discuss.PlateId)
|
||||||
@@ -95,24 +101,34 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
}, true)
|
}, true)
|
||||||
.FirstAsync(discuss => discuss.Id == id);
|
.FirstAsync(discuss => discuss.Id == id);
|
||||||
|
|
||||||
if (item is null)
|
if (output is null)
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException("该主题不存在", "404");
|
throw new UserFriendlyException("该主题不存在", "404");
|
||||||
}
|
}
|
||||||
|
|
||||||
//组装点赞
|
//组装点赞
|
||||||
var agreeCreatorList =
|
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)
|
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
|
await _localEventBus.PublishAsync(new SeeDiscussEventArgs
|
||||||
{ DiscussId = item.Id, OldSeeNum = item.SeeNum });
|
{ DiscussId = output.Id, OldSeeNum = output.SeeNum });
|
||||||
return item;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +184,9 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
items.ApplyPermissionTypeFilter(CurrentUser.Id ?? Guid.Empty);
|
items.ApplyPermissionTypeFilter(CurrentUser.Id ?? Guid.Empty);
|
||||||
|
|
||||||
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
|
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
|
||||||
//等级、是否点赞赋值
|
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||||
|
|
||||||
|
//组装等级、是否点赞赋值、标签
|
||||||
items?.ForEach(x =>
|
items?.ForEach(x =>
|
||||||
{
|
{
|
||||||
x.User.LevelName = levelCacheDic[x.User.Level].Name;
|
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);
|
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);
|
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
|
||||||
}
|
}
|
||||||
@@ -223,7 +250,19 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
}, true)
|
}, true)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
|
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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,5 +299,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
var entity = await _forumManager.CreateDiscussAsync(await MapToEntityAsync(input));
|
var entity = await _forumManager.CreateDiscussAsync(await MapToEntityAsync(input));
|
||||||
return await MapToGetOutputDtoAsync(entity);
|
return await MapToGetOutputDtoAsync(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override Task<DiscussGetOutputDto> UpdateAsync(Guid id, DiscussUpdateInputVo input)
|
||||||
|
{
|
||||||
|
return base.UpdateAsync(id, input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||||
|
|
||||||
|
public class DiscussLableConst
|
||||||
|
{
|
||||||
|
public const string DiscussLableCacheKey="DiscussLable:All";
|
||||||
|
}
|
||||||
@@ -67,7 +67,7 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
|||||||
public List<Guid>? PermissionUserIds { get; set; }
|
public List<Guid>? PermissionUserIds { get; set; }
|
||||||
|
|
||||||
[SugarColumn(IsJson = true)]//使用json处理
|
[SugarColumn(IsJson = true)]//使用json处理
|
||||||
public HashSet<Guid>? DiscussLables{ get; set; }
|
public List<Guid>? DiscussLables{ get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否禁止评论创建功能
|
/// 是否禁止评论创建功能
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -100,7 +100,7 @@ namespace Yi.Abp.Web
|
|||||||
Configure<AbpAuditingOptions>(options =>
|
Configure<AbpAuditingOptions>(options =>
|
||||||
{
|
{
|
||||||
//默认关闭,开启会有大量的审计日志
|
//默认关闭,开启会有大量的审计日志
|
||||||
options.IsEnabled = true;
|
options.IsEnabled = false;
|
||||||
});
|
});
|
||||||
//忽略审计日志路径
|
//忽略审计日志路径
|
||||||
Configure<AbpAspNetCoreAuditingOptions>(options =>
|
Configure<AbpAspNetCoreAuditingOptions>(options =>
|
||||||
|
|||||||
@@ -40,7 +40,8 @@
|
|||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
<div class="item item-bottom">
|
<div class="item item-bottom">
|
||||||
<div class="tag-list">
|
<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>
|
</div>
|
||||||
<el-space :size="10" :spacer="spacer">
|
<el-space :size="10" :spacer="spacer">
|
||||||
<div class="item-description">
|
<div class="item-description">
|
||||||
@@ -80,7 +81,8 @@ const discuss = reactive({
|
|||||||
agreeNum: 0,
|
agreeNum: 0,
|
||||||
isAgree: false,
|
isAgree: false,
|
||||||
cover: "",
|
cover: "",
|
||||||
isBan: false
|
isBan: false,
|
||||||
|
lables:[]
|
||||||
});
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const spacer = h(ElDivider, { direction: "vertical" });
|
const spacer = h(ElDivider, { direction: "vertical" });
|
||||||
@@ -113,15 +115,6 @@ const agree = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// id:'',
|
|
||||||
// title:"",
|
|
||||||
// introduction:"",
|
|
||||||
// creationTime:"",
|
|
||||||
// user:{},
|
|
||||||
// color:"",
|
|
||||||
// seeNum:0,
|
|
||||||
// agreeNum:0,
|
|
||||||
// isAgree:""
|
|
||||||
discuss.id = props.discuss.id;
|
discuss.id = props.discuss.id;
|
||||||
discuss.title = props.discuss.title;
|
discuss.title = props.discuss.title;
|
||||||
discuss.introduction = props.discuss.introduction;
|
discuss.introduction = props.discuss.introduction;
|
||||||
@@ -133,8 +126,7 @@ onMounted(() => {
|
|||||||
discuss.agreeNum = props.discuss.agreeNum;
|
discuss.agreeNum = props.discuss.agreeNum;
|
||||||
discuss.isBan = props.discuss.isBan;
|
discuss.isBan = props.discuss.isBan;
|
||||||
discuss.cover = props.discuss.cover;
|
discuss.cover = props.discuss.cover;
|
||||||
discuss.value = props.isAgree;
|
discuss.lables=props.discuss.lables
|
||||||
discuss.value = props.agreeNum;
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -99,9 +99,9 @@
|
|||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in labelListData"
|
v-for="item in labelListData"
|
||||||
:key="item.value.id"
|
:key="item.id"
|
||||||
:label="item.label"
|
:label="item.name"
|
||||||
:value="item.value"
|
:value="item"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -201,12 +201,7 @@ const remoteMethod = async (query) => {
|
|||||||
labelLoading.value = true
|
labelLoading.value = true
|
||||||
const {data} = await getLableAllList({name:query});
|
const {data} = await getLableAllList({name:query});
|
||||||
labelLoading.value = false
|
labelLoading.value = false
|
||||||
labelListData.value = data.items.map((item) => {
|
labelListData.value = data.items;
|
||||||
return {
|
|
||||||
value: item,
|
|
||||||
label: item.name
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//文件上传成功后
|
//文件上传成功后
|
||||||
@@ -279,6 +274,7 @@ const submit = async (formEl) => {
|
|||||||
}
|
}
|
||||||
//主题更新
|
//主题更新
|
||||||
else if (route.query.operType == "update") {
|
else if (route.query.operType == "update") {
|
||||||
|
discuss.discussLables=selectLabelList.value.map((item) =>item.id);
|
||||||
await discussUpdate(route.query.discussId, discuss);
|
await discussUpdate(route.query.discussId, discuss);
|
||||||
|
|
||||||
ElMessage({
|
ElMessage({
|
||||||
@@ -322,11 +318,6 @@ const submit = async (formEl) => {
|
|||||||
router.push(routerPer);
|
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.content = res.content;
|
||||||
editForm.title = res.title;
|
editForm.title = res.title;
|
||||||
editForm.introduction = res.introduction;
|
editForm.introduction = res.introduction;
|
||||||
|
editForm.discussLables=res.discussLables;
|
||||||
|
|
||||||
|
//编辑状态,已选择的就是全部
|
||||||
|
labelListData.value=res.lables;
|
||||||
|
selectLabelList.value=res.lables;
|
||||||
|
|
||||||
discuss.plateId = res.plateId;
|
discuss.plateId = res.plateId;
|
||||||
dialogImageUrl.value = res.cover;
|
dialogImageUrl.value = res.cover;
|
||||||
perRadio.value = res.permissionType;
|
perRadio.value = res.permissionType;
|
||||||
|
|||||||
Reference in New Issue
Block a user