Skip to content

Commit 8869cce

Browse files
authored
Merge pull request #23 from KYJKY/master
Feat: 게시글 상세 조회 API에서 좋아요 수를 가져오도록 수정
2 parents 7bf80ca + 88ef939 commit 8869cce

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Service/Models/PostService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ public async Task<IEnumerable<PostDto>> GetAllPost(bool trackChanges)
4343
public async Task<PostPostPhotoDto> GetPost(int postId, bool trackChanges)
4444
{
4545
var post = await _repository.Post.GetPostById(postId, trackChanges);
46+
int likeNum = await _repository.Like.GetLikeCountByPostId(postId, trackChanges);
4647

4748
if (post is null)
4849
throw new PostNotFoundException(postId);
4950

5051
var postDto = _mapper.Map<PostPostPhotoDto>(post);
52+
postDto.LikeCount = likeNum;
5153

5254
return postDto;
5355
}

Shared/DataTransferObject/OutputDto/PostPostPhotoDto.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class PostPostPhotoDto
1414
public double? x {get; set;}
1515
public double? y {get; set;}
1616
public ICollection<PostPhotoDto> PostPhotos { get; set; }
17+
public int LikeCount {get; set;}
1718
public DateTime? UpdateDate {get; set;}
1819
public DateTime? CreatedDate {get; set;}
1920
}

0 commit comments

Comments
 (0)