From 175fe9b2a07c051ba7e53b624556d142e65e00d2 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 22 Jan 2019 13:33:36 +0300 Subject: [PATCH 1/2] Blogging module: added missing controllers --- .../Volo/Blogging/CommentsController.cs | 48 +++++++++++++ .../Volo/Blogging/PostsController.cs | 67 +++++++++++++++++++ .../Volo/Blogging/TagsController.cs | 35 ++++++++++ 3 files changed, 150 insertions(+) create mode 100644 modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs create mode 100644 modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs create mode 100644 modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs new file mode 100644 index 0000000000..64a079edfb --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Auditing; +using Volo.Blogging.Comments; +using Volo.Blogging.Comments.Dtos; + +namespace Volo.Blogging +{ + [RemoteService] + [Area("blogging")] + [Controller] + [ControllerName("Comments")] + [Route("api/blogging/comments")] + [DisableAuditing] + public class CommentsController : AbpController, ICommentAppService + { + [HttpGet] + [Route("{postId}")] + public Task> GetHierarchicalListOfPostAsync(Guid postId) + { + throw new NotImplementedException(); + } + + [HttpPost] + public Task CreateAsync(CreateCommentDto input) + { + throw new NotImplementedException(); + } + + [HttpPut] + [Route("{id}")] + public Task UpdateAsync(Guid id, UpdateCommentDto input) + { + throw new NotImplementedException(); + } + + [HttpDelete] + public Task DeleteAsync(Guid id) + { + throw new NotImplementedException(); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs new file mode 100644 index 0000000000..87e5551cd2 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs @@ -0,0 +1,67 @@ +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.Abp.Auditing; +using Volo.Blogging.Posts; + +namespace Volo.Blogging +{ + [RemoteService] + [Area("blogging")] + [Controller] + [ControllerName("Posts")] + [Route("api/blogging/posts")] + [DisableAuditing] + public class PostsController : AbpController, IPostAppService + { + private readonly IPostAppService _postAppService; + + public PostsController(IPostAppService postAppService) + { + _postAppService = postAppService; + } + + [HttpGet] + [Route("{blogId}/all")] + public Task> GetListByBlogIdAndTagName(Guid blogId, string tagName) + { + return _postAppService.GetListByBlogIdAndTagName(blogId, tagName); + } + + [HttpGet] + [Route("read/{id}")] + public Task GetForReadingAsync(GetPostInput input) + { + return _postAppService.GetForReadingAsync(input); + } + + [HttpGet] + [Route("{id}")] + public Task GetAsync(Guid id) + { + return _postAppService.GetAsync(id); + } + + [HttpDelete] + public Task DeleteAsync(Guid id) + { + return _postAppService.DeleteAsync(id); + } + + [HttpPost] + public Task CreateAsync(CreatePostDto input) + { + return _postAppService.CreateAsync(input); + } + + [HttpPut] + [Route("{id}")] + public Task UpdateAsync(Guid id, UpdatePostDto input) + { + return _postAppService.UpdateAsync(id, input); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs new file mode 100644 index 0000000000..71310c065d --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Auditing; +using Volo.Blogging.Tagging; +using Volo.Blogging.Tagging.Dtos; + +namespace Volo.Blogging +{ + [RemoteService] + [Area("blogging")] + [Controller] + [ControllerName("Tags")] + [Route("api/blogging/tags")] + [DisableAuditing] + public class TagsController : AbpController, ITagAppService + { + private readonly ITagAppService _tagAppService; + + public TagsController(ITagAppService tagAppService) + { + _tagAppService = tagAppService; + } + + [HttpGet] + [Route("popular/{blogId}")] + public Task> GetPopularTags(Guid blogId, GetPopularTagsInput input) + { + return _tagAppService.GetPopularTags(blogId, input); + } + } +} From 2d5f664739a7370e1128b675381ce3fe347abc4b Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 22 Jan 2019 14:10:33 +0300 Subject: [PATCH 2/2] Blogging module: controllers refactor & fixes --- .../Volo/Blogging/BlogsController.cs | 4 +--- .../Volo/Blogging/CommentsController.cs | 19 ++++++++++++------- .../Volo/Blogging/PostsController.cs | 16 +++++++--------- .../Volo/Blogging/TagsController.cs | 3 --- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs index 357dfe8b7f..9fbb70f849 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs @@ -12,10 +12,7 @@ namespace Volo.Blogging { [RemoteService] [Area("blogging")] - [Controller] - [ControllerName("Blogs")] [Route("api/blogging/blogs")] - [DisableAuditing] public class BlogsController : AbpController, IBlogAppService { private readonly IBlogAppService _blogAppService; @@ -66,6 +63,7 @@ namespace Volo.Blogging } [HttpDelete] + [Route("{id}")] public async Task Delete(Guid id) { await _blogAppService.Delete(id); diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs index 64a079edfb..518a37b809 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs @@ -13,33 +13,38 @@ namespace Volo.Blogging { [RemoteService] [Area("blogging")] - [Controller] - [ControllerName("Comments")] [Route("api/blogging/comments")] - [DisableAuditing] public class CommentsController : AbpController, ICommentAppService { + private readonly ICommentAppService _commentAppService; + + public CommentsController(ICommentAppService commentAppService) + { + _commentAppService = commentAppService; + } + [HttpGet] - [Route("{postId}")] + [Route("hierarchical/{postId}")] public Task> GetHierarchicalListOfPostAsync(Guid postId) { - throw new NotImplementedException(); + return _commentAppService.GetHierarchicalListOfPostAsync(postId); } [HttpPost] public Task CreateAsync(CreateCommentDto input) { - throw new NotImplementedException(); + return _commentAppService.CreateAsync(input); } [HttpPut] [Route("{id}")] public Task UpdateAsync(Guid id, UpdateCommentDto input) { - throw new NotImplementedException(); + return _commentAppService.UpdateAsync(id, input); } [HttpDelete] + [Route("{id}")] public Task DeleteAsync(Guid id) { throw new NotImplementedException(); diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs index 87e5551cd2..22b68cd292 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs @@ -11,10 +11,7 @@ namespace Volo.Blogging { [RemoteService] [Area("blogging")] - [Controller] - [ControllerName("Posts")] [Route("api/blogging/posts")] - [DisableAuditing] public class PostsController : AbpController, IPostAppService { private readonly IPostAppService _postAppService; @@ -45,12 +42,6 @@ namespace Volo.Blogging return _postAppService.GetAsync(id); } - [HttpDelete] - public Task DeleteAsync(Guid id) - { - return _postAppService.DeleteAsync(id); - } - [HttpPost] public Task CreateAsync(CreatePostDto input) { @@ -63,5 +54,12 @@ namespace Volo.Blogging { return _postAppService.UpdateAsync(id, input); } + + [HttpDelete] + [Route("{id}")] + public Task DeleteAsync(Guid id) + { + return _postAppService.DeleteAsync(id); + } } } diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs index 71310c065d..bdb7d1d77c 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs @@ -12,10 +12,7 @@ namespace Volo.Blogging { [RemoteService] [Area("blogging")] - [Controller] - [ControllerName("Tags")] [Route("api/blogging/tags")] - [DisableAuditing] public class TagsController : AbpController, ITagAppService { private readonly ITagAppService _tagAppService;