feat: 添加首页置顶接口
This commit is contained in:
@@ -24,5 +24,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
|||||||
/// 封面
|
/// 封面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Cover { get; set; }
|
public string? Cover { get; set; }
|
||||||
|
|
||||||
|
public int OrderNum { get; set; } = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,5 +20,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
|||||||
/// <20><><EFBFBD><EFBFBD>
|
/// <20><><EFBFBD><EFBFBD>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Cover { get; set; }
|
public string? Cover { get; set; }
|
||||||
|
|
||||||
|
public int OrderNum { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ namespace Yi.Framework.Bbs.Application.Services
|
|||||||
public class DiscussService : YiCrudAppService<DiscussEntity, DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>,
|
public class DiscussService : YiCrudAppService<DiscussEntity, DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>,
|
||||||
IDiscussService
|
IDiscussService
|
||||||
{
|
{
|
||||||
public DiscussService(ForumManager forumManager, ISqlSugarRepository<PlateEntity> plateEntityRepository, ILocalEventBus localEventBus) : base(forumManager._discussRepository)
|
private ISqlSugarRepository<DiscussTopEntity> _discussTopEntityRepository;
|
||||||
|
public DiscussService(ForumManager forumManager, ISqlSugarRepository<DiscussTopEntity> discussTopEntityRepository, ISqlSugarRepository<PlateEntity> plateEntityRepository, ILocalEventBus localEventBus) : base(forumManager._discussRepository)
|
||||||
{
|
{
|
||||||
_forumManager = forumManager;
|
_forumManager = forumManager;
|
||||||
_plateEntityRepository = plateEntityRepository;
|
_plateEntityRepository = plateEntityRepository;
|
||||||
_localEventBus = localEventBus;
|
_localEventBus = localEventBus;
|
||||||
|
_discussTopEntityRepository = discussTopEntityRepository;
|
||||||
}
|
}
|
||||||
private readonly ILocalEventBus _localEventBus;
|
private readonly ILocalEventBus _localEventBus;
|
||||||
private ForumManager _forumManager { get; set; }
|
private ForumManager _forumManager { get; set; }
|
||||||
@@ -78,12 +80,17 @@ namespace Yi.Framework.Bbs.Application.Services
|
|||||||
var items = await _forumManager._discussRepository._DbQueryable
|
var items = await _forumManager._discussRepository._DbQueryable
|
||||||
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
|
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
|
||||||
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
|
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
|
||||||
.WhereIF(input.IsTop==true, x => x.IsTop == input.IsTop)
|
|
||||||
|
|
||||||
|
.WhereIF(input.IsTop == true, x => x.IsTop == input.IsTop)
|
||||||
|
|
||||||
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
|
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
|
||||||
|
|
||||||
|
.OrderByDescending(x => x.OrderNum)
|
||||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.New, discuss => discuss.CreationTime, OrderByType.Desc)
|
.OrderByIF(input.Type == QueryDiscussTypeEnum.New, discuss => discuss.CreationTime, OrderByType.Desc)
|
||||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.Host, discuss => discuss.SeeNum, OrderByType.Desc)
|
.OrderByIF(input.Type == QueryDiscussTypeEnum.Host, discuss => discuss.SeeNum, OrderByType.Desc)
|
||||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc)
|
.OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc)
|
||||||
|
|
||||||
.Select((discuss, user) => new DiscussGetListOutputDto
|
.Select((discuss, user) => new DiscussGetListOutputDto
|
||||||
{
|
{
|
||||||
Id = discuss.Id,
|
Id = discuss.Id,
|
||||||
@@ -99,6 +106,18 @@ namespace Yi.Framework.Bbs.Application.Services
|
|||||||
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
|
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取首页的置顶主题
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<DiscussGetListOutputDto>> GetListTopAsync()
|
||||||
|
{
|
||||||
|
var entities = await _discussTopEntityRepository._DbQueryable.Includes(x => x.Discuss).OrderByDescending(x => x.OrderNum).ToListAsync();
|
||||||
|
|
||||||
|
var output = await MapToGetListOutputDtosAsync(entities.Select(x => x.Discuss).ToList());
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建主题
|
/// 创建主题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -114,9 +133,6 @@ namespace Yi.Framework.Bbs.Application.Services
|
|||||||
return await MapToGetOutputDtoAsync(entity);
|
return await MapToGetOutputDtoAsync(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 效验主题查询权限
|
/// 效验主题查询权限
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ namespace Yi.Framework.Bbs.Domain.Entities
|
|||||||
//是否置顶,默认false
|
//是否置顶,默认false
|
||||||
public bool IsTop { get; set; }
|
public bool IsTop { get; set; }
|
||||||
|
|
||||||
|
public int OrderNum { get; set; } = 0;
|
||||||
|
|
||||||
|
|
||||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SqlSugar;
|
||||||
|
using Volo.Abp.Auditing;
|
||||||
|
using Volo.Abp.Domain.Entities;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Bbs.Domain.Entities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 首页置顶主题
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("DiscussTop")]
|
||||||
|
public class DiscussTopEntity : Entity<Guid>, IHasModificationTime
|
||||||
|
{
|
||||||
|
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||||
|
public override Guid Id { get; protected set; }
|
||||||
|
|
||||||
|
public int OrderNum { get; set; }
|
||||||
|
|
||||||
|
public Guid DiscussId { get; set; }
|
||||||
|
|
||||||
|
[Navigate(NavigateType.OneToOne, nameof(DiscussId))]
|
||||||
|
public DiscussEntity Discuss { get; set; }
|
||||||
|
|
||||||
|
public DateTime? LastModificationTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
4074
Yi.Abp.Net8/src/Yi.Abp.Web/logs/log-20231218.txt
Normal file
4074
Yi.Abp.Net8/src/Yi.Abp.Web/logs/log-20231218.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user