mirror of https://github.com/abpframework/abp.git
11 changed files with 260 additions and 49 deletions
@ -0,0 +1,20 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<AssemblyName>Volo.Blogging.Admin.Application</AssemblyName> |
||||
|
<PackageId>Volo.Blogging.Admin.Application</PackageId> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="System.Drawing.Common" Version="4.7.0" /> |
||||
|
<ProjectReference Include="..\Volo.Blogging.Admin.Application.Contracts\Volo.Blogging.Admin.Application.Contracts.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Blogging.Domain\Volo.Blogging.Domain.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Caching\Volo.Abp.Caching.csproj" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -0,0 +1,14 @@ |
|||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Blogging.Localization; |
||||
|
|
||||
|
namespace Volo.Blogging.Admin |
||||
|
{ |
||||
|
public abstract class BloggingAdminAppServiceBase : ApplicationService |
||||
|
{ |
||||
|
protected BloggingAdminAppServiceBase() |
||||
|
{ |
||||
|
ObjectMapperContext = typeof(BloggingAdminApplicationModule); |
||||
|
LocalizationResource = typeof(BloggingResource); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using AutoMapper; |
||||
|
using Volo.Blogging.Admin.Blogs; |
||||
|
using Volo.Blogging.Blogs; |
||||
|
|
||||
|
namespace Volo.Blogging.Admin |
||||
|
{ |
||||
|
public class BloggingAdminApplicationAutoMapperProfile : Profile |
||||
|
{ |
||||
|
public BloggingAdminApplicationAutoMapperProfile() |
||||
|
{ |
||||
|
CreateMap<Blog, BlogDto>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Blogging.Comments; |
||||
|
using Volo.Blogging.Posts; |
||||
|
|
||||
|
namespace Volo.Blogging.Admin |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BloggingDomainModule), |
||||
|
typeof(BloggingAdminApplicationContractsModule), |
||||
|
typeof(AbpCachingModule), |
||||
|
typeof(AbpAutoMapperModule))] |
||||
|
public class BloggingAdminApplicationModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddAutoMapperObjectMapper<BloggingAdminApplicationModule>(); |
||||
|
Configure<AbpAutoMapperOptions>(options => |
||||
|
{ |
||||
|
options.AddProfile<BloggingAdminApplicationAutoMapperProfile>(validate: true); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Blogging.Blogs; |
||||
|
|
||||
|
namespace Volo.Blogging.Admin.Blogs |
||||
|
{ |
||||
|
public class BlogManagementAppService : BloggingAdminAppServiceBase, IBlogManagementAppService |
||||
|
{ |
||||
|
private readonly IBlogRepository _blogRepository; |
||||
|
|
||||
|
public BlogManagementAppService(IBlogRepository blogRepository) |
||||
|
{ |
||||
|
_blogRepository = blogRepository; |
||||
|
} |
||||
|
|
||||
|
public async Task<ListResultDto<BlogDto>> GetListAsync() |
||||
|
{ |
||||
|
var blogs = await _blogRepository.GetListAsync(); |
||||
|
|
||||
|
return new ListResultDto<BlogDto>( |
||||
|
ObjectMapper.Map<List<Blog>, List<BlogDto>>(blogs) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
public async Task<BlogDto> GetAsync(Guid id) |
||||
|
{ |
||||
|
var blog = await _blogRepository.GetAsync(id); |
||||
|
|
||||
|
return ObjectMapper.Map<Blog, BlogDto>(blog); |
||||
|
} |
||||
|
|
||||
|
[Authorize(BloggingAdminPermissions.Blogs.Create)] |
||||
|
public async Task<BlogDto> Create(CreateBlogDto input) |
||||
|
{ |
||||
|
var newBlog = await _blogRepository.InsertAsync(new Blog(GuidGenerator.Create(), input.Name, input.ShortName) |
||||
|
{ |
||||
|
Description = input.Description |
||||
|
}); |
||||
|
|
||||
|
return ObjectMapper.Map<Blog, BlogDto>(newBlog); |
||||
|
} |
||||
|
|
||||
|
[Authorize(BloggingAdminPermissions.Blogs.Update)] |
||||
|
public async Task<BlogDto> Update(Guid id, UpdateBlogDto input) |
||||
|
{ |
||||
|
var blog = await _blogRepository.GetAsync(id); |
||||
|
|
||||
|
blog.SetName(input.Name); |
||||
|
blog.SetShortName(input.ShortName); |
||||
|
blog.Description = input.Description; |
||||
|
|
||||
|
return ObjectMapper.Map<Blog, BlogDto>(blog); |
||||
|
} |
||||
|
|
||||
|
[Authorize(BloggingAdminPermissions.Blogs.Delete)] |
||||
|
public async Task Delete(Guid id) |
||||
|
{ |
||||
|
await _blogRepository.DeleteAsync(id); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp3.1</TargetFramework> |
||||
|
<AssemblyName>Volo.Blogging.Admin.HttpApi</AssemblyName> |
||||
|
<PackageId>Volo.Blogging.Admin.HttpApi</PackageId> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Blogging.Admin.Application.Contracts\Volo.Blogging.Admin.Application.Contracts.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,56 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Blogging.Admin.Blogs; |
||||
|
|
||||
|
namespace Volo.Blogging.Admin |
||||
|
{ |
||||
|
[RemoteService(Name = BloggingAdminRemoteServiceConsts.RemoteServiceName)] |
||||
|
[Area("bloggingAdmin")] |
||||
|
[Route("api/blogging/blogs/admin")] |
||||
|
public class BlogManagementController : AbpController, IBlogManagementAppService |
||||
|
{ |
||||
|
private readonly IBlogManagementAppService _blogManagementAppService; |
||||
|
|
||||
|
public BlogManagementController(IBlogManagementAppService blogManagementAppService) |
||||
|
{ |
||||
|
_blogManagementAppService = blogManagementAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public async Task<ListResultDto<BlogDto>> GetListAsync() |
||||
|
{ |
||||
|
return await _blogManagementAppService.GetListAsync(); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("{id}")] |
||||
|
public async Task<BlogDto> GetAsync(Guid id) |
||||
|
{ |
||||
|
return await _blogManagementAppService.GetAsync(id); |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
public async Task<BlogDto> Create(CreateBlogDto input) |
||||
|
{ |
||||
|
return await _blogManagementAppService.Create(input); |
||||
|
} |
||||
|
|
||||
|
[HttpPut] |
||||
|
[Route("{id}")] |
||||
|
public async Task<BlogDto> Update(Guid id, UpdateBlogDto input) |
||||
|
{ |
||||
|
return await _blogManagementAppService.Update(id, input); |
||||
|
} |
||||
|
|
||||
|
[HttpDelete] |
||||
|
[Route("{id}")] |
||||
|
public async Task Delete(Guid id) |
||||
|
{ |
||||
|
await _blogManagementAppService.Delete(id); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using Localization.Resources.AbpUi; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Blogging.Localization; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Blogging.Admin |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BloggingAdminApplicationContractsModule), |
||||
|
typeof(AbpAspNetCoreMvcModule))] |
||||
|
public class BloggingAdminHttpApiModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
PreConfigure<IMvcBuilder>(mvcBuilder => |
||||
|
{ |
||||
|
mvcBuilder.AddApplicationPartIfNotExists(typeof(BloggingAdminHttpApiModule).Assembly); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Get<BloggingResource>() |
||||
|
.AddBaseTypes(typeof(AbpUiResource)); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue