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.
74 lines
2.4 KiB
74 lines
2.4 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.GlobalFeatures;
|
|
using Volo.CmsKit.Blogs;
|
|
using Volo.CmsKit.GlobalFeatures;
|
|
using Volo.CmsKit.Permissions;
|
|
|
|
namespace Volo.CmsKit.Admin.Blogs
|
|
{
|
|
[RequiresGlobalFeature(typeof(BlogsFeature))]
|
|
[Authorize(CmsKitAdminPermissions.Blogs.Default)]
|
|
public class BlogAdminAppService : CmsKitAdminAppServiceBase, IBlogAdminAppService
|
|
{
|
|
protected IBlogRepository BlogRepository { get; }
|
|
protected BlogManager BlogManager { get; }
|
|
|
|
public BlogAdminAppService(IBlogRepository blogRepository, BlogManager blogManager)
|
|
{
|
|
BlogRepository = blogRepository;
|
|
BlogManager = blogManager;
|
|
}
|
|
|
|
public virtual async Task<BlogDto> GetAsync(Guid id)
|
|
{
|
|
var blog = await BlogRepository.GetAsync(id);
|
|
|
|
return ObjectMapper.Map<Blog, BlogDto>(blog);
|
|
}
|
|
|
|
public virtual async Task<PagedResultDto<BlogDto>> GetListAsync(BlogGetListInput input)
|
|
{
|
|
var totalCount = await BlogRepository.GetCountAsync(input.Filter);
|
|
|
|
var blogs = await BlogRepository.GetListAsync(
|
|
input.Filter,
|
|
input.Sorting,
|
|
input.MaxResultCount,
|
|
input.SkipCount);
|
|
|
|
return new PagedResultDto<BlogDto>(totalCount, ObjectMapper.Map<List<Blog>, List<BlogDto>>(blogs));
|
|
}
|
|
|
|
[Authorize(CmsKitAdminPermissions.Blogs.Create)]
|
|
public virtual async Task<BlogDto> CreateAsync(CreateBlogDto input)
|
|
{
|
|
var blog = await BlogManager.CreateAsync(input.Name, input.Slug);
|
|
|
|
await BlogRepository.InsertAsync(blog);
|
|
|
|
return ObjectMapper.Map<Blog, BlogDto>(blog);
|
|
}
|
|
|
|
[Authorize(CmsKitAdminPermissions.Blogs.Update)]
|
|
public virtual async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input)
|
|
{
|
|
var blog = await BlogRepository.GetAsync(id);
|
|
|
|
blog = await BlogManager.UpdateAsync(blog, input.Name, input.Slug);
|
|
|
|
await BlogRepository.UpdateAsync(blog);
|
|
|
|
return ObjectMapper.Map<Blog, BlogDto>(blog);
|
|
}
|
|
|
|
[Authorize(CmsKitAdminPermissions.Blogs.Delete)]
|
|
public virtual Task DeleteAsync(Guid id)
|
|
{
|
|
return BlogRepository.DeleteAsync(id);
|
|
}
|
|
}
|
|
}
|
|
|