-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#55 feat: GET /api/v1/workbooks/{workbookId} 구현 #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~!
return dslContext.select( | ||
ArticleMst.ARTICLE_MST.ID.`as`(SelectWorkBookArticleRecord::articleId.name), | ||
ArticleMst.ARTICLE_MST.MEMBER_ID.`as`(SelectWorkBookArticleRecord::writerId.name), | ||
ArticleMst.ARTICLE_MST.MAIN_IMAGE_URL.`as`(SelectWorkBookArticleRecord::mainImageURL.name), | ||
ArticleMst.ARTICLE_MST.TITLE.`as`(SelectWorkBookArticleRecord::title.name), | ||
ArticleMst.ARTICLE_MST.CATEGORY_CD.`as`(SelectWorkBookArticleRecord::category.name), | ||
ArticleIfo.ARTICLE_IFO.CONTENT.`as`(SelectWorkBookArticleRecord::content.name), | ||
ArticleMst.ARTICLE_MST.CREATED_AT.`as`(SelectWorkBookArticleRecord::createdAt.name), | ||
MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.DAY_COL.`as`(SelectWorkBookArticleRecord::day.name) | ||
) | ||
.from(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE) | ||
.leftJoin(ArticleMst.ARTICLE_MST) | ||
.on(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.ARTICLE_ID.eq(ArticleMst.ARTICLE_MST.ID)) | ||
.leftJoin(ArticleIfo.ARTICLE_IFO) | ||
.on(ArticleMst.ARTICLE_MST.ID.eq(ArticleIfo.ARTICLE_IFO.ARTICLE_MST_ID)) | ||
.where(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.WORKBOOK_ID.eq(workbookId)) | ||
.fetchInto(SelectWorkBookMappedArticleRecord::class.java) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQL로 변환해서 보면,,,
SELECT
article_mst.id AS articleId,
article_mst.member_id AS writerId,
article_mst.main_image_url AS mainImageURL,
article_mst.title AS title,
article_mst.category_cd AS category,
article_ifo.content AS content,
article_mst.created_at AS createdAt,
mapping_workbook_article.day_col AS day
FROM
mapping_workbook_article
LEFT JOIN
article_mst
ON mapping_workbook_article.article_id = article_mst.id
LEFT JOIN
article_ifo
ON article_mst.id = article_ifo.article_mst_id
WHERE
mapping_workbook_article.workbook_id = :workbookId;
아티클mst에 row가 있다는건 아티클info에서도 row가 있다는건데 Left join을 꼭 해야할까요? 그냥 조인으로 가도 결과 똑같을듯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 그리고 deleted_at 체크 빠졌네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
join으로 해도 결과가 동일하네요! 감사함다!!
) | ||
.from(Member.MEMBER) | ||
.where(Member.MEMBER.ID.`in`(query.writerIds)) | ||
.and(Member.MEMBER.TYPE_CD.eq(1)) // todo fix after considering the type_cd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MemberType
제가 만들어둔걸로 ㄱ ㄱ (직접숫자 넣기X)
Workbook.WORKBOOK.CREATED_AT.`as`(SelectWorkBookRecord::createdAt.name) | ||
) | ||
.from(Workbook.WORKBOOK) | ||
.where(Workbook.WORKBOOK.ID.eq(query.id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete_at 필드 체크 필요할듯
val mainImageUrl: String, | ||
val title: String, | ||
val description: String, | ||
val category: String, | ||
val createdAt: LocalDateTime, | ||
val writers: List<WriterDetail>, | ||
val articles: List<ArticleDetail> | ||
) | ||
|
||
data class WriterDetail( | ||
val id: Long, | ||
val name: String, | ||
val url: URL | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WriterDetail의 url 타입은 URL이고 ReadWorkbookUseCaseOut의 mainImageUrl 타입은 String인데 이렇게 된 이유가 뭔가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 url을 dao에서 부터 String으로 가져오고 있더라고요..!
다른 url: String까지 한번에 고치겠습니다~! 감사합니다!
# Conflicts: # api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt
🎫 연관 이슈
resolved: #55
💁♂️ PR 내용
🙏 작업
🙈 PR 참고 사항
📸 스크린샷
🤖 테스트 체크리스트