diff --git a/src/EasyAbp.EasyComment.Application.Contracts/Comments/Dtos/CommentDto.cs b/src/EasyAbp.EasyComment.Application.Contracts/Comments/Dtos/CommentDto.cs index 650c513..2cd569c 100644 --- a/src/EasyAbp.EasyComment.Application.Contracts/Comments/Dtos/CommentDto.cs +++ b/src/EasyAbp.EasyComment.Application.Contracts/Comments/Dtos/CommentDto.cs @@ -13,5 +13,7 @@ public class CommentDto : FullAuditedEntityDto public string Content { get; set; } public Guid? ReplyTo { get; set; } + + public string CreatorName { get; set; } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs b/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs index 3554b6a..c8b56b8 100644 --- a/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs +++ b/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization; using Volo.Abp; using Volo.Abp.Application.Services; +using Volo.Abp.Threading; using Volo.Abp.Users; namespace EasyAbp.EasyComment.Comments @@ -17,10 +18,12 @@ public class CommentAppService : CrudAppService CreateFilteredQuery(GetListInput input) @@ -43,6 +46,15 @@ protected override IQueryable ApplySorting(IQueryable query, G } } + protected override CommentDto MapToGetListOutputDto(Comment entity) + { + var dto = base.MapToGetListOutputDto(entity); + var creator = AsyncHelper.RunSync(() => _userLookupServiceProvider.FindByIdAsync(entity.CreatorId.GetValueOrDefault())); + dto.CreatorName = creator.Name; + + return dto; + } + [Authorize] public virtual async Task UpdateContentAsync(UpdateContentInput input) { diff --git a/src/EasyAbp.EasyComment.Application/EasyAbp.EasyComment.Application.csproj b/src/EasyAbp.EasyComment.Application/EasyAbp.EasyComment.Application.csproj index c69f19a..e5109a1 100644 --- a/src/EasyAbp.EasyComment.Application/EasyAbp.EasyComment.Application.csproj +++ b/src/EasyAbp.EasyComment.Application/EasyAbp.EasyComment.Application.csproj @@ -10,6 +10,7 @@ + diff --git a/src/EasyAbp.EasyComment.Application/EasyCommentApplicationAutoMapperProfile.cs b/src/EasyAbp.EasyComment.Application/EasyCommentApplicationAutoMapperProfile.cs index 030be33..0ed604c 100644 --- a/src/EasyAbp.EasyComment.Application/EasyCommentApplicationAutoMapperProfile.cs +++ b/src/EasyAbp.EasyComment.Application/EasyCommentApplicationAutoMapperProfile.cs @@ -11,7 +11,9 @@ public EasyCommentApplicationAutoMapperProfile() /* You can configure your AutoMapper mapping configuration here. * Alternatively, you can split your mapping configurations * into multiple profile classes for a better organization. */ - CreateMap(); + CreateMap() + .ForMember(dest => dest.CreatorName, opt => opt.Ignore()) + ; CreateMap(MemberList.Source); } } diff --git a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.cshtml index 8756520..5d343af 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.cshtml @@ -3,14 +3,21 @@ @using Microsoft.AspNetCore.Mvc.Localization @inject IHtmlLocalizer L -
- @L["TotalComments", Model.TotalCount] + + + @L["TotalComments", Model.TotalCount] + + @{ int i = 1;} @foreach (CommentDto comment in Model.Items) { - @comment.CreatorId @comment.CreationTime -

@comment.Content

+ + #@(i++) +

@comment.CreatorName

+ @comment.CreationTime +
+

@comment.Content


} -
\ No newline at end of file + \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.css b/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.css index 265b974..3f1f9a8 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.css +++ b/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.css @@ -1,3 +1,27 @@ div.ec-comments { margin: 10px; +} + +div.ec-comment { + margin: 10px; +} + +div.ec-comment span { + margin-left: 5px; +} + +a.ec-comment-link { + margin-right: 5px; +} + +p.ec-creator { + font-weight: bold; +} + +p.ec-content { + line-break: anywhere; +} + +span.ec-comment-time { + color: gray; } \ No newline at end of file