|
|
@ -23,10 +23,10 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp |
|
|
protected ICommentRepository CommentRepository { get; } |
|
|
protected ICommentRepository CommentRepository { get; } |
|
|
|
|
|
|
|
|
protected ISettingManager SettingManager { get; } |
|
|
protected ISettingManager SettingManager { get; } |
|
|
|
|
|
|
|
|
public CommentAdminAppService( |
|
|
public CommentAdminAppService( |
|
|
ICommentRepository commentRepository, |
|
|
ICommentRepository commentRepository, |
|
|
ISettingManager settingManager) |
|
|
ISettingManager settingManager) |
|
|
{ |
|
|
{ |
|
|
CommentRepository = commentRepository; |
|
|
CommentRepository = commentRepository; |
|
|
SettingManager = settingManager; |
|
|
SettingManager = settingManager; |
|
|
@ -34,39 +34,38 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp |
|
|
|
|
|
|
|
|
public virtual async Task<PagedResultDto<CommentWithAuthorDto>> GetListAsync(CommentGetListInput input) |
|
|
public virtual async Task<PagedResultDto<CommentWithAuthorDto>> GetListAsync(CommentGetListInput input) |
|
|
{ |
|
|
{ |
|
|
var totalCount = await CommentRepository.GetCountAsync( |
|
|
var totalCount = await CommentRepository.GetCountAsync( |
|
|
input.Text, |
|
|
input.Text, |
|
|
input.EntityType, |
|
|
input.EntityType, |
|
|
input.RepliedCommentId, |
|
|
input.RepliedCommentId, |
|
|
input.Author, |
|
|
input.Author, |
|
|
input.CreationStartDate, |
|
|
input.CreationStartDate, |
|
|
input.CreationEndDate, |
|
|
input.CreationEndDate, |
|
|
input.CommentApproveState |
|
|
input.CommentApproveState |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
var comments = await CommentRepository.GetListAsync( |
|
|
var comments = await CommentRepository.GetListAsync( |
|
|
input.Text, |
|
|
input.Text, |
|
|
input.EntityType, |
|
|
input.EntityType, |
|
|
input.RepliedCommentId, |
|
|
input.RepliedCommentId, |
|
|
input.Author, |
|
|
input.Author, |
|
|
input.CreationStartDate, |
|
|
input.CreationStartDate, |
|
|
input.CreationEndDate, |
|
|
input.CreationEndDate, |
|
|
input.Sorting, |
|
|
input.Sorting, |
|
|
input.MaxResultCount, |
|
|
input.MaxResultCount, |
|
|
input.SkipCount, |
|
|
input.SkipCount, |
|
|
input.CommentApproveState |
|
|
input.CommentApproveState |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
var dtos = comments.Select(queryResultItem => |
|
|
var dtos = comments.Select(queryResultItem => |
|
|
{ |
|
|
{ |
|
|
var dto = ObjectMapper.Map<Comment, CommentWithAuthorDto>(queryResultItem.Comment); |
|
|
var dto = ObjectMapper.Map<Comment, CommentWithAuthorDto>(queryResultItem.Comment); |
|
|
dto.Author = ObjectMapper.Map<CmsUser, CmsUserDto>(queryResultItem.Author); |
|
|
dto.Author = ObjectMapper.Map<CmsUser, CmsUserDto>(queryResultItem.Author); |
|
|
|
|
|
|
|
|
return dto; |
|
|
return dto; |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
return new PagedResultDto<CommentWithAuthorDto>(totalCount, dtos); |
|
|
return new PagedResultDto<CommentWithAuthorDto>(totalCount, dtos); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<CommentWithAuthorDto> GetAsync(Guid id) |
|
|
public virtual async Task<CommentWithAuthorDto> GetAsync(Guid id) |
|
|
@ -89,11 +88,11 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp |
|
|
[Authorize(CmsKitAdminPermissions.Comments.Update)] |
|
|
[Authorize(CmsKitAdminPermissions.Comments.Update)] |
|
|
public async Task UpdateApprovalStatusAsync(Guid id, CommentApprovalDto input) |
|
|
public async Task UpdateApprovalStatusAsync(Guid id, CommentApprovalDto input) |
|
|
{ |
|
|
{ |
|
|
var comment = await CommentRepository.GetAsync(id); |
|
|
var comment = await CommentRepository.GetAsync(id); |
|
|
comment.IsApproved = input.IsApproved; |
|
|
comment.IsApproved = input.IsApproved; |
|
|
|
|
|
|
|
|
await CommentRepository.UpdateAsync(comment); |
|
|
await CommentRepository.UpdateAsync(comment); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(CmsKitAdminPermissions.Comments.SettingManagement)] |
|
|
[Authorize(CmsKitAdminPermissions.Comments.SettingManagement)] |
|
|
public async Task SetSettingsAsync(CommentSettingsDto input) |
|
|
public async Task SetSettingsAsync(CommentSettingsDto input) |
|
|
@ -104,16 +103,13 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp |
|
|
[Authorize(CmsKitAdminPermissions.Comments.SettingManagement)] |
|
|
[Authorize(CmsKitAdminPermissions.Comments.SettingManagement)] |
|
|
public async Task<CommentSettingsDto> GetSettingsAsync() |
|
|
public async Task<CommentSettingsDto> GetSettingsAsync() |
|
|
{ |
|
|
{ |
|
|
var isRequireApprovementEnabled = bool.Parse(await SettingManager.GetOrNullGlobalAsync(AppSettings.CommentRequireApprovement)); |
|
|
var isRequireApprovementEnabled = bool.Parse(await SettingManager.GetOrNullGlobalAsync(AppSettings.CommentRequireApprovement)); |
|
|
|
|
|
|
|
|
return new CommentSettingsDto |
|
|
return new CommentSettingsDto {CommentRequireApprovement = isRequireApprovementEnabled}; |
|
|
{ |
|
|
} |
|
|
CommentRequireApprovement = isRequireApprovementEnabled |
|
|
|
|
|
}; |
|
|
public async Task<int> GetWaitingCountAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
return (int)await CommentRepository.GetCountAsync(commentApproveState: CommentApproveState.Waiting); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
public async Task<int> GetWaitingCountAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
return (int)await CommentRepository.GetCountAsync(commentApproveState: CommentApproveState.Waiting); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|