Skip to content

Commit f62ed01

Browse files
committed
Post Edit & create
1 parent f520c7e commit f62ed01

File tree

22 files changed

+399
-18
lines changed

22 files changed

+399
-18
lines changed

modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/IBlogAppService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ public interface IBlogAppService : IApplicationService
1212
Task<ListResultDto<BlogDto>> GetListAsync();
1313

1414
Task<BlogDto> GetByShortNameAsync(string shortName);
15+
16+
Task<BlogDto> GetAsync(Guid id);
1517
}
1618
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Volo.Abp.Application.Dtos;
5+
6+
namespace Volo.Blogging.Posts
7+
{
8+
public class CreatePostDto
9+
{
10+
public Guid BlogId { get; set; }
11+
12+
public string Title { get; set; }
13+
14+
public string Content { get; set; }
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Volo.Abp.Application.Dtos;
5+
6+
namespace Volo.Blogging.Posts
7+
{
8+
public class GetPostForEditOutput : FullAuditedEntityDto<Guid>
9+
{
10+
public Guid BlogId { get; set; }
11+
12+
public string Title { get; set; }
13+
14+
public string Content { get; set; }
15+
}
16+
}

modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ namespace Volo.Blogging.Posts
99
{
1010
public interface IPostAppService : IApplicationService
1111
{
12-
ListResultDto<PostDto> GetPostsByBlogId(Guid id);
12+
ListResultDto<PostWithDetailsDto> GetListByBlogIdAsync(Guid id);
1313

14-
Task<PostDto> GetPost(GetPostInput input);
14+
Task<PostWithDetailsDto> GetByTitleAsync(GetPostInput input);
15+
16+
Task<PostWithDetailsDto> GetAsync(Guid id);
17+
18+
Task<PostWithDetailsDto> CreateAsync(CreatePostDto input);
19+
20+
Task<PostWithDetailsDto> UpdateAsync(Guid id, UpdatePostDto input);
1521
}
1622
}

modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/PostDto.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33

44
namespace Volo.Blogging.Posts
55
{
6-
public class PostDto : EntityDto<Guid>
6+
public class PostDto : FullAuditedEntityDto<Guid>
77
{
88
public Guid BlogId { get; protected set; }
99

1010
public string Title { get; protected set; }
1111

1212
public string Content { get; set; }
13-
14-
public DateTime CreationTime { get; set; }
1513
}
1614
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Volo.Abp.Application.Dtos;
5+
6+
namespace Volo.Blogging.Posts
7+
{
8+
public class PostWithDetailsDto : FullAuditedEntityDto<Guid>
9+
{
10+
public Guid BlogId { get; set; }
11+
12+
public string Title { get; set; }
13+
14+
public string Content { get; set; }
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Volo.Abp.Application.Dtos;
5+
6+
namespace Volo.Blogging.Posts
7+
{
8+
public class UpdatePostDto
9+
{
10+
public Guid BlogId { get; set; }
11+
12+
public string Title { get; set; }
13+
14+
public string Content { get; set; }
15+
}
16+
}

modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/BloggingApplicationAutoMapperProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AutoMapper;
2+
using Volo.Abp.AutoMapper;
23
using Volo.Blogging.Blogs;
34
using Volo.Blogging.Posts;
45

@@ -10,6 +11,7 @@ public BloggingApplicationAutoMapperProfile()
1011
{
1112
CreateMap<Blog, BlogDto>();
1213
CreateMap<Post, PostDto>();
14+
CreateMap<Post, PostWithDetailsDto>();
1315
}
1416
}
1517
}

modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/BloggingApplicationModule.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class BloggingApplicationModule : AbpModule
1414
{
1515
public override void ConfigureServices(IServiceCollection services)
1616
{
17+
services.Configure<AbpAutoMapperOptions>(options =>
18+
{
19+
options.AddProfile<BloggingApplicationAutoMapperProfile>(validate: true);
20+
});
21+
1722
services.AddAssemblyOf<BloggingApplicationModule>();
1823
}
1924
}

modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Threading.Tasks;
34
using Volo.Abp.Application.Dtos;
45
using Volo.Abp.Application.Services;
@@ -34,6 +35,12 @@ public async Task<BlogDto> GetByShortNameAsync(string shortName)
3435

3536
return ObjectMapper.Map<Blog, BlogDto>(blog);
3637
}
37-
38+
39+
public async Task<BlogDto> GetAsync(Guid id)
40+
{
41+
var blog = await _blogRepository.GetAsync(id);
42+
43+
return ObjectMapper.Map<Blog, BlogDto>(blog);
44+
}
3845
}
3946
}

0 commit comments

Comments
 (0)