-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from humpose/fix/mergeConflict
refactor: 리뷰 반영
- Loading branch information
Showing
3 changed files
with
253 additions
and
236 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/jeje/work/aeatbe/mapper/article/ArticleMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package jeje.work.aeatbe.mapper.article; | ||
|
||
import java.util.Arrays; | ||
import jeje.work.aeatbe.dto.article.ArticleDTO; | ||
import jeje.work.aeatbe.dto.article.ArticleResponseDTO; | ||
import jeje.work.aeatbe.entity.Article; | ||
import jeje.work.aeatbe.utility.ArticleUtil; | ||
import org.springframework.stereotype.Component; | ||
|
||
/* | ||
칼럼 매퍼 | ||
*/ | ||
@Component | ||
public class ArticleMapper { | ||
|
||
/** | ||
* Entity -> DTO | ||
* @param article | ||
* @return | ||
*/ | ||
public ArticleDTO toDTO(Article article) { | ||
return ArticleDTO.builder() | ||
.title(article.getTitle()) | ||
.date(article.getDate()) | ||
.author(article.getAuthor()) | ||
.tags(article.getTags()) | ||
.content(article.getContent()) | ||
.thumbnailUrl(article.getThumbnailUrl()) | ||
.likes(article.getLikes()) | ||
.build(); | ||
} | ||
|
||
/** | ||
* Entity -> ResponseDTO | ||
* @param article | ||
* @return | ||
*/ | ||
public ArticleResponseDTO toResponseDTO(Article article) { | ||
return ArticleResponseDTO.builder() | ||
.id(article.getId()) | ||
.title(article.getTitle()) | ||
.imgurl(article.getThumbnailUrl()) | ||
.createdAt(article.getDate()) | ||
.auth(article.getAuthor()) | ||
.keyword(Arrays.asList(article.getTags().split(","))) | ||
.content(ArticleUtil.extractContentList(article.getContent())) | ||
.subtitle(ArticleUtil.extractSubtitle(article.getContent())) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.