添加评论模块

This commit is contained in:
橙子
2023-01-26 11:25:04 +08:00
parent ac26df6827
commit 38d69c9e6f
12 changed files with 193 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ TemplateFactory templateFactory = new();
//List<string> entityNames = new() { "Banner" };
string modelName = "Forum";
string nameSpaces = "Yi.BBS";
List<string> entityNames = new() { "Plate" };
List<string> entityNames = new() { "Comment" };

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
{
/// <summary>
/// Comment输入创建对象
/// </summary>
public class CommentCreateInputVo
{
public long Id { get; set; }
public DateTime? CreateTime { get; set; }
public string Content { get; set; }
public long DiscussId { get; set; }
public long UserId { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
{
public class CommentGetListInputVo : PagedAndSortedResultRequestDto
{
public long Id { get; set; }
public DateTime? CreateTime { get; set; }
public string Content { get; set; }
public long DiscussId { get; set; }
public long UserId { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
{
public class CommentGetListOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public DateTime? CreateTime { get; set; }
public string Content { get; set; }
public long DiscussId { get; set; }
public long UserId { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
{
public class CommentGetOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public DateTime? CreateTime { get; set; }
public string Content { get; set; }
public long DiscussId { get; set; }
public long UserId { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
{
public class CommentUpdateInputVo
{
public long Id { get; set; }
public DateTime? CreateTime { get; set; }
public string Content { get; set; }
public long DiscussId { get; set; }
public long UserId { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.Framework.Ddd.Services.Abstract;
namespace Yi.BBS.Application.Contracts.Forum
{
/// <summary>
/// Comment服务抽象
/// </summary>
public interface ICommentService : ICrudAppService<CommentGetOutputDto, CommentGetListOutputDto, long, CommentGetListInputVo, CommentCreateInputVo, CommentUpdateInputVo>
{
}
}

View File

@@ -0,0 +1,17 @@
using Yi.BBS.Application.Contracts.Forum;
using NET.AutoWebApi.Setting;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Domain.Forum.Entities;
using Yi.Framework.Ddd.Services;
namespace Yi.BBS.Application.Forum
{
/// <summary>
/// Comment服务实现
/// </summary>
[AppService]
public class CommentService : CrudAppService<CommentEntity, CommentGetOutputDto, CommentGetListOutputDto, long, CommentGetListInputVo, CommentCreateInputVo, CommentUpdateInputVo>,
ICommentService, IAutoApiService
{
}
}

View File

@@ -0,0 +1,23 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Domain.Forum.Entities;
namespace Yi.BBS.Application.Forum.MapperConfig
{
public class CommentProfile: Profile
{
public CommentProfile()
{
CreateMap<CommentGetListInputVo, CommentEntity>();
CreateMap<CommentCreateInputVo, CommentEntity>();
CreateMap<CommentUpdateInputVo, CommentEntity>();
CreateMap<CommentEntity, CommentGetListOutputDto>();
CreateMap<CommentEntity, CommentGetOutputDto>();
}
}
}

View File

@@ -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.ConstClasses
{
/// <summary>
/// 常量定义
/// </summary>
public class CommentConst
{
}
}

View File

@@ -0,0 +1,25 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Entities;
namespace Yi.BBS.Domain.Forum.Entities
{
[SugarTable("Comment")]
public class CommentEntity : IEntity<long>, ISoftDelete
{
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public bool IsDeleted { get; set; }
public DateTime? CreateTime { get; set; }
public string Content { get; set; }
public long DiscussId { get; set; }
public long UserId { get; set; }
}
}

View File

@@ -17,7 +17,8 @@ namespace Yi.BBS.Domain.Forum
{
private readonly IRepository<DiscussEntity> _discussRepository;
private readonly IRepository<PlateEntity> _plateEntityRepository;
public ForumManager(IRepository<DiscussEntity> discussRepository, IRepository<PlateEntity> plateEntityRepository)
private readonly IRepository<CommentEntity> commentRepository;
public ForumManager(IRepository<DiscussEntity> discussRepository, IRepository<PlateEntity> plateEntityRepository,IRepository<CommentEntity> commentRepository)
{
_discussRepository = discussRepository;
_plateEntityRepository = plateEntityRepository;