feat:完善discuss主题相关功能及界面
@@ -11,6 +11,7 @@
|
||||
<Compile Include="..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\rbac\Yi.RBAC.Application.Contracts\Yi.RBAC.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Yi.BBS.Domain.Shared\Yi.BBS.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -64,6 +64,13 @@
|
||||
Discuss应用服务实现,用于参数效验、领域服务业务组合、日志记录、事务处理、账户信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.GetAsync(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.GetListAsync(Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListInputVo)">
|
||||
<summary>
|
||||
查询
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
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 QueryDiscussTypeEnum
|
||||
{
|
||||
New,
|
||||
Suggest,
|
||||
Host
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.BBS.Domain.Shared.Forum.Etos
|
||||
{
|
||||
public class SeeDiscussEventArgs
|
||||
{
|
||||
public long DiscussId { get; set; }
|
||||
public int OldSeeNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cike.EventBus.EventHandlerAbstracts;
|
||||
using Yi.BBS.Domain.Forum.Entities;
|
||||
using Yi.BBS.Domain.Shared.Forum.Etos;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.RBAC.Domain.Shared.Identity.Etos;
|
||||
|
||||
namespace Yi.BBS.Domain.Forum.Event
|
||||
{
|
||||
public class SeeDiscussEventHandler : IDistributedEventHandler<SeeDiscussEventArgs>
|
||||
{
|
||||
private IRepository<DiscussEntity> _repository;
|
||||
public SeeDiscussEventHandler(IRepository<DiscussEntity> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
public async Task HandlerAsync(SeeDiscussEventArgs eventData)
|
||||
{
|
||||
var entity= await _repository.GetByIdAsync(eventData.DiscussId);
|
||||
if (entity is not null) {
|
||||
entity.SeeNum += 1;
|
||||
await _repository.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 616 KiB |
|
After Width: | Height: | Size: 616 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -3,6 +3,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;
|
||||
|
||||
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
@@ -12,5 +14,11 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public string? Title { get; set; }
|
||||
|
||||
public long? PlateId { get; set; }
|
||||
|
||||
//Ĭ<>ϲ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD>ö<EFBFBD>
|
||||
public bool IsTop { get; set; } = false;
|
||||
|
||||
//<2F><>ѯ<EFBFBD><D1AF>ʽ
|
||||
public QueryDiscussTypeEnum Type { get; set; } = QueryDiscussTypeEnum.New;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||
|
||||
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
{
|
||||
@@ -15,12 +16,24 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public string Title { get; set; }
|
||||
public string Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
public long PlateId { get; set; }
|
||||
|
||||
//<2F>Ƿ<EFBFBD><C7B7>ö<EFBFBD><C3B6><EFBFBD>Ĭ<EFBFBD><C4AC>false
|
||||
public bool IsTop { 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 UserGetListOutputDto User { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||
|
||||
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
{
|
||||
@@ -15,12 +16,23 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
public string Title { get; set; }
|
||||
public string Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
public long PlateId { get; set; }
|
||||
//<2F>Ƿ<EFBFBD><C7B7>ö<EFBFBD><C3B6><EFBFBD>Ĭ<EFBFBD><C4AC>false
|
||||
public bool IsTop { 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 UserGetListOutputDto User { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<Compile Include="..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\rbac\Yi.RBAC.Application.Contracts\Yi.RBAC.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Yi.BBS.Domain.Shared\Yi.BBS.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -64,6 +64,13 @@
|
||||
Discuss应用服务实现,用于参数效验、领域服务业务组合、日志记录、事务处理、账户信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.GetAsync(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.DiscussService.GetListAsync(Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListInputVo)">
|
||||
<summary>
|
||||
查询
|
||||
|
||||
@@ -12,6 +12,11 @@ using SqlSugar;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Yi.BBS.Domain.Shared.Forum.ConstClasses;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.RBAC.Domain.Identity.Entities;
|
||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||
using Cike.EventBus.DistributedEvent;
|
||||
using Yi.BBS.Domain.Shared.Forum.Etos;
|
||||
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
|
||||
|
||||
namespace Yi.BBS.Application.Forum
|
||||
{
|
||||
@@ -28,6 +33,28 @@ namespace Yi.BBS.Application.Forum
|
||||
[Autowired]
|
||||
private IRepository<PlateEntity> _plateEntityRepository { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IDistributedEventBus _distributedEventBus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <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);
|
||||
|
||||
_distributedEventBus.PublishAsync(new SeeDiscussEventArgs { DiscussId= item.Id, OldSeeNum= item .SeeNum});
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
@@ -36,13 +63,19 @@ namespace Yi.BBS.Application.Forum
|
||||
|
||||
public override async Task<PagedResultDto<DiscussGetListOutputDto>> GetListAsync( [FromQuery] DiscussGetListInputVo input)
|
||||
{
|
||||
//需要关联创建者用户
|
||||
RefAsync<int> total = 0;
|
||||
var entities = await _DbQueryable
|
||||
var items = await _DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
|
||||
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
|
||||
.OrderByDescending(x => x.CreateTime)
|
||||
.Where(x=>x.IsTop==input.IsTop)
|
||||
.OrderByIF(input.Type==QueryDiscussTypeEnum.New, x =>x.CreationTime,OrderByType.Desc )
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.Host, x => x.SeeNum, OrderByType.Desc)
|
||||
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId==user.Id)
|
||||
.Select((discuss,user) =>new DiscussGetListOutputDto {
|
||||
User=new UserGetListOutputDto() { UserName=user.UserName,Nick=user.Nick, Icon = user.Icon }
|
||||
},true)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
var items = await MapToGetListOutputDtosAsync(entities);
|
||||
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Yi.Framework.Data.Auditing;
|
||||
using Yi.Framework.Data.Entities;
|
||||
using Yi.Framework.Ddd.Entities;
|
||||
|
||||
namespace Yi.BBS.Domain.Forum.Entities
|
||||
{
|
||||
[SugarTable("Discuss")]
|
||||
public class DiscussEntity : IEntity<long>, ISoftDelete
|
||||
public class DiscussEntity : IEntity<long>, ISoftDelete,IAuditedObject
|
||||
{
|
||||
public DiscussEntity()
|
||||
{
|
||||
@@ -26,7 +27,6 @@ namespace Yi.BBS.Domain.Forum.Entities
|
||||
public string Title { get; set; }
|
||||
public string Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
|
||||
@@ -36,7 +36,23 @@ namespace Yi.BBS.Domain.Forum.Entities
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
//是否置顶,默认false
|
||||
public bool IsTop { get; set; }
|
||||
|
||||
|
||||
//是否私有,默认false
|
||||
public bool IsPrivate { get; set; }
|
||||
|
||||
//私有需要判断code权限
|
||||
public string? PrivateCode { get; set; }
|
||||
|
||||
public long PlateId { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public long? CreatorId { get; set; }
|
||||
|
||||
public long? LastModifierId { get; set; }
|
||||
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Yi.BBS.Domain.Forum
|
||||
entity.Types = types;
|
||||
entity.Introduction = introduction;
|
||||
entity.Content = content;
|
||||
entity.CreateTime = DateTime.Now;
|
||||
entity.CreationTime = DateTime.Now;
|
||||
entity.AgreeNum = 0;
|
||||
entity.SeeNum = 0;
|
||||
return await _discussRepository.InsertReturnEntityAsync(entity);
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Yi.RBAC.Domain.Identity
|
||||
|
||||
if (!user.JudgePassword(oldPassword))
|
||||
{
|
||||
throw new UserFriendlyException("无效更新!新密码不能与老密码相同");
|
||||
throw new UserFriendlyException("无效更新!原密码错误!");
|
||||
}
|
||||
user.Password = newPassword;
|
||||
user.BuildPassword();
|
||||
|
||||