mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.4 KiB
71 lines
2.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.GlobalFeatures;
|
|
using Volo.CmsKit.Comments;
|
|
using Volo.CmsKit.GlobalFeatures;
|
|
using Volo.CmsKit.Permissions;
|
|
using Volo.CmsKit.Users;
|
|
|
|
namespace Volo.CmsKit.Admin.Comments
|
|
{
|
|
[RequiresGlobalFeature(typeof(CommentsFeature))]
|
|
[Authorize(CmsKitAdminPermissions.Comments.Default)]
|
|
public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAppService
|
|
{
|
|
protected ICommentRepository CommentRepository { get; }
|
|
|
|
public CommentAdminAppService(ICommentRepository commentRepository)
|
|
{
|
|
CommentRepository = commentRepository;
|
|
}
|
|
|
|
public virtual async Task<PagedResultDto<CommentDto>> GetListAsync(CommentGetListInput input)
|
|
{
|
|
var totalCount = await CommentRepository.GetCountAsync(
|
|
input.Text,
|
|
input.EntityType,
|
|
input.EntityId,
|
|
input.RepliedCommentId,
|
|
input.CreatorId,
|
|
input.CreationStartDate,
|
|
input.CreationEndDate);
|
|
|
|
var comments = await CommentRepository.GetListAsync(
|
|
input.Text,
|
|
input.EntityType,
|
|
input.EntityId,
|
|
input.RepliedCommentId,
|
|
input.CreatorId,
|
|
input.CreationStartDate,
|
|
input.CreationEndDate,
|
|
input.Sorting,
|
|
input.MaxResultCount,
|
|
input.SkipCount
|
|
);
|
|
|
|
var dtos = ObjectMapper.Map<List<Comment>, List<CommentDto>>(comments);
|
|
|
|
return new PagedResultDto<CommentDto>(totalCount, dtos);
|
|
}
|
|
|
|
public virtual async Task<CommentWithAuthorDto> GetAsync(Guid id)
|
|
{
|
|
var comment = await CommentRepository.GetWithAuthorAsync(id);
|
|
|
|
var dto = ObjectMapper.Map<Comment, CommentWithAuthorDto>(comment.Comment);
|
|
dto.Author = ObjectMapper.Map<CmsUser, CmsUserDto>(comment.Author);
|
|
|
|
return dto;
|
|
}
|
|
|
|
[Authorize(CmsKitAdminPermissions.Comments.Delete)]
|
|
public virtual async Task DeleteAsync(Guid id)
|
|
{
|
|
var comment = await CommentRepository.GetAsync(id);
|
|
await CommentRepository.DeleteWithRepliesAsync(comment);
|
|
}
|
|
}
|
|
}
|