From 49d46555b5da8fca4540252e11540933a6dd3288 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 19:21:09 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20member,=20article=5Fmain=5Fcard=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=BB=AC=EB=9F=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20=EB=A9=A4=EB=B2=84=20image=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/db/migration/entity/V1.00.0.16__add_col_member_tb.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 data/db/migration/entity/V1.00.0.16__add_col_member_tb.sql diff --git a/data/db/migration/entity/V1.00.0.16__add_col_member_tb.sql b/data/db/migration/entity/V1.00.0.16__add_col_member_tb.sql new file mode 100644 index 000000000..10186b637 --- /dev/null +++ b/data/db/migration/entity/V1.00.0.16__add_col_member_tb.sql @@ -0,0 +1,6 @@ +-- 멤버 이미지 URL 추가 +ALTER TABLE MEMBER + ADD COLUMN img_url VARCHAR(1000); -- TODO: NOT NULL 옵션 추가 + +ALTER TABLE ARTICLE_MAIN_CARD + ADD COLUMN writer_img_url VARCHAR(1000); -- TODO: NOT NULL 옵션 추가 From 45aadae940cf0c56b13ce453e4abf39d685c5c52 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 19:30:31 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=EC=95=84=ED=8B=B0=ED=81=B4=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EC=A1=B0=ED=9A=8C,=20=EC=95=84=ED=8B=B0?= =?UTF-8?q?=ED=81=B4=20=EB=8B=A8=EA=B1=B4=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=20?= =?UTF-8?q?=EC=9E=91=EA=B0=80=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/few/api/repo/dao/article/ArticleMainCardDao.kt | 3 ++- .../api/repo/dao/article/record/ArticleMainCardRecord.kt | 1 + .../api/repo/dao/article/support/ArticleMainCardMapper.kt | 1 + .../main/kotlin/com/few/api/repo/dao/member/MemberDao.kt | 3 ++- .../com/few/api/repo/dao/member/record/WriterRecord.kt | 1 + .../article/service/ReadArticleWriterRecordService.kt | 3 ++- .../few/api/domain/article/service/dto/ReadWriterOutDto.kt | 1 + .../few/api/domain/article/usecase/ReadArticleUseCase.kt | 3 ++- .../few/api/domain/article/usecase/ReadArticlesUseCase.kt | 3 ++- .../api/domain/article/usecase/dto/ReadArticleUseCaseOut.kt | 1 + .../com/few/api/web/controller/article/ArticleController.kt | 6 ++++-- .../web/controller/article/response/ReadArticleResponse.kt | 1 + 12 files changed, 20 insertions(+), 7 deletions(-) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt index 952aa1b8d..076cf49c9 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt @@ -31,11 +31,12 @@ class ArticleMainCardDao( ARTICLE_MAIN_CARD.CREATED_AT.`as`(ArticleMainCardRecord::createdAt.name), ARTICLE_MAIN_CARD.WRITER_ID.`as`(ArticleMainCardRecord::writerId.name), ARTICLE_MAIN_CARD.WRITER_EMAIL.`as`(ArticleMainCardRecord::writerEmail.name), + ARTICLE_MAIN_CARD.WRITER_IMG_URL.`as`(ArticleMainCardRecord::writerImgUrl.name), jsonGetAttributeAsText( ARTICLE_MAIN_CARD.WRITER_DESCRIPTION, "name" ).`as`(ArticleMainCardRecord::writerName.name), - jsonGetAttribute(ARTICLE_MAIN_CARD.WRITER_DESCRIPTION, "url").`as`(ArticleMainCardRecord::writerImgUrl.name), + jsonGetAttribute(ARTICLE_MAIN_CARD.WRITER_DESCRIPTION, "url").`as`(ArticleMainCardRecord::writerUrl.name), ARTICLE_MAIN_CARD.WORKBOOKS.`as`(ArticleMainCardRecord::workbooks.name) ).from(ARTICLE_MAIN_CARD) .where(ARTICLE_MAIN_CARD.ID.`in`(articleIds)) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt index 3833a6634..a3719f451 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt @@ -12,6 +12,7 @@ data class ArticleMainCardRecord( val writerId: Long, val writerEmail: String, val writerName: String, + val writerUrl: URL, val writerImgUrl: URL, val workbooks: List = emptyList(), ) { diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt index 7c4896b53..68acf9d9d 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt @@ -25,6 +25,7 @@ class ArticleMainCardMapper( writerId = record.get(ArticleMainCardRecord::writerId.name, Long::class.java), writerEmail = record.get(ArticleMainCardRecord::writerEmail.name, String::class.java), writerName = record.get(ArticleMainCardRecord::writerName.name, String::class.java), + writerUrl = record.get(ArticleMainCardRecord::writerUrl.name, URL::class.java), writerImgUrl = record.get(ArticleMainCardRecord::writerImgUrl.name, URL::class.java), workbooks = record.get(ArticleMainCardRecord::workbooks.name, JSON::class.java)?.data()?.let { if ("{}".equals(it)) { diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt index f19a5f8b0..692f1c66f 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt @@ -42,7 +42,8 @@ class MemberDao( fun selectWriterQuery(query: SelectWriterQuery) = dslContext.select( Member.MEMBER.ID.`as`(WriterRecord::writerId.name), DSL.jsonGetAttributeAsText(Member.MEMBER.DESCRIPTION, "name").`as`(WriterRecord::name.name), - DSL.jsonGetAttribute(Member.MEMBER.DESCRIPTION, "url").`as`(WriterRecord::url.name) + DSL.jsonGetAttribute(Member.MEMBER.DESCRIPTION, "url").`as`(WriterRecord::url.name), + Member.MEMBER.IMG_URL.`as`(WriterRecord::imgUrl.name) ) .from(Member.MEMBER) .where(Member.MEMBER.ID.eq(query.writerId)) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/WriterRecord.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/WriterRecord.kt index 9b551c421..1879ac406 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/WriterRecord.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/WriterRecord.kt @@ -6,4 +6,5 @@ data class WriterRecord( val writerId: Long, val name: String, val url: URL, + val imgUrl: URL, ) \ No newline at end of file diff --git a/api/src/main/kotlin/com/few/api/domain/article/service/ReadArticleWriterRecordService.kt b/api/src/main/kotlin/com/few/api/domain/article/service/ReadArticleWriterRecordService.kt index 79994cc08..b3c63d2ce 100644 --- a/api/src/main/kotlin/com/few/api/domain/article/service/ReadArticleWriterRecordService.kt +++ b/api/src/main/kotlin/com/few/api/domain/article/service/ReadArticleWriterRecordService.kt @@ -18,7 +18,8 @@ class ReadArticleWriterRecordService( ReadWriterOutDto( writerId = it.writerId, name = it.name, - url = it.url + url = it.url, + imgUrl = it.imgUrl ) } } diff --git a/api/src/main/kotlin/com/few/api/domain/article/service/dto/ReadWriterOutDto.kt b/api/src/main/kotlin/com/few/api/domain/article/service/dto/ReadWriterOutDto.kt index 418671e8b..35a1ea064 100644 --- a/api/src/main/kotlin/com/few/api/domain/article/service/dto/ReadWriterOutDto.kt +++ b/api/src/main/kotlin/com/few/api/domain/article/service/dto/ReadWriterOutDto.kt @@ -6,4 +6,5 @@ data class ReadWriterOutDto( val writerId: Long, val name: String, val url: URL, + val imgUrl: URL, ) \ No newline at end of file diff --git a/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCase.kt b/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCase.kt index e536dcbae..342c4dfd8 100644 --- a/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCase.kt @@ -59,7 +59,8 @@ class ReadArticleUseCase( writer = WriterDetail( id = writerRecord.writerId, name = writerRecord.name, - url = writerRecord.url + url = writerRecord.url, + imgUrl = writerRecord.imgUrl ), mainImageUrl = articleRecord.mainImageURL, title = articleRecord.title, diff --git a/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt b/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt index c6c750310..d6c5e4a6b 100644 --- a/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt @@ -81,7 +81,8 @@ class ReadArticlesUseCase( writer = WriterDetail( id = a.writerId, name = a.writerName, - url = a.writerImgUrl + url = a.writerUrl, + imgUrl = a.writerImgUrl ), mainImageUrl = a.mainImageUrl, title = a.articleTitle, diff --git a/api/src/main/kotlin/com/few/api/domain/article/usecase/dto/ReadArticleUseCaseOut.kt b/api/src/main/kotlin/com/few/api/domain/article/usecase/dto/ReadArticleUseCaseOut.kt index a5ac939cd..424abb438 100644 --- a/api/src/main/kotlin/com/few/api/domain/article/usecase/dto/ReadArticleUseCaseOut.kt +++ b/api/src/main/kotlin/com/few/api/domain/article/usecase/dto/ReadArticleUseCaseOut.kt @@ -20,6 +20,7 @@ data class WriterDetail( val id: Long, val name: String, val url: URL, + val imgUrl: URL, ) data class WorkbookDetail( diff --git a/api/src/main/kotlin/com/few/api/web/controller/article/ArticleController.kt b/api/src/main/kotlin/com/few/api/web/controller/article/ArticleController.kt index 29aebb01a..b46de2f2b 100644 --- a/api/src/main/kotlin/com/few/api/web/controller/article/ArticleController.kt +++ b/api/src/main/kotlin/com/few/api/web/controller/article/ArticleController.kt @@ -41,7 +41,8 @@ class ArticleController( writer = WriterInfo( useCaseOut.writer.id, useCaseOut.writer.name, - useCaseOut.writer.url + useCaseOut.writer.url, + useCaseOut.writer.imgUrl ), mainImageUrl = useCaseOut.mainImageUrl, content = useCaseOut.content, @@ -74,7 +75,8 @@ class ArticleController( writer = WriterInfo( a.writer.id, a.writer.name, - a.writer.url + a.writer.url, + a.writer.imgUrl ), mainImageUrl = a.mainImageUrl, content = a.content, diff --git a/api/src/main/kotlin/com/few/api/web/controller/article/response/ReadArticleResponse.kt b/api/src/main/kotlin/com/few/api/web/controller/article/response/ReadArticleResponse.kt index d587c3ce6..d87b3ed41 100644 --- a/api/src/main/kotlin/com/few/api/web/controller/article/response/ReadArticleResponse.kt +++ b/api/src/main/kotlin/com/few/api/web/controller/article/response/ReadArticleResponse.kt @@ -22,6 +22,7 @@ data class WriterInfo( val id: Long, val name: String, val url: URL, + val imgUrl: URL, ) data class WorkbookInfo( From af823b7704638c2a2008a50d2437b37c61e05311 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 19:45:01 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=EC=95=84=ED=8B=B0=ED=81=B4=20?= =?UTF-8?q?=EC=8B=A0=EA=B7=9C=20=EC=83=9D=EC=84=B1=EC=8B=9C=20=EC=9E=91?= =?UTF-8?q?=EA=B0=80=20Image=20url=EC=9D=84=20article=5Fmain=5Fcard?= =?UTF-8?q?=EC=97=90=20=EC=A0=80=EC=9E=A5=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repo/dao/article/ArticleMainCardDao.kt | 31 +++++++------------ .../ArticleMainCardExcludeWorkbookCommand.kt | 1 + .../com/few/api/repo/dao/member/MemberDao.kt | 15 ++++++--- ...mberIdAndNameRecord.kt => MemberRecord.kt} | 6 +++- .../service/ArticleMainCardService.kt | 3 +- .../dto/InitializeArticleMainCardInDto.kt | 1 + .../document/usecase/AddArticleUseCase.kt | 12 +++---- 7 files changed, 37 insertions(+), 32 deletions(-) rename api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/{MemberIdAndNameRecord.kt => MemberRecord.kt} (51%) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt index 076cf49c9..dca0c57af 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt @@ -49,29 +49,22 @@ class ArticleMainCardDao( insertArticleMainCardQuery(command).execute() fun insertArticleMainCardQuery(command: ArticleMainCardExcludeWorkbookCommand) = dslContext - .insertInto( - ARTICLE_MAIN_CARD, - ARTICLE_MAIN_CARD.ID, - ARTICLE_MAIN_CARD.TITLE, - ARTICLE_MAIN_CARD.MAIN_IMAGE_URL, - ARTICLE_MAIN_CARD.CATEGORY_CD, - ARTICLE_MAIN_CARD.CREATED_AT, - ARTICLE_MAIN_CARD.WRITER_ID, - ARTICLE_MAIN_CARD.WRITER_EMAIL, - ARTICLE_MAIN_CARD.WRITER_DESCRIPTION - ).values( - command.articleId, - command.articleTitle, - command.mainImageUrl.toString(), - command.categoryCd, - command.createdAt, - command.writerId, - command.writerEmail, + .insertInto(ARTICLE_MAIN_CARD) + .set(ARTICLE_MAIN_CARD.ID, command.articleId) + .set(ARTICLE_MAIN_CARD.TITLE, command.articleTitle) + .set(ARTICLE_MAIN_CARD.MAIN_IMAGE_URL, command.mainImageUrl.toString()) + .set(ARTICLE_MAIN_CARD.CATEGORY_CD, command.categoryCd) + .set(ARTICLE_MAIN_CARD.CREATED_AT, command.createdAt) + .set(ARTICLE_MAIN_CARD.WRITER_ID, command.writerId) + .set(ARTICLE_MAIN_CARD.WRITER_EMAIL, command.writerEmail) + .set(ARTICLE_MAIN_CARD.WRITER_IMG_URL, command.writerImgUrl.toString()) + .set( + ARTICLE_MAIN_CARD.WRITER_DESCRIPTION, JSON.valueOf( commonJsonMapper.toJsonStr( mapOf( "name" to command.writerName, - "url" to command.writerImgUrl + "url" to command.writerUrl ) ) ) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/command/ArticleMainCardExcludeWorkbookCommand.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/command/ArticleMainCardExcludeWorkbookCommand.kt index 0392e27c1..4df571e59 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/command/ArticleMainCardExcludeWorkbookCommand.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/command/ArticleMainCardExcludeWorkbookCommand.kt @@ -13,4 +13,5 @@ data class ArticleMainCardExcludeWorkbookCommand( val writerEmail: String, val writerName: String, val writerImgUrl: URL, + val writerUrl: URL, ) \ No newline at end of file diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt index 692f1c66f..3f4ff0582 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt @@ -12,7 +12,7 @@ import com.few.api.repo.dao.member.query.SelectMemberByEmailQuery import com.few.api.repo.dao.member.query.SelectWriterQuery import com.few.api.repo.dao.member.query.SelectWritersQuery import com.few.api.repo.dao.member.record.MemberIdAndIsDeletedRecord -import com.few.api.repo.dao.member.record.MemberIdAndNameRecord +import com.few.api.repo.dao.member.record.MemberRecord import com.few.api.repo.dao.member.record.MemberEmailAndTypeRecord import com.few.api.repo.dao.member.record.WriterRecord import com.few.api.repo.dao.member.record.WriterRecordMappedWorkbook @@ -22,6 +22,7 @@ import jooq.jooq_dsl.tables.MappingWorkbookArticle import jooq.jooq_dsl.tables.Member import org.jooq.DSLContext import org.jooq.impl.DSL +import org.jooq.impl.DSL.jsonGetAttribute import org.jooq.impl.DSL.jsonGetAttributeAsText import org.springframework.cache.annotation.Cacheable import org.springframework.stereotype.Repository @@ -126,14 +127,18 @@ class MemberDao( .where(Member.MEMBER.TYPE_CD.eq(MemberType.WRITER.code)) .and(Member.MEMBER.DELETED_AT.isNull) - fun selectMemberByEmail(query: SelectMemberByEmailQuery): MemberIdAndNameRecord? { + fun selectMemberByEmail(query: SelectMemberByEmailQuery): MemberRecord? { return selectMemberByEmailQuery(query) - .fetchOneInto(MemberIdAndNameRecord::class.java) + .fetchOneInto(MemberRecord::class.java) } fun selectMemberByEmailQuery(query: SelectMemberByEmailQuery) = dslContext.select( - Member.MEMBER.ID.`as`(MemberIdAndNameRecord::memberId.name), - jsonGetAttributeAsText(Member.MEMBER.DESCRIPTION, "name").`as`(MemberIdAndNameRecord::writerName.name) // writer only(nullable) + Member.MEMBER.ID.`as`(MemberRecord::memberId.name), + Member.MEMBER.IMG_URL.`as`(MemberRecord::imageUrl.name), + // writer only(nullable) + jsonGetAttributeAsText(Member.MEMBER.DESCRIPTION, "name").`as`(MemberRecord::writerName.name), + // writer only(nullable) + jsonGetAttribute(Member.MEMBER.DESCRIPTION, "url").`as`(MemberRecord::writerUrl.name) ) .from(Member.MEMBER) .where(Member.MEMBER.EMAIL.eq(query.email)) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/MemberIdAndNameRecord.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/MemberRecord.kt similarity index 51% rename from api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/MemberIdAndNameRecord.kt rename to api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/MemberRecord.kt index f2267e120..f65c4caf0 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/MemberIdAndNameRecord.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/MemberRecord.kt @@ -1,6 +1,10 @@ package com.few.api.repo.dao.member.record -data class MemberIdAndNameRecord( +import java.net.URL + +data class MemberRecord( val memberId: Long, + val imageUrl: URL, + val writerUrl: URL, val writerName: String?, ) \ No newline at end of file diff --git a/api/src/main/kotlin/com/few/api/domain/admin/document/service/ArticleMainCardService.kt b/api/src/main/kotlin/com/few/api/domain/admin/document/service/ArticleMainCardService.kt index 9d7643e40..4351ec44d 100644 --- a/api/src/main/kotlin/com/few/api/domain/admin/document/service/ArticleMainCardService.kt +++ b/api/src/main/kotlin/com/few/api/domain/admin/document/service/ArticleMainCardService.kt @@ -28,7 +28,8 @@ class ArticleMainCardService( writerId = inDto.writerId, writerEmail = inDto.writerEmail, writerName = inDto.writerName, - writerImgUrl = inDto.writerImgUrl + writerImgUrl = inDto.writerImgUrl, + writerUrl = inDto.writerUrl ) ) } diff --git a/api/src/main/kotlin/com/few/api/domain/admin/document/service/dto/InitializeArticleMainCardInDto.kt b/api/src/main/kotlin/com/few/api/domain/admin/document/service/dto/InitializeArticleMainCardInDto.kt index d013a7484..7aa515372 100644 --- a/api/src/main/kotlin/com/few/api/domain/admin/document/service/dto/InitializeArticleMainCardInDto.kt +++ b/api/src/main/kotlin/com/few/api/domain/admin/document/service/dto/InitializeArticleMainCardInDto.kt @@ -13,4 +13,5 @@ data class InitializeArticleMainCardInDto( val writerEmail: String, val writerName: String, val writerImgUrl: URL, + val writerUrl: URL, ) \ No newline at end of file diff --git a/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt b/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt index 910be40b7..d8e41adaa 100644 --- a/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt @@ -27,7 +27,6 @@ import com.few.storage.document.service.PutDocumentService import org.springframework.stereotype.Component import org.springframework.transaction.annotation.Transactional import java.io.File -import java.net.URL import java.time.LocalDateTime import java.util.* @@ -46,7 +45,7 @@ class AddArticleUseCase( @Transactional fun execute(useCaseIn: AddArticleUseCaseIn): AddArticleUseCaseOut { /** select writerId */ - val writerIdRecord = SelectMemberByEmailQuery(useCaseIn.writerEmail).let { + val writerRecord = SelectMemberByEmailQuery(useCaseIn.writerEmail).let { memberDao.selectMemberByEmail(it) } ?: throw NotFoundException("member.notfound.id") @@ -101,7 +100,7 @@ class AddArticleUseCase( /** insert article */ val articleMstId = InsertFullArticleRecordCommand( - writerId = writerIdRecord.memberId, + writerId = writerRecord.memberId, mainImageURL = useCaseIn.articleImageUrl, title = useCaseIn.title, category = category.code, @@ -141,10 +140,11 @@ class AddArticleUseCase( mainImageUrl = useCaseIn.articleImageUrl, categoryCd = category.code, createdAt = LocalDateTime.now(), // TODO: DB insert 시점으로 변경 - writerId = writerIdRecord.memberId, + writerId = writerRecord.memberId, writerEmail = useCaseIn.writerEmail, - writerName = writerIdRecord.writerName ?: throw NotFoundException("article.writer.name"), - writerImgUrl = URL("https://github.com/user-attachments/assets/528a6531-2cba-4efc-b8df-64a083d38be8") //TODO: 작가 이미지로 변환 + writerName = writerRecord.writerName ?: throw NotFoundException("article.writer.name"), + writerImgUrl = writerRecord.imageUrl, + writerUrl = writerRecord.writerUrl ) ) From 41053ad24404e8f8812960bbd6872d94b01f07c9 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 19:54:22 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A9=A4=EB=B2=84=20=EC=B6=94=EA=B0=80=EC=8B=9C=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/few/api/repo/dao/member/MemberDao.kt | 1 + .../dao/member/command/InsertMemberCommand.kt | 1 + .../member/MemberDaoExplainGenerateTest.kt | 4 +++- .../domain/member/usecase/SaveMemberUseCase.kt | 4 +++- .../domain/subscription/service/MemberService.kt | 4 +++- .../few/data/common/code/MemberDefaultImage.kt | 15 +++++++++++++++ 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 data/src/main/kotlin/com/few/data/common/code/MemberDefaultImage.kt diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt index 3f4ff0582..a82972632 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt @@ -168,6 +168,7 @@ class MemberDao( dslContext.insertInto(Member.MEMBER) .set(Member.MEMBER.EMAIL, command.email) .set(Member.MEMBER.TYPE_CD, command.memberType.code) + .set(Member.MEMBER.IMG_URL, command.imageUrl) fun selectMemberEmailAndType(memberId: Long): MemberEmailAndTypeRecord? { return selectMemberIdAndTypeQuery(memberId) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/command/InsertMemberCommand.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/command/InsertMemberCommand.kt index db7b860b6..c9902bf9b 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/command/InsertMemberCommand.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/command/InsertMemberCommand.kt @@ -5,4 +5,5 @@ import com.few.data.common.code.MemberType data class InsertMemberCommand( val email: String, val memberType: MemberType, + val imageUrl: String, ) \ No newline at end of file diff --git a/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt b/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt index 433e5dd4e..47f7cd48e 100644 --- a/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt +++ b/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt @@ -11,6 +11,7 @@ import com.few.api.repo.dao.member.support.WriterDescriptionJsonMapper import com.few.api.repo.explain.InsertUpdateExplainGenerator import com.few.api.repo.explain.ResultGenerator import com.few.api.repo.jooq.JooqTestSpec +import com.few.data.common.code.MemberDefaultImage import com.few.data.common.code.MemberType import io.github.oshai.kotlinlogging.KotlinLogging import jooq.jooq_dsl.tables.Member @@ -114,7 +115,8 @@ class MemberDaoExplainGenerateTest : JooqTestSpec() { fun insertMemberCommandExplain() { val command = InsertMemberCommand( email = "test100@gmail.com", - memberType = MemberType.NORMAL + memberType = MemberType.NORMAL, + imageUrl = MemberDefaultImage.getRandom().url ).let { memberDao.insertMemberCommand(it) } diff --git a/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt b/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt index 3b722afae..254efb327 100644 --- a/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt @@ -8,6 +8,7 @@ import com.few.api.repo.dao.member.MemberDao import com.few.api.repo.dao.member.command.InsertMemberCommand import com.few.api.repo.dao.member.command.UpdateDeletedMemberTypeCommand import com.few.api.repo.dao.member.query.SelectMemberByEmailNotConsiderDeletedAtQuery +import com.few.data.common.code.MemberDefaultImage import com.few.data.common.code.MemberType import com.few.email.service.member.SendAuthEmailService import com.few.email.service.member.dto.Content @@ -36,7 +37,8 @@ class SaveMemberUseCase( val token = if (Objects.isNull(isSignUpBeforeMember)) { InsertMemberCommand( email = useCaseIn.email, - memberType = MemberType.PREAUTH + memberType = MemberType.PREAUTH, + MemberDefaultImage.getRandom().url ).let { memberDao.insertMember(it) ?: throw InsertException("member.insertfail.record") } diff --git a/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt b/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt index 68482dca2..2d0bf77fa 100644 --- a/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt +++ b/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt @@ -7,6 +7,7 @@ import com.few.api.exception.common.InsertException import com.few.api.repo.dao.member.MemberDao import com.few.api.repo.dao.member.command.InsertMemberCommand import com.few.api.repo.dao.member.query.SelectMemberByEmailQuery +import com.few.data.common.code.MemberDefaultImage import org.springframework.stereotype.Service @Service @@ -19,7 +20,8 @@ class MemberService( } fun insertMember(dto: InsertMemberInDto): MemberIdOutDto { - return memberDao.insertMember(InsertMemberCommand(dto.email, dto.memberType))?.let { MemberIdOutDto(it) } + return memberDao.insertMember(InsertMemberCommand(dto.email, dto.memberType, MemberDefaultImage.getRandom().url)) + ?.let { MemberIdOutDto(it) } ?: throw InsertException("member.insertfail.record") } } \ No newline at end of file diff --git a/data/src/main/kotlin/com/few/data/common/code/MemberDefaultImage.kt b/data/src/main/kotlin/com/few/data/common/code/MemberDefaultImage.kt new file mode 100644 index 000000000..80ad892b6 --- /dev/null +++ b/data/src/main/kotlin/com/few/data/common/code/MemberDefaultImage.kt @@ -0,0 +1,15 @@ +package com.few.data.common.code + +enum class MemberDefaultImage(val url: String) { + DEFAULT_IMG1("https://github.com/user-attachments/assets/28df9078-488c-49d6-9375-54ce5a250742"), + DEFAULT_IMG2("https://github.com/user-attachments/assets/385dcafd-6737-41d7-aaa0-9db4ea6f27ea"), + DEFAULT_IMG3("https://github.com/user-attachments/assets/209da8ff-7c78-41b7-8e3e-40a2705f714a"), + + ; + + companion object { + fun getRandom(): MemberDefaultImage { + return entries.toTypedArray().random() + } + } +} \ No newline at end of file From f56bfed8e048b916a94344d4eab665a7e1fb2e09 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 20:08:01 +0900 Subject: [PATCH 5/8] =?UTF-8?q?test:=20=EB=A9=A4=EB=B2=84=20image=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/few/api/repo/dao/member/MemberDao.kt | 3 +- .../few/api/repo/dao/member/MemberDaoTest.kt | 4 ++ .../browseWorkBookQueryCategoryCondition.txt | 38 +++++++++++++++++++ .../browseWorkBookQueryNoConditionQuery.txt | 35 +++++++++++++++++ ...untAllWorkbookSubscriptionQueryExplain.txt | 13 +++++++ ...ountWorkbookMappedArticlesQueryExplain.txt | 11 ++++++ .../explain/deleteMemberCommandExplain.txt | 13 +++++++ .../insertArticleIfoCommandExplain.txt | 13 +++++++ .../insertArticleMstCommandExplain.txt | 15 ++++++++ .../insertArticleViewHisCommandExplain.txt | 13 +++++++ .../explain/insertMemberCommandExplain.txt | 14 +++++++ .../explain/insertProblemCommandExplain.txt | 24 ++++++++++++ .../explain/insertSubmitCommandExplain.txt | 15 ++++++++ .../explain/insertWorkBookCommandExplain.txt | 15 ++++++++ ...sertWorkbookSubscriptionCommandExplain.txt | 13 +++++++ ...WorkbookSubscriptionStatusQueryExplain.txt | 22 +++++++++++ ...rticleIdByWorkbookIdAndDayQueryExplain.txt | 14 +++++++ .../selectArticleRecordQueryExplain.txt | 24 ++++++++++++ .../selectArticleViewCountQueryExplain.txt | 11 ++++++ ...yEmailNotConsiderDeletedAtQueryExplain.txt | 27 +++++++++++++ ...selectMemberByEmailQueryExplainExplain.txt | 27 +++++++++++++ .../selectMemberIdAndTypeQueryExplain.txt | 16 ++++++++ .../selectProblemAnswerQueryExplain.txt | 17 +++++++++ .../selectProblemContentsQueryExplain.txt | 17 +++++++++ .../selectProblemsByArticleIdQueryExplain.txt | 23 +++++++++++ ...WorkbookSubscriptionStatusQueryExplain.txt | 19 ++++++++++ ...electWorkBookArticleRecordQueryExplain.txt | 31 +++++++++++++++ .../explain/selectWorkBookQueryExplain.txt | 20 ++++++++++ ...rkbookMappedArticleRecordsQueryExplain.txt | 28 ++++++++++++++ .../explain/selectWriterQueryExplain.txt | 28 ++++++++++++++ .../explain/selectWritersQueryExplain.txt | 31 +++++++++++++++ ...letedAtInAllSubscriptionCommandExplain.txt | 13 +++++++ .../updateDeletedMemberTypeCommandExplain.txt | 13 +++++++ .../updateMemberTypeCommandExplain.txt | 15 ++++++++ .../upsertArticleViewCountQueryExplain.txt | 16 ++++++++ .../article/usecase/ReadArticleUseCaseTest.kt | 4 +- .../article/ArticleControllerTest.kt | 11 +++++- 37 files changed, 662 insertions(+), 4 deletions(-) create mode 100644 api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt create mode 100644 api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt create mode 100644 api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertMemberCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertProblemCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectWriterQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/selectWritersQueryExplain.txt create mode 100644 api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt create mode 100644 api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt index a82972632..c1cecec37 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt @@ -75,7 +75,8 @@ class MemberDao( Member.MEMBER.ID.`as`(WriterRecord::writerId.name), DSL.jsonGetAttributeAsText(Member.MEMBER.DESCRIPTION, "name") .`as`(WriterRecord::name.name), - DSL.jsonGetAttribute(Member.MEMBER.DESCRIPTION, "url").`as`(WriterRecord::url.name) + DSL.jsonGetAttribute(Member.MEMBER.DESCRIPTION, "url").`as`(WriterRecord::url.name), + Member.MEMBER.IMG_URL.`as`(WriterRecord::imgUrl.name) ) .from(Member.MEMBER) .where(Member.MEMBER.ID.`in`(notCachedIds)) diff --git a/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt b/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt index 64c0fea12..f5586be29 100644 --- a/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt +++ b/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt @@ -5,6 +5,7 @@ import com.few.api.repo.dao.member.query.SelectWritersQuery import com.few.api.repo.dao.member.support.WriterDescription import com.few.api.repo.dao.member.support.WriterDescriptionJsonMapper import com.few.api.repo.jooq.JooqTestSpec +import com.few.data.common.code.MemberDefaultImage import com.few.data.common.code.MemberType import io.github.oshai.kotlinlogging.KotlinLogging import jooq.jooq_dsl.tables.Member @@ -40,6 +41,7 @@ class MemberDaoTest : JooqTestSpec() { .set(Member.MEMBER.ID, 1) .set(Member.MEMBER.EMAIL, "member@gmail.com") .set(Member.MEMBER.TYPE_CD, MemberType.NORMAL.code) + .set(Member.MEMBER.IMG_URL, MemberDefaultImage.getRandom().url) .execute() val writerDescription = writerDescriptionJsonMapper.toJson( @@ -51,6 +53,7 @@ class MemberDaoTest : JooqTestSpec() { .set(Member.MEMBER.EMAIL, "writer2@gmail.com") .set(Member.MEMBER.TYPE_CD, MemberType.WRITER.code) .set(Member.MEMBER.DESCRIPTION, JSON.valueOf(writerDescription)) + .set(Member.MEMBER.IMG_URL, MemberDefaultImage.getRandom().url) .execute() log.debug { "===== finish setUp =====" } } @@ -107,6 +110,7 @@ class MemberDaoTest : JooqTestSpec() { .set(Member.MEMBER.EMAIL, "writer$i@gmail.com") .set(Member.MEMBER.TYPE_CD, MemberType.WRITER.code) .set(Member.MEMBER.DESCRIPTION, JSON.valueOf(writerDescription)) + .set(Member.MEMBER.IMG_URL, MemberDefaultImage.getRandom().url) .execute() } } diff --git a/api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt b/api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt new file mode 100644 index 000000000..1aca3110c --- /dev/null +++ b/api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt @@ -0,0 +1,38 @@ +select + `WORKBOOK`.`ID` as `id`, + `WORKBOOK`.`TITLE` as `title`, + `WORKBOOK`.`MAIN_IMAGE_URL` as `mainImageUrl`, + `WORKBOOK`.`CATEGORY_CD` as `category`, + `WORKBOOK`.`DESCRIPTION` as `description`, + `WORKBOOK`.`CREATED_AT` as `createdAt`, + coalesce( + subscription_count_table.subscription_count, + 0 + ) as `subscriptionCount` +from `WORKBOOK` + left outer join ( + select + `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `TARGET_WORKBOOK_ID`, + count(`SUBSCRIPTION`.`TARGET_WORKBOOK_ID`) as `subscription_count` + from `SUBSCRIPTION` + where `SUBSCRIPTION`.`DELETED_AT` is null + group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` + ) as `subscription_count_table` + on `WORKBOOK`.`ID` = subscription_count_table.TARGET_WORKBOOK_ID +where ( + `WORKBOOK`.`CATEGORY_CD` = 0 + and `WORKBOOK`.`DELETED_AT` is null +) +order by + subscription_count_table.subscription_count desc, + `WORKBOOK`.`CREATED_AT` desc + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ +| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ +| 1|PRIMARY |WORKBOOK |{null} |ALL |{null} |{null} |{null} |{null} | 1| 100.0|Using where; Using temporary; Using filesort| +| 1|PRIMARY | |{null} |ref | | |9 |api.WORKBOOK.id| 2| 100.0|{null} | +| 2|DERIVED |SUBSCRIPTION|{null} |index|target_workbook_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |{null} | 1| 100.0|Using where | ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt b/api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt new file mode 100644 index 000000000..1a0380d86 --- /dev/null +++ b/api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt @@ -0,0 +1,35 @@ +select + `WORKBOOK`.`ID` as `id`, + `WORKBOOK`.`TITLE` as `title`, + `WORKBOOK`.`MAIN_IMAGE_URL` as `mainImageUrl`, + `WORKBOOK`.`CATEGORY_CD` as `category`, + `WORKBOOK`.`DESCRIPTION` as `description`, + `WORKBOOK`.`CREATED_AT` as `createdAt`, + coalesce( + subscription_count_table.subscription_count, + 0 + ) as `subscriptionCount` +from `WORKBOOK` + left outer join ( + select + `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `TARGET_WORKBOOK_ID`, + count(`SUBSCRIPTION`.`TARGET_WORKBOOK_ID`) as `subscription_count` + from `SUBSCRIPTION` + where `SUBSCRIPTION`.`DELETED_AT` is null + group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` + ) as `subscription_count_table` + on `WORKBOOK`.`ID` = subscription_count_table.TARGET_WORKBOOK_ID +where `WORKBOOK`.`DELETED_AT` is null +order by + subscription_count_table.subscription_count desc, + `WORKBOOK`.`CREATED_AT` desc + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ +| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ +| 1|PRIMARY |WORKBOOK |{null} |ALL |{null} |{null} |{null} |{null} | 1| 100.0|Using where; Using temporary; Using filesort| +| 1|PRIMARY | |{null} |ref | | |9 |api.WORKBOOK.id| 2| 100.0|{null} | +| 2|DERIVED |SUBSCRIPTION|{null} |index|target_workbook_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |{null} | 1| 100.0|Using where | ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt b/api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt new file mode 100644 index 000000000..3e206263a --- /dev/null +++ b/api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt @@ -0,0 +1,13 @@ +select + `SUBSCRIPTION`.`TARGET_WORKBOOK_ID`, + count(`SUBSCRIPTION`.`TARGET_WORKBOOK_ID`) +from `SUBSCRIPTION` +group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+------+----+--------+-----------+ +| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+------+----+--------+-----------+ +| 1|SIMPLE |SUBSCRIPTION|{null} |index|target_workbook_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |{null}| 1| 100.0|Using index| ++----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt b/api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt new file mode 100644 index 000000000..cc1196661 --- /dev/null +++ b/api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt @@ -0,0 +1,11 @@ +select count(*) +from `MAPPING_WORKBOOK_ARTICLE` +where `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------------------+----------+-----+-------------+-------+-------+------+----+--------+------------------------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------------------+----------+-----+-------------+-------+-------+------+----+--------+------------------------+ +| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |index|PRIMARY |PRIMARY|16 |{null}| 1| 100.0|Using where; Using index| ++----+-----------+------------------------+----------+-----+-------------+-------+-------+------+----+--------+------------------------+ diff --git a/api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt b/api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt new file mode 100644 index 000000000..3430c6814 --- /dev/null +++ b/api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt @@ -0,0 +1,13 @@ +update `MEMBER` +set + `MEMBER`.`TYPE_CD` = 120, + `MEMBER`.`DELETED_AT` = null +where `MEMBER`.`ID` = 1 + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ +| 1|UPDATE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |const| 1| 100.0|Using where| ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt b/api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt new file mode 100644 index 000000000..fce2eb21f --- /dev/null +++ b/api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt @@ -0,0 +1,13 @@ +insert into `ARTICLE_IFO` (`ARTICLE_MST_ID`, `CONTENT`) +values ( + 1, + 'this is content1' +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |ARTICLE_IFO|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt b/api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt new file mode 100644 index 000000000..2acbcefc3 --- /dev/null +++ b/api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt @@ -0,0 +1,15 @@ +insert into `ARTICLE_MST` (`MEMBER_ID`, `MAIN_IMAGE_URL`, `TITLE`, `CATEGORY_CD`) +values ( + 100, + 'http://localhost:8080/image1.jpg', + 'this is title1', + 0 +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |ARTICLE_MST|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt b/api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt new file mode 100644 index 000000000..a6763ab92 --- /dev/null +++ b/api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt @@ -0,0 +1,13 @@ +insert into `ARTICLE_VIEW_HIS` (`ARTICLE_MST_ID`, `MEMBER_ID`) +values ( + 1, + 1 +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+----------------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+----------------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |ARTICLE_VIEW_HIS|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+----------------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertMemberCommandExplain.txt b/api-repo/src/test/resources/explain/insertMemberCommandExplain.txt new file mode 100644 index 000000000..327f6bff3 --- /dev/null +++ b/api-repo/src/test/resources/explain/insertMemberCommandExplain.txt @@ -0,0 +1,14 @@ +insert into `MEMBER` (`EMAIL`, `TYPE_CD`, `IMG_URL`) +values ( + 'test100@gmail.com', + 60, + 'https://github.com/user-attachments/assets/28df9078-488c-49d6-9375-54ce5a250742' +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |MEMBER|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertProblemCommandExplain.txt b/api-repo/src/test/resources/explain/insertProblemCommandExplain.txt new file mode 100644 index 000000000..af546ad59 --- /dev/null +++ b/api-repo/src/test/resources/explain/insertProblemCommandExplain.txt @@ -0,0 +1,24 @@ +insert into `PROBLEM` ( + `ARTICLE_ID`, + `CREATOR_ID`, + `TITLE`, + `CONTENTS`, + `ANSWER`, + `EXPLANATION` +) +values ( + 1, + 1, + 'problem title', + '{"contents":[{"number":1,"content":"content1"},{"number":2,"content":"content2"}]}', + '1', + 'explanation' +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+-------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+-------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |PROBLEM|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+-------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt b/api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt new file mode 100644 index 000000000..0b84443d1 --- /dev/null +++ b/api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt @@ -0,0 +1,15 @@ +insert into `SUBMIT_HISTORY` (`PROBLEM_ID`, `MEMBER_ID`, `SUBMIT_ANS`, `IS_SOLVED`) +values ( + 1, + 1, + '1', + true +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+--------------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+--------------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |SUBMIT_HISTORY|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+--------------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt b/api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt new file mode 100644 index 000000000..e09a7cf15 --- /dev/null +++ b/api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt @@ -0,0 +1,15 @@ +insert into `WORKBOOK` (`TITLE`, `MAIN_IMAGE_URL`, `CATEGORY_CD`, `DESCRIPTION`) +values ( + 'title2', + 'http://localhost:8080/image2.jpg', + 0, + 'description2' +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+--------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+--------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |WORKBOOK|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+--------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt b/api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt new file mode 100644 index 000000000..0d2373aca --- /dev/null +++ b/api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt @@ -0,0 +1,13 @@ +insert into `SUBSCRIPTION` (`MEMBER_ID`, `TARGET_WORKBOOK_ID`) +values ( + 1, + 1 +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+------------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+------------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |SUBSCRIPTION|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+------------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt b/api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt new file mode 100644 index 000000000..08baf5912 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt @@ -0,0 +1,22 @@ +select + `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `workbookId`, + (`SUBSCRIPTION`.`DELETED_AT` is null) as `isActiveSub`, + (max(`SUBSCRIPTION`.`PROGRESS`) + 1) as `currentDay`, + max(`MAPPING_WORKBOOK_ARTICLE`.`DAY_COL`) as `totalDay` +from `SUBSCRIPTION` + left outer join `MAPPING_WORKBOOK_ARTICLE` + on `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` = `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` +where ( + `SUBSCRIPTION`.`MEMBER_ID` = 1 + and `SUBSCRIPTION`.`TARGET_MEMBER_ID` is null +) +group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID`, `SUBSCRIPTION`.`DELETED_AT` + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------------------+----------+----+----------------------------------------------------------------------------------------------------------------+----------------+-------+-----------+----+--------+------------------------------------------+ +| id|select_type|table |partitions|type|possible_keys |key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------------------+----------+----+----------------------------------------------------------------------------------------------------------------+----------------+-------+-----------+----+--------+------------------------------------------+ +| 1|SIMPLE |SUBSCRIPTION |{null} |ref |target_member_id,subscription_unique_member_id_target_member_id,subscription_unique_member_id_target_workbook_id|target_member_id|17 |const,const| 1| 100.0|Using index condition; Using temporary | +| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |ALL |{null} |{null} |{null} |{null} | 1| 100.0|Using where; Using join buffer (hash join)| ++----+-----------+------------------------+----------+----+----------------------------------------------------------------------------------------------------------------+----------------+-------+-----------+----+--------+------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt b/api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt new file mode 100644 index 000000000..795d3242b --- /dev/null +++ b/api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt @@ -0,0 +1,14 @@ +select `MAPPING_WORKBOOK_ARTICLE`.`ARTICLE_ID` +from `MAPPING_WORKBOOK_ARTICLE` +where ( + `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 + and `MAPPING_WORKBOOK_ARTICLE`.`DAY_COL` = 1 +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------------------+----------+----+-------------+------+-------+------+----+--------+-----------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------------------+----------+----+-------------+------+-------+------+----+--------+-----------+ +| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |ALL |{null} |{null}|{null} |{null}| 1| 100.0|Using where| ++----+-----------+------------------------+----------+----+-------------+------+-------+------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt b/api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt new file mode 100644 index 000000000..02d535a16 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt @@ -0,0 +1,24 @@ +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` +from `ARTICLE_MST` + join `ARTICLE_IFO` + on `ARTICLE_MST`.`ID` = `ARTICLE_IFO`.`ARTICLE_MST_ID` +where ( + `ARTICLE_MST`.`ID` = 1 + and `ARTICLE_MST`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+-----------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+-----------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| 1|SIMPLE |ARTICLE_MST|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| +| 1|SIMPLE |ARTICLE_IFO|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| ++----+-----------+-----------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt b/api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt new file mode 100644 index 000000000..5a12b14f4 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt @@ -0,0 +1,11 @@ +select count(*) +from `ARTICLE_VIEW_HIS` +where `ARTICLE_VIEW_HIS`.`ARTICLE_MST_ID` = 1 + +Explain [cost=NaN, rows=1.00] + ++----+-----------+----------------+----------+----+---------------------+---------------------+-------+-----+----+--------+-----------+ +| id|select_type|table |partitions|type|possible_keys |key |key_len|ref |rows|filtered|Extra | ++----+-----------+----------------+----------+----+---------------------+---------------------+-------+-----+----+--------+-----------+ +| 1|SIMPLE |ARTICLE_VIEW_HIS|{null} |ref |article_view_his_idx1|article_view_his_idx1|8 |const| 1| 100.0|Using index| ++----+-----------+----------------+----------+----+---------------------+---------------------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt b/api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt new file mode 100644 index 000000000..1b59cb80e --- /dev/null +++ b/api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt @@ -0,0 +1,27 @@ +select + `MEMBER`.`ID` as `memberId`, + `MEMBER`.`IMG_URL` as `imageUrl`, + json_unquote(nullif( + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'name') + ), + cast('null' as json) + )) as `writerName`, + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'url') + ) as `writerUrl` +from `MEMBER` +where ( + `MEMBER`.`EMAIL` = 'test@gmail.com' + and `MEMBER`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+------+----------+------+-------------+------+-------+------+------+--------+------------------------------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+------+----------+------+-------------+------+-------+------+------+--------+------------------------------+ +| 1|SIMPLE |{null}|{null} |{null}|{null} |{null}|{null} |{null}|{null}| {null}|no matching row in const table| ++----+-----------+------+----------+------+-------------+------+-------+------+------+--------+------------------------------+ diff --git a/api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt b/api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt new file mode 100644 index 000000000..ab60615c5 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt @@ -0,0 +1,27 @@ +select + `MEMBER`.`ID` as `memberId`, + `MEMBER`.`IMG_URL` as `imageUrl`, + json_unquote(nullif( + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'name') + ), + cast('null' as json) + )) as `writerName`, + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'url') + ) as `writerUrl` +from `MEMBER` +where ( + `MEMBER`.`EMAIL` = 'member@gmail.com' + and `MEMBER`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------+----------+-----+-------------+-----+-------+-----+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------+----------+-----+-------------+-----+-------+-----+----+--------+------+ +| 1|SIMPLE |MEMBER|{null} |const|email |email|1022 |const| 1| 100.0|{null}| ++----+-----------+------+----------+-----+-------------+-----+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt b/api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt new file mode 100644 index 000000000..1c772ec71 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt @@ -0,0 +1,16 @@ +select + `MEMBER`.`EMAIL` as `email`, + `MEMBER`.`TYPE_CD` as `memberType` +from `MEMBER` +where ( + `MEMBER`.`ID` = 1 + and `MEMBER`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| 1|SIMPLE |MEMBER|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt b/api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt new file mode 100644 index 000000000..8dc4bd005 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt @@ -0,0 +1,17 @@ +select + `PROBLEM`.`ID` as `id`, + `PROBLEM`.`ANSWER` as `answer`, + `PROBLEM`.`EXPLANATION` as `explanation` +from `PROBLEM` +where ( + `PROBLEM`.`ID` = 1 + and `PROBLEM`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| 1|SIMPLE |PROBLEM|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| ++----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt b/api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt new file mode 100644 index 000000000..543911e01 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt @@ -0,0 +1,17 @@ +select + `PROBLEM`.`ID` as `id`, + `PROBLEM`.`TITLE` as `title`, + JSON_UNQUOTE(`PROBLEM`.`CONTENTS`) as `contents` +from `PROBLEM` +where ( + `PROBLEM`.`ID` = 1 + and `PROBLEM`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| 1|SIMPLE |PROBLEM|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| ++----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt b/api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt new file mode 100644 index 000000000..60b87d049 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt @@ -0,0 +1,23 @@ +select + `PROBLEM`.`ID`, + `PROBLEM`.`ARTICLE_ID`, + `PROBLEM`.`TITLE`, + `PROBLEM`.`CONTENTS`, + `PROBLEM`.`ANSWER`, + `PROBLEM`.`EXPLANATION`, + `PROBLEM`.`CREATOR_ID`, + `PROBLEM`.`CREATED_AT`, + `PROBLEM`.`DELETED_AT` +from `PROBLEM` +where ( + `PROBLEM`.`ARTICLE_ID` = 1 + and `PROBLEM`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+-------+----------+----+-------------+------------+-------+-----+----+--------+-----------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+-------+----------+----+-------------+------------+-------+-----+----+--------+-----------+ +| 1|SIMPLE |PROBLEM|{null} |ref |problem_idx1 |problem_idx1|8 |const| 1| 100.0|Using where| ++----+-----------+-------+----------+----+-------------+------------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt b/api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt new file mode 100644 index 000000000..47eb96261 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt @@ -0,0 +1,19 @@ +select + `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `workbookId`, + (`SUBSCRIPTION`.`DELETED_AT` is null) as `isActiveSub`, + (`SUBSCRIPTION`.`PROGRESS` + 1) as `day` +from `SUBSCRIPTION` +where ( + `SUBSCRIPTION`.`MEMBER_ID` = 1 + and `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` = 1 +) +order by `SUBSCRIPTION`.`CREATED_AT` desc +limit 1 + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------+----------+-----+------------------------------------------------------------------------------------------------------------------+------------------+-------+-----------+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------+----------+-----+------------------------------------------------------------------------------------------------------------------+------------------+-------+-----------+----+--------+------+ +| 1|SIMPLE |SUBSCRIPTION|{null} |const|target_workbook_id,subscription_unique_member_id_target_member_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |const,const| 1| 100.0|{null}| ++----+-----------+------------+----------+-----+------------------------------------------------------------------------------------------------------------------+------------------+-------+-----------+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt b/api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt new file mode 100644 index 000000000..6c8cc6ba4 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt @@ -0,0 +1,31 @@ +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 `ARTICLE_MST` + join `ARTICLE_IFO` + on `ARTICLE_MST`.`ID` = `ARTICLE_IFO`.`ARTICLE_MST_ID` + join `MAPPING_WORKBOOK_ARTICLE` + on ( + `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 + and `MAPPING_WORKBOOK_ARTICLE`.`ARTICLE_ID` = `ARTICLE_MST`.`ID` + ) +where ( + `ARTICLE_MST`.`ID` = 1 + and `ARTICLE_MST`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------------------+----------+-----+-------------+-------+-------+-----------+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------------------+----------+-----+-------------+-------+-------+-----------+----+--------+------+ +| 1|SIMPLE |ARTICLE_MST |{null} |const|PRIMARY |PRIMARY|8 |const | 1| 100.0|{null}| +| 1|SIMPLE |ARTICLE_IFO |{null} |const|PRIMARY |PRIMARY|8 |const | 1| 100.0|{null}| +| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |const|PRIMARY |PRIMARY|16 |const,const| 1| 100.0|{null}| ++----+-----------+------------------------+----------+-----+-------------+-------+-------+-----------+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt b/api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt new file mode 100644 index 000000000..7e1a25bda --- /dev/null +++ b/api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt @@ -0,0 +1,20 @@ +select + `WORKBOOK`.`ID` as `id`, + `WORKBOOK`.`TITLE` as `title`, + `WORKBOOK`.`MAIN_IMAGE_URL` as `mainImageUrl`, + `WORKBOOK`.`CATEGORY_CD` as `category`, + `WORKBOOK`.`DESCRIPTION` as `description`, + `WORKBOOK`.`CREATED_AT` as `createdAt` +from `WORKBOOK` +where ( + `WORKBOOK`.`ID` = 1 + and `WORKBOOK`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+--------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+--------+----------+-----+-------------+-------+-------+-----+----+--------+------+ +| 1|SIMPLE |WORKBOOK|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| ++----+-----------+--------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt b/api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt new file mode 100644 index 000000000..516b95b4b --- /dev/null +++ b/api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt @@ -0,0 +1,28 @@ +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 outer join `ARTICLE_MST` + on `MAPPING_WORKBOOK_ARTICLE`.`ARTICLE_ID` = `ARTICLE_MST`.`ID` + join `ARTICLE_IFO` + on `ARTICLE_MST`.`ID` = `ARTICLE_IFO`.`ARTICLE_MST_ID` +where ( + `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 + and `ARTICLE_MST`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------------------------+----------+------+-------------+-------+-------+---------------------------------------+----+--------+-----------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------------------+----------+------+-------------+-------+-------+---------------------------------------+----+--------+-----------+ +| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |ALL |PRIMARY |{null} |{null} |{null} | 1| 100.0|Using where| +| 1|SIMPLE |ARTICLE_MST |{null} |eq_ref|PRIMARY |PRIMARY|8 |api.MAPPING_WORKBOOK_ARTICLE.article_id| 1| 100.0|Using where| +| 1|SIMPLE |ARTICLE_IFO |{null} |eq_ref|PRIMARY |PRIMARY|8 |api.MAPPING_WORKBOOK_ARTICLE.article_id| 1| 100.0|{null} | ++----+-----------+------------------------+----------+------+-------------+-------+-------+---------------------------------------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectWriterQueryExplain.txt b/api-repo/src/test/resources/explain/selectWriterQueryExplain.txt new file mode 100644 index 000000000..a6a3ef35c --- /dev/null +++ b/api-repo/src/test/resources/explain/selectWriterQueryExplain.txt @@ -0,0 +1,28 @@ +select + `MEMBER`.`ID` as `writerId`, + json_unquote(nullif( + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'name') + ), + cast('null' as json) + )) as `name`, + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'url') + ) as `url`, + `MEMBER`.`IMG_URL` as `imgUrl` +from `MEMBER` +where ( + `MEMBER`.`ID` = 1 + and `MEMBER`.`TYPE_CD` = 120 + and `MEMBER`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+------+----------+------+-------------+------+-------+------+------+--------+---------------------------------------------------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+------+----------+------+-------------+------+-------+------+------+--------+---------------------------------------------------+ +| 1|SIMPLE |{null}|{null} |{null}|{null} |{null}|{null} |{null}|{null}| {null}|Impossible WHERE noticed after reading const tables| ++----+-----------+------+----------+------+-------------+------+-------+------+------+--------+---------------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/selectWritersQueryExplain.txt b/api-repo/src/test/resources/explain/selectWritersQueryExplain.txt new file mode 100644 index 000000000..e8f24d279 --- /dev/null +++ b/api-repo/src/test/resources/explain/selectWritersQueryExplain.txt @@ -0,0 +1,31 @@ +select + `MEMBER`.`ID` as `writerId`, + json_unquote(nullif( + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'name') + ), + cast('null' as json) + )) as `name`, + json_extract( + `MEMBER`.`DESCRIPTION`, + concat('$.', 'url') + ) as `url`, + `MEMBER`.`IMG_URL` as `imgUrl` +from `MEMBER` +where ( + `MEMBER`.`ID` in ( + 2, 3 + ) + and `MEMBER`.`TYPE_CD` = 120 + and `MEMBER`.`DELETED_AT` is null +) +order by `MEMBER`.`ID` asc + +Explain [cost=NaN, rows=2.00] + ++----+-----------+------+----------+-----+-------------+-------+-------+------+----+--------+-----------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------+----------+-----+-------------+-------+-------+------+----+--------+-----------+ +| 1|SIMPLE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |{null}| 2| 33.33|Using where| ++----+-----------+------+----------+-----+-------------+-------+-------+------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt b/api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt new file mode 100644 index 000000000..21b94333d --- /dev/null +++ b/api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt @@ -0,0 +1,13 @@ +update `SUBSCRIPTION` +set + `SUBSCRIPTION`.`DELETED_AT` = {ts '2024-08-04 20:06:51.272108'}, + `SUBSCRIPTION`.`UNSUBS_OPINION` = 'test' +where `SUBSCRIPTION`.`MEMBER_ID` = 1 + +Explain [cost=NaN, rows=2.00] + ++----+-----------+------------+----------+-----+-----------------------------------------------------------------------------------------------+----------------------------------------------+-------+-----+----+--------+-----------+ +| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | ++----+-----------+------------+----------+-----+-----------------------------------------------------------------------------------------------+----------------------------------------------+-------+-----+----+--------+-----------+ +| 1|UPDATE |SUBSCRIPTION|{null} |range|subscription_unique_member_id_target_member_id,subscription_unique_member_id_target_workbook_id|subscription_unique_member_id_target_member_id|8 |const| 2| 100.0|Using where| ++----+-----------+------------+----------+-----+-----------------------------------------------------------------------------------------------+----------------------------------------------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt b/api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt new file mode 100644 index 000000000..3430c6814 --- /dev/null +++ b/api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt @@ -0,0 +1,13 @@ +update `MEMBER` +set + `MEMBER`.`TYPE_CD` = 120, + `MEMBER`.`DELETED_AT` = null +where `MEMBER`.`ID` = 1 + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ +| 1|UPDATE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |const| 1| 100.0|Using where| ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt b/api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt new file mode 100644 index 000000000..659770260 --- /dev/null +++ b/api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt @@ -0,0 +1,15 @@ +update `MEMBER` +set + `MEMBER`.`TYPE_CD` = 120 +where ( + `MEMBER`.`ID` = 1 + and `MEMBER`.`DELETED_AT` is null +) + +Explain [cost=NaN, rows=1.00] + ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ +| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ +| 1|UPDATE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |const| 1| 100.0|Using where| ++----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt b/api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt new file mode 100644 index 000000000..50904a7ef --- /dev/null +++ b/api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt @@ -0,0 +1,16 @@ +insert into `ARTICLE_VIEW_COUNT` (`ARTICLE_ID`, `VIEW_COUNT`, `CATEGORY_CD`) +values ( + 1, + 1, + 0 +) +on duplicate key update + `ARTICLE_VIEW_COUNT`.`VIEW_COUNT` = (`ARTICLE_VIEW_COUNT`.`VIEW_COUNT` + 1) + +Explain [cost=NaN, rows=0.00] + ++----+-----------+------------------+----------+----+-------------+------+-------+------+------+--------+------+ +| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | ++----+-----------+------------------+----------+----+-------------+------+-------+------+------+--------+------+ +| 1|INSERT |ARTICLE_VIEW_COUNT|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| ++----+-----------+------------------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt index e832feb97..028ab8837 100644 --- a/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt @@ -9,6 +9,7 @@ import com.few.api.domain.article.service.dto.ReadWriterOutDto import com.few.api.domain.article.usecase.dto.ReadArticleUseCaseIn import com.few.api.repo.dao.article.ArticleDao import com.few.api.repo.dao.article.record.SelectArticleRecord +import com.few.data.common.code.MemberDefaultImage import io.github.oshai.kotlinlogging.KotlinLogging import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.BehaviorSpec @@ -57,7 +58,8 @@ class ReadArticleUseCaseTest : BehaviorSpec({ val writerSvcOutDto = ReadWriterOutDto( writerId = 1L, name = "hunca", - url = URL("https://jh-labs.tistory.com/") + url = URL("https://jh-labs.tistory.com/"), + imgUrl = URL(MemberDefaultImage.getRandom().url) ) val probSvcOutDto = BrowseArticleProblemsOutDto(problemIds = listOf(1, 2, 3)) diff --git a/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt b/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt index 958ff7075..9c38dc990 100644 --- a/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt +++ b/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt @@ -12,6 +12,7 @@ import com.few.api.web.controller.ControllerTestSpec import com.few.api.web.controller.description.Description import com.few.api.web.controller.helper.* import com.few.data.common.code.CategoryType +import com.few.data.common.code.MemberDefaultImage import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test @@ -78,7 +79,8 @@ class ArticleControllerTest : ControllerTestSpec() { writer = WriterDetail( id = 1L, name = "안나포", - url = URL("http://localhost:8080/api/v1/writers/1") + url = URL("http://localhost:8080/api/v1/writers/1"), + imgUrl = URL(MemberDefaultImage.getRandom().url) ), mainImageUrl = URL("https://github.com/YAPP-Github/24th-Web-Team-1-BE/assets/102807742/0643d805-5f3a-4563-8c48-2a7d51795326"), title = "ETF(상장 지수 펀드)란? 모르면 손해라고?", @@ -115,6 +117,8 @@ class ArticleControllerTest : ControllerTestSpec() { .fieldWithString("아티클 작가 이름"), PayloadDocumentation.fieldWithPath("data.writer.url") .fieldWithString("아티클 작가 링크"), + PayloadDocumentation.fieldWithPath("data.writer.imgUrl") + .fieldWithString("아티클 작가 이미지 링크(non-null)"), PayloadDocumentation.fieldWithPath("data.mainImageUrl") .fieldWithString("아티클 썸네일 이미지 링크"), PayloadDocumentation.fieldWithPath("data.title") @@ -161,7 +165,8 @@ class ArticleControllerTest : ControllerTestSpec() { writer = WriterDetail( id = 1L, name = "안나포", - url = URL("http://localhost:8080/api/v1/writers/1") + url = URL("http://localhost:8080/api/v1/writers/1"), + imgUrl = URL(MemberDefaultImage.getRandom().url) ), mainImageUrl = URL("https://github.com/YAPP-Github/24th-Web-Team-1-BE/assets/102807742/0643d805-5f3a-4563-8c48-2a7d51795326"), title = "ETF(상장 지수 펀드)란? 모르면 손해라고?", @@ -218,6 +223,8 @@ class ArticleControllerTest : ControllerTestSpec() { .fieldWithString("아티클 작가 이름"), PayloadDocumentation.fieldWithPath("data.articles[].writer.url") .fieldWithString("아티클 작가 링크"), + PayloadDocumentation.fieldWithPath("data.articles[].writer.imgUrl") + .fieldWithString("아티클 작가 이미지 링크(non-null)"), PayloadDocumentation.fieldWithPath("data.articles[].mainImageUrl") .fieldWithString("아티클 썸네일 이미지 링크"), PayloadDocumentation.fieldWithPath("data.articles[].title") From 2057d8eeaceb70ef439eabb9708f277b82d75d2d Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 20:14:04 +0900 Subject: [PATCH 6/8] =?UTF-8?q?docs:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../browseWorkBookQueryCategoryCondition.txt | 38 ------------------- .../browseWorkBookQueryNoConditionQuery.txt | 35 ----------------- ...untAllWorkbookSubscriptionQueryExplain.txt | 13 ------- ...ountWorkbookMappedArticlesQueryExplain.txt | 11 ------ .../explain/deleteMemberCommandExplain.txt | 13 ------- .../insertArticleIfoCommandExplain.txt | 13 ------- .../insertArticleMstCommandExplain.txt | 15 -------- .../insertArticleViewHisCommandExplain.txt | 13 ------- .../explain/insertMemberCommandExplain.txt | 14 ------- .../explain/insertProblemCommandExplain.txt | 24 ------------ .../explain/insertSubmitCommandExplain.txt | 15 -------- .../explain/insertWorkBookCommandExplain.txt | 15 -------- ...sertWorkbookSubscriptionCommandExplain.txt | 13 ------- ...WorkbookSubscriptionStatusQueryExplain.txt | 22 ----------- ...rticleIdByWorkbookIdAndDayQueryExplain.txt | 14 ------- .../selectArticleRecordQueryExplain.txt | 24 ------------ .../selectArticleViewCountQueryExplain.txt | 11 ------ ...yEmailNotConsiderDeletedAtQueryExplain.txt | 27 ------------- ...selectMemberByEmailQueryExplainExplain.txt | 27 ------------- .../selectMemberIdAndTypeQueryExplain.txt | 16 -------- .../selectProblemAnswerQueryExplain.txt | 17 --------- .../selectProblemContentsQueryExplain.txt | 17 --------- .../selectProblemsByArticleIdQueryExplain.txt | 23 ----------- ...WorkbookSubscriptionStatusQueryExplain.txt | 19 ---------- ...electWorkBookArticleRecordQueryExplain.txt | 31 --------------- .../explain/selectWorkBookQueryExplain.txt | 20 ---------- ...rkbookMappedArticleRecordsQueryExplain.txt | 28 -------------- .../explain/selectWriterQueryExplain.txt | 28 -------------- .../explain/selectWritersQueryExplain.txt | 31 --------------- ...letedAtInAllSubscriptionCommandExplain.txt | 13 ------- .../updateDeletedMemberTypeCommandExplain.txt | 13 ------- .../updateMemberTypeCommandExplain.txt | 15 -------- .../upsertArticleViewCountQueryExplain.txt | 16 -------- 33 files changed, 644 deletions(-) delete mode 100644 api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt delete mode 100644 api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt delete mode 100644 api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertMemberCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertProblemCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectWriterQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/selectWritersQueryExplain.txt delete mode 100644 api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt delete mode 100644 api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt diff --git a/api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt b/api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt deleted file mode 100644 index 1aca3110c..000000000 --- a/api-repo/src/test/resources/explain/browseWorkBookQueryCategoryCondition.txt +++ /dev/null @@ -1,38 +0,0 @@ -select - `WORKBOOK`.`ID` as `id`, - `WORKBOOK`.`TITLE` as `title`, - `WORKBOOK`.`MAIN_IMAGE_URL` as `mainImageUrl`, - `WORKBOOK`.`CATEGORY_CD` as `category`, - `WORKBOOK`.`DESCRIPTION` as `description`, - `WORKBOOK`.`CREATED_AT` as `createdAt`, - coalesce( - subscription_count_table.subscription_count, - 0 - ) as `subscriptionCount` -from `WORKBOOK` - left outer join ( - select - `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `TARGET_WORKBOOK_ID`, - count(`SUBSCRIPTION`.`TARGET_WORKBOOK_ID`) as `subscription_count` - from `SUBSCRIPTION` - where `SUBSCRIPTION`.`DELETED_AT` is null - group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` - ) as `subscription_count_table` - on `WORKBOOK`.`ID` = subscription_count_table.TARGET_WORKBOOK_ID -where ( - `WORKBOOK`.`CATEGORY_CD` = 0 - and `WORKBOOK`.`DELETED_AT` is null -) -order by - subscription_count_table.subscription_count desc, - `WORKBOOK`.`CREATED_AT` desc - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ -| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ -| 1|PRIMARY |WORKBOOK |{null} |ALL |{null} |{null} |{null} |{null} | 1| 100.0|Using where; Using temporary; Using filesort| -| 1|PRIMARY | |{null} |ref | | |9 |api.WORKBOOK.id| 2| 100.0|{null} | -| 2|DERIVED |SUBSCRIPTION|{null} |index|target_workbook_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |{null} | 1| 100.0|Using where | -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt b/api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt deleted file mode 100644 index 1a0380d86..000000000 --- a/api-repo/src/test/resources/explain/browseWorkBookQueryNoConditionQuery.txt +++ /dev/null @@ -1,35 +0,0 @@ -select - `WORKBOOK`.`ID` as `id`, - `WORKBOOK`.`TITLE` as `title`, - `WORKBOOK`.`MAIN_IMAGE_URL` as `mainImageUrl`, - `WORKBOOK`.`CATEGORY_CD` as `category`, - `WORKBOOK`.`DESCRIPTION` as `description`, - `WORKBOOK`.`CREATED_AT` as `createdAt`, - coalesce( - subscription_count_table.subscription_count, - 0 - ) as `subscriptionCount` -from `WORKBOOK` - left outer join ( - select - `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `TARGET_WORKBOOK_ID`, - count(`SUBSCRIPTION`.`TARGET_WORKBOOK_ID`) as `subscription_count` - from `SUBSCRIPTION` - where `SUBSCRIPTION`.`DELETED_AT` is null - group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` - ) as `subscription_count_table` - on `WORKBOOK`.`ID` = subscription_count_table.TARGET_WORKBOOK_ID -where `WORKBOOK`.`DELETED_AT` is null -order by - subscription_count_table.subscription_count desc, - `WORKBOOK`.`CREATED_AT` desc - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ -| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ -| 1|PRIMARY |WORKBOOK |{null} |ALL |{null} |{null} |{null} |{null} | 1| 100.0|Using where; Using temporary; Using filesort| -| 1|PRIMARY | |{null} |ref | | |9 |api.WORKBOOK.id| 2| 100.0|{null} | -| 2|DERIVED |SUBSCRIPTION|{null} |index|target_workbook_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |{null} | 1| 100.0|Using where | -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+---------------+----+--------+--------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt b/api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt deleted file mode 100644 index 3e206263a..000000000 --- a/api-repo/src/test/resources/explain/countAllWorkbookSubscriptionQueryExplain.txt +++ /dev/null @@ -1,13 +0,0 @@ -select - `SUBSCRIPTION`.`TARGET_WORKBOOK_ID`, - count(`SUBSCRIPTION`.`TARGET_WORKBOOK_ID`) -from `SUBSCRIPTION` -group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+------+----+--------+-----------+ -| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+------+----+--------+-----------+ -| 1|SIMPLE |SUBSCRIPTION|{null} |index|target_workbook_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |{null}| 1| 100.0|Using index| -+----+-----------+------------+----------+-----+-------------------------------------------------------------------+------------------+-------+------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt b/api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt deleted file mode 100644 index cc1196661..000000000 --- a/api-repo/src/test/resources/explain/countWorkbookMappedArticlesQueryExplain.txt +++ /dev/null @@ -1,11 +0,0 @@ -select count(*) -from `MAPPING_WORKBOOK_ARTICLE` -where `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------------------+----------+-----+-------------+-------+-------+------+----+--------+------------------------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------------------+----------+-----+-------------+-------+-------+------+----+--------+------------------------+ -| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |index|PRIMARY |PRIMARY|16 |{null}| 1| 100.0|Using where; Using index| -+----+-----------+------------------------+----------+-----+-------------+-------+-------+------+----+--------+------------------------+ diff --git a/api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt b/api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt deleted file mode 100644 index 3430c6814..000000000 --- a/api-repo/src/test/resources/explain/deleteMemberCommandExplain.txt +++ /dev/null @@ -1,13 +0,0 @@ -update `MEMBER` -set - `MEMBER`.`TYPE_CD` = 120, - `MEMBER`.`DELETED_AT` = null -where `MEMBER`.`ID` = 1 - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ -| 1|UPDATE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |const| 1| 100.0|Using where| -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt b/api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt deleted file mode 100644 index fce2eb21f..000000000 --- a/api-repo/src/test/resources/explain/insertArticleIfoCommandExplain.txt +++ /dev/null @@ -1,13 +0,0 @@ -insert into `ARTICLE_IFO` (`ARTICLE_MST_ID`, `CONTENT`) -values ( - 1, - 'this is content1' -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |ARTICLE_IFO|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt b/api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt deleted file mode 100644 index 2acbcefc3..000000000 --- a/api-repo/src/test/resources/explain/insertArticleMstCommandExplain.txt +++ /dev/null @@ -1,15 +0,0 @@ -insert into `ARTICLE_MST` (`MEMBER_ID`, `MAIN_IMAGE_URL`, `TITLE`, `CATEGORY_CD`) -values ( - 100, - 'http://localhost:8080/image1.jpg', - 'this is title1', - 0 -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |ARTICLE_MST|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+-----------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt b/api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt deleted file mode 100644 index a6763ab92..000000000 --- a/api-repo/src/test/resources/explain/insertArticleViewHisCommandExplain.txt +++ /dev/null @@ -1,13 +0,0 @@ -insert into `ARTICLE_VIEW_HIS` (`ARTICLE_MST_ID`, `MEMBER_ID`) -values ( - 1, - 1 -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+----------------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+----------------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |ARTICLE_VIEW_HIS|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+----------------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertMemberCommandExplain.txt b/api-repo/src/test/resources/explain/insertMemberCommandExplain.txt deleted file mode 100644 index 327f6bff3..000000000 --- a/api-repo/src/test/resources/explain/insertMemberCommandExplain.txt +++ /dev/null @@ -1,14 +0,0 @@ -insert into `MEMBER` (`EMAIL`, `TYPE_CD`, `IMG_URL`) -values ( - 'test100@gmail.com', - 60, - 'https://github.com/user-attachments/assets/28df9078-488c-49d6-9375-54ce5a250742' -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |MEMBER|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertProblemCommandExplain.txt b/api-repo/src/test/resources/explain/insertProblemCommandExplain.txt deleted file mode 100644 index af546ad59..000000000 --- a/api-repo/src/test/resources/explain/insertProblemCommandExplain.txt +++ /dev/null @@ -1,24 +0,0 @@ -insert into `PROBLEM` ( - `ARTICLE_ID`, - `CREATOR_ID`, - `TITLE`, - `CONTENTS`, - `ANSWER`, - `EXPLANATION` -) -values ( - 1, - 1, - 'problem title', - '{"contents":[{"number":1,"content":"content1"},{"number":2,"content":"content2"}]}', - '1', - 'explanation' -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+-------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+-------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |PROBLEM|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+-------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt b/api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt deleted file mode 100644 index 0b84443d1..000000000 --- a/api-repo/src/test/resources/explain/insertSubmitCommandExplain.txt +++ /dev/null @@ -1,15 +0,0 @@ -insert into `SUBMIT_HISTORY` (`PROBLEM_ID`, `MEMBER_ID`, `SUBMIT_ANS`, `IS_SOLVED`) -values ( - 1, - 1, - '1', - true -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+--------------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+--------------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |SUBMIT_HISTORY|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+--------------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt b/api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt deleted file mode 100644 index e09a7cf15..000000000 --- a/api-repo/src/test/resources/explain/insertWorkBookCommandExplain.txt +++ /dev/null @@ -1,15 +0,0 @@ -insert into `WORKBOOK` (`TITLE`, `MAIN_IMAGE_URL`, `CATEGORY_CD`, `DESCRIPTION`) -values ( - 'title2', - 'http://localhost:8080/image2.jpg', - 0, - 'description2' -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+--------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+--------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |WORKBOOK|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+--------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt b/api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt deleted file mode 100644 index 0d2373aca..000000000 --- a/api-repo/src/test/resources/explain/insertWorkbookSubscriptionCommandExplain.txt +++ /dev/null @@ -1,13 +0,0 @@ -insert into `SUBSCRIPTION` (`MEMBER_ID`, `TARGET_WORKBOOK_ID`) -values ( - 1, - 1 -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+------------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+------------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |SUBSCRIPTION|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+------------+----------+----+-------------+------+-------+------+------+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt b/api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt deleted file mode 100644 index 08baf5912..000000000 --- a/api-repo/src/test/resources/explain/selectAllTopWorkbookSubscriptionStatusQueryExplain.txt +++ /dev/null @@ -1,22 +0,0 @@ -select - `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `workbookId`, - (`SUBSCRIPTION`.`DELETED_AT` is null) as `isActiveSub`, - (max(`SUBSCRIPTION`.`PROGRESS`) + 1) as `currentDay`, - max(`MAPPING_WORKBOOK_ARTICLE`.`DAY_COL`) as `totalDay` -from `SUBSCRIPTION` - left outer join `MAPPING_WORKBOOK_ARTICLE` - on `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` = `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` -where ( - `SUBSCRIPTION`.`MEMBER_ID` = 1 - and `SUBSCRIPTION`.`TARGET_MEMBER_ID` is null -) -group by `SUBSCRIPTION`.`TARGET_WORKBOOK_ID`, `SUBSCRIPTION`.`DELETED_AT` - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------------------+----------+----+----------------------------------------------------------------------------------------------------------------+----------------+-------+-----------+----+--------+------------------------------------------+ -| id|select_type|table |partitions|type|possible_keys |key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------------------+----------+----+----------------------------------------------------------------------------------------------------------------+----------------+-------+-----------+----+--------+------------------------------------------+ -| 1|SIMPLE |SUBSCRIPTION |{null} |ref |target_member_id,subscription_unique_member_id_target_member_id,subscription_unique_member_id_target_workbook_id|target_member_id|17 |const,const| 1| 100.0|Using index condition; Using temporary | -| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |ALL |{null} |{null} |{null} |{null} | 1| 100.0|Using where; Using join buffer (hash join)| -+----+-----------+------------------------+----------+----+----------------------------------------------------------------------------------------------------------------+----------------+-------+-----------+----+--------+------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt b/api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt deleted file mode 100644 index 795d3242b..000000000 --- a/api-repo/src/test/resources/explain/selectArticleIdByWorkbookIdAndDayQueryExplain.txt +++ /dev/null @@ -1,14 +0,0 @@ -select `MAPPING_WORKBOOK_ARTICLE`.`ARTICLE_ID` -from `MAPPING_WORKBOOK_ARTICLE` -where ( - `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 - and `MAPPING_WORKBOOK_ARTICLE`.`DAY_COL` = 1 -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------------------+----------+----+-------------+------+-------+------+----+--------+-----------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------------------+----------+----+-------------+------+-------+------+----+--------+-----------+ -| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |ALL |{null} |{null}|{null} |{null}| 1| 100.0|Using where| -+----+-----------+------------------------+----------+----+-------------+------+-------+------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt b/api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt deleted file mode 100644 index 02d535a16..000000000 --- a/api-repo/src/test/resources/explain/selectArticleRecordQueryExplain.txt +++ /dev/null @@ -1,24 +0,0 @@ -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` -from `ARTICLE_MST` - join `ARTICLE_IFO` - on `ARTICLE_MST`.`ID` = `ARTICLE_IFO`.`ARTICLE_MST_ID` -where ( - `ARTICLE_MST`.`ID` = 1 - and `ARTICLE_MST`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+-----------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+-----------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| 1|SIMPLE |ARTICLE_MST|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| -| 1|SIMPLE |ARTICLE_IFO|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| -+----+-----------+-----------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt b/api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt deleted file mode 100644 index 5a12b14f4..000000000 --- a/api-repo/src/test/resources/explain/selectArticleViewCountQueryExplain.txt +++ /dev/null @@ -1,11 +0,0 @@ -select count(*) -from `ARTICLE_VIEW_HIS` -where `ARTICLE_VIEW_HIS`.`ARTICLE_MST_ID` = 1 - -Explain [cost=NaN, rows=1.00] - -+----+-----------+----------------+----------+----+---------------------+---------------------+-------+-----+----+--------+-----------+ -| id|select_type|table |partitions|type|possible_keys |key |key_len|ref |rows|filtered|Extra | -+----+-----------+----------------+----------+----+---------------------+---------------------+-------+-----+----+--------+-----------+ -| 1|SIMPLE |ARTICLE_VIEW_HIS|{null} |ref |article_view_his_idx1|article_view_his_idx1|8 |const| 1| 100.0|Using index| -+----+-----------+----------------+----------+----+---------------------+---------------------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt b/api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt deleted file mode 100644 index 1b59cb80e..000000000 --- a/api-repo/src/test/resources/explain/selectMemberByEmailNotConsiderDeletedAtQueryExplain.txt +++ /dev/null @@ -1,27 +0,0 @@ -select - `MEMBER`.`ID` as `memberId`, - `MEMBER`.`IMG_URL` as `imageUrl`, - json_unquote(nullif( - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'name') - ), - cast('null' as json) - )) as `writerName`, - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'url') - ) as `writerUrl` -from `MEMBER` -where ( - `MEMBER`.`EMAIL` = 'test@gmail.com' - and `MEMBER`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+------+----------+------+-------------+------+-------+------+------+--------+------------------------------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+------+----------+------+-------------+------+-------+------+------+--------+------------------------------+ -| 1|SIMPLE |{null}|{null} |{null}|{null} |{null}|{null} |{null}|{null}| {null}|no matching row in const table| -+----+-----------+------+----------+------+-------------+------+-------+------+------+--------+------------------------------+ diff --git a/api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt b/api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt deleted file mode 100644 index ab60615c5..000000000 --- a/api-repo/src/test/resources/explain/selectMemberByEmailQueryExplainExplain.txt +++ /dev/null @@ -1,27 +0,0 @@ -select - `MEMBER`.`ID` as `memberId`, - `MEMBER`.`IMG_URL` as `imageUrl`, - json_unquote(nullif( - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'name') - ), - cast('null' as json) - )) as `writerName`, - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'url') - ) as `writerUrl` -from `MEMBER` -where ( - `MEMBER`.`EMAIL` = 'member@gmail.com' - and `MEMBER`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------+----------+-----+-------------+-----+-------+-----+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------+----------+-----+-------------+-----+-------+-----+----+--------+------+ -| 1|SIMPLE |MEMBER|{null} |const|email |email|1022 |const| 1| 100.0|{null}| -+----+-----------+------+----------+-----+-------------+-----+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt b/api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt deleted file mode 100644 index 1c772ec71..000000000 --- a/api-repo/src/test/resources/explain/selectMemberIdAndTypeQueryExplain.txt +++ /dev/null @@ -1,16 +0,0 @@ -select - `MEMBER`.`EMAIL` as `email`, - `MEMBER`.`TYPE_CD` as `memberType` -from `MEMBER` -where ( - `MEMBER`.`ID` = 1 - and `MEMBER`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| 1|SIMPLE |MEMBER|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt b/api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt deleted file mode 100644 index 8dc4bd005..000000000 --- a/api-repo/src/test/resources/explain/selectProblemAnswerQueryExplain.txt +++ /dev/null @@ -1,17 +0,0 @@ -select - `PROBLEM`.`ID` as `id`, - `PROBLEM`.`ANSWER` as `answer`, - `PROBLEM`.`EXPLANATION` as `explanation` -from `PROBLEM` -where ( - `PROBLEM`.`ID` = 1 - and `PROBLEM`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| 1|SIMPLE |PROBLEM|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| -+----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt b/api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt deleted file mode 100644 index 543911e01..000000000 --- a/api-repo/src/test/resources/explain/selectProblemContentsQueryExplain.txt +++ /dev/null @@ -1,17 +0,0 @@ -select - `PROBLEM`.`ID` as `id`, - `PROBLEM`.`TITLE` as `title`, - JSON_UNQUOTE(`PROBLEM`.`CONTENTS`) as `contents` -from `PROBLEM` -where ( - `PROBLEM`.`ID` = 1 - and `PROBLEM`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| 1|SIMPLE |PROBLEM|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| -+----+-----------+-------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt b/api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt deleted file mode 100644 index 60b87d049..000000000 --- a/api-repo/src/test/resources/explain/selectProblemsByArticleIdQueryExplain.txt +++ /dev/null @@ -1,23 +0,0 @@ -select - `PROBLEM`.`ID`, - `PROBLEM`.`ARTICLE_ID`, - `PROBLEM`.`TITLE`, - `PROBLEM`.`CONTENTS`, - `PROBLEM`.`ANSWER`, - `PROBLEM`.`EXPLANATION`, - `PROBLEM`.`CREATOR_ID`, - `PROBLEM`.`CREATED_AT`, - `PROBLEM`.`DELETED_AT` -from `PROBLEM` -where ( - `PROBLEM`.`ARTICLE_ID` = 1 - and `PROBLEM`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+-------+----------+----+-------------+------------+-------+-----+----+--------+-----------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+-------+----------+----+-------------+------------+-------+-----+----+--------+-----------+ -| 1|SIMPLE |PROBLEM|{null} |ref |problem_idx1 |problem_idx1|8 |const| 1| 100.0|Using where| -+----+-----------+-------+----------+----+-------------+------------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt b/api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt deleted file mode 100644 index 47eb96261..000000000 --- a/api-repo/src/test/resources/explain/selectTopWorkbookSubscriptionStatusQueryExplain.txt +++ /dev/null @@ -1,19 +0,0 @@ -select - `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` as `workbookId`, - (`SUBSCRIPTION`.`DELETED_AT` is null) as `isActiveSub`, - (`SUBSCRIPTION`.`PROGRESS` + 1) as `day` -from `SUBSCRIPTION` -where ( - `SUBSCRIPTION`.`MEMBER_ID` = 1 - and `SUBSCRIPTION`.`TARGET_WORKBOOK_ID` = 1 -) -order by `SUBSCRIPTION`.`CREATED_AT` desc -limit 1 - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------+----------+-----+------------------------------------------------------------------------------------------------------------------+------------------+-------+-----------+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------+----------+-----+------------------------------------------------------------------------------------------------------------------+------------------+-------+-----------+----+--------+------+ -| 1|SIMPLE |SUBSCRIPTION|{null} |const|target_workbook_id,subscription_unique_member_id_target_member_id,subscription_unique_member_id_target_workbook_id|target_workbook_id|17 |const,const| 1| 100.0|{null}| -+----+-----------+------------+----------+-----+------------------------------------------------------------------------------------------------------------------+------------------+-------+-----------+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt b/api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt deleted file mode 100644 index 6c8cc6ba4..000000000 --- a/api-repo/src/test/resources/explain/selectWorkBookArticleRecordQueryExplain.txt +++ /dev/null @@ -1,31 +0,0 @@ -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 `ARTICLE_MST` - join `ARTICLE_IFO` - on `ARTICLE_MST`.`ID` = `ARTICLE_IFO`.`ARTICLE_MST_ID` - join `MAPPING_WORKBOOK_ARTICLE` - on ( - `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 - and `MAPPING_WORKBOOK_ARTICLE`.`ARTICLE_ID` = `ARTICLE_MST`.`ID` - ) -where ( - `ARTICLE_MST`.`ID` = 1 - and `ARTICLE_MST`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------------------+----------+-----+-------------+-------+-------+-----------+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------------------+----------+-----+-------------+-------+-------+-----------+----+--------+------+ -| 1|SIMPLE |ARTICLE_MST |{null} |const|PRIMARY |PRIMARY|8 |const | 1| 100.0|{null}| -| 1|SIMPLE |ARTICLE_IFO |{null} |const|PRIMARY |PRIMARY|8 |const | 1| 100.0|{null}| -| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |const|PRIMARY |PRIMARY|16 |const,const| 1| 100.0|{null}| -+----+-----------+------------------------+----------+-----+-------------+-------+-------+-----------+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt b/api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt deleted file mode 100644 index 7e1a25bda..000000000 --- a/api-repo/src/test/resources/explain/selectWorkBookQueryExplain.txt +++ /dev/null @@ -1,20 +0,0 @@ -select - `WORKBOOK`.`ID` as `id`, - `WORKBOOK`.`TITLE` as `title`, - `WORKBOOK`.`MAIN_IMAGE_URL` as `mainImageUrl`, - `WORKBOOK`.`CATEGORY_CD` as `category`, - `WORKBOOK`.`DESCRIPTION` as `description`, - `WORKBOOK`.`CREATED_AT` as `createdAt` -from `WORKBOOK` -where ( - `WORKBOOK`.`ID` = 1 - and `WORKBOOK`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+--------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+--------+----------+-----+-------------+-------+-------+-----+----+--------+------+ -| 1|SIMPLE |WORKBOOK|{null} |const|PRIMARY |PRIMARY|8 |const| 1| 100.0|{null}| -+----+-----------+--------+----------+-----+-------------+-------+-------+-----+----+--------+------+ diff --git a/api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt b/api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt deleted file mode 100644 index 516b95b4b..000000000 --- a/api-repo/src/test/resources/explain/selectWorkbookMappedArticleRecordsQueryExplain.txt +++ /dev/null @@ -1,28 +0,0 @@ -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 outer join `ARTICLE_MST` - on `MAPPING_WORKBOOK_ARTICLE`.`ARTICLE_ID` = `ARTICLE_MST`.`ID` - join `ARTICLE_IFO` - on `ARTICLE_MST`.`ID` = `ARTICLE_IFO`.`ARTICLE_MST_ID` -where ( - `MAPPING_WORKBOOK_ARTICLE`.`WORKBOOK_ID` = 1 - and `ARTICLE_MST`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------------------------+----------+------+-------------+-------+-------+---------------------------------------+----+--------+-----------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------------------+----------+------+-------------+-------+-------+---------------------------------------+----+--------+-----------+ -| 1|SIMPLE |MAPPING_WORKBOOK_ARTICLE|{null} |ALL |PRIMARY |{null} |{null} |{null} | 1| 100.0|Using where| -| 1|SIMPLE |ARTICLE_MST |{null} |eq_ref|PRIMARY |PRIMARY|8 |api.MAPPING_WORKBOOK_ARTICLE.article_id| 1| 100.0|Using where| -| 1|SIMPLE |ARTICLE_IFO |{null} |eq_ref|PRIMARY |PRIMARY|8 |api.MAPPING_WORKBOOK_ARTICLE.article_id| 1| 100.0|{null} | -+----+-----------+------------------------+----------+------+-------------+-------+-------+---------------------------------------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/selectWriterQueryExplain.txt b/api-repo/src/test/resources/explain/selectWriterQueryExplain.txt deleted file mode 100644 index a6a3ef35c..000000000 --- a/api-repo/src/test/resources/explain/selectWriterQueryExplain.txt +++ /dev/null @@ -1,28 +0,0 @@ -select - `MEMBER`.`ID` as `writerId`, - json_unquote(nullif( - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'name') - ), - cast('null' as json) - )) as `name`, - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'url') - ) as `url`, - `MEMBER`.`IMG_URL` as `imgUrl` -from `MEMBER` -where ( - `MEMBER`.`ID` = 1 - and `MEMBER`.`TYPE_CD` = 120 - and `MEMBER`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+------+----------+------+-------------+------+-------+------+------+--------+---------------------------------------------------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+------+----------+------+-------------+------+-------+------+------+--------+---------------------------------------------------+ -| 1|SIMPLE |{null}|{null} |{null}|{null} |{null}|{null} |{null}|{null}| {null}|Impossible WHERE noticed after reading const tables| -+----+-----------+------+----------+------+-------------+------+-------+------+------+--------+---------------------------------------------------+ diff --git a/api-repo/src/test/resources/explain/selectWritersQueryExplain.txt b/api-repo/src/test/resources/explain/selectWritersQueryExplain.txt deleted file mode 100644 index e8f24d279..000000000 --- a/api-repo/src/test/resources/explain/selectWritersQueryExplain.txt +++ /dev/null @@ -1,31 +0,0 @@ -select - `MEMBER`.`ID` as `writerId`, - json_unquote(nullif( - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'name') - ), - cast('null' as json) - )) as `name`, - json_extract( - `MEMBER`.`DESCRIPTION`, - concat('$.', 'url') - ) as `url`, - `MEMBER`.`IMG_URL` as `imgUrl` -from `MEMBER` -where ( - `MEMBER`.`ID` in ( - 2, 3 - ) - and `MEMBER`.`TYPE_CD` = 120 - and `MEMBER`.`DELETED_AT` is null -) -order by `MEMBER`.`ID` asc - -Explain [cost=NaN, rows=2.00] - -+----+-----------+------+----------+-----+-------------+-------+-------+------+----+--------+-----------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------+----------+-----+-------------+-------+-------+------+----+--------+-----------+ -| 1|SIMPLE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |{null}| 2| 33.33|Using where| -+----+-----------+------+----------+-----+-------------+-------+-------+------+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt b/api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt deleted file mode 100644 index 21b94333d..000000000 --- a/api-repo/src/test/resources/explain/updateDeletedAtInAllSubscriptionCommandExplain.txt +++ /dev/null @@ -1,13 +0,0 @@ -update `SUBSCRIPTION` -set - `SUBSCRIPTION`.`DELETED_AT` = {ts '2024-08-04 20:06:51.272108'}, - `SUBSCRIPTION`.`UNSUBS_OPINION` = 'test' -where `SUBSCRIPTION`.`MEMBER_ID` = 1 - -Explain [cost=NaN, rows=2.00] - -+----+-----------+------------+----------+-----+-----------------------------------------------------------------------------------------------+----------------------------------------------+-------+-----+----+--------+-----------+ -| id|select_type|table |partitions|type |possible_keys |key |key_len|ref |rows|filtered|Extra | -+----+-----------+------------+----------+-----+-----------------------------------------------------------------------------------------------+----------------------------------------------+-------+-----+----+--------+-----------+ -| 1|UPDATE |SUBSCRIPTION|{null} |range|subscription_unique_member_id_target_member_id,subscription_unique_member_id_target_workbook_id|subscription_unique_member_id_target_member_id|8 |const| 2| 100.0|Using where| -+----+-----------+------------+----------+-----+-----------------------------------------------------------------------------------------------+----------------------------------------------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt b/api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt deleted file mode 100644 index 3430c6814..000000000 --- a/api-repo/src/test/resources/explain/updateDeletedMemberTypeCommandExplain.txt +++ /dev/null @@ -1,13 +0,0 @@ -update `MEMBER` -set - `MEMBER`.`TYPE_CD` = 120, - `MEMBER`.`DELETED_AT` = null -where `MEMBER`.`ID` = 1 - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ -| 1|UPDATE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |const| 1| 100.0|Using where| -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt b/api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt deleted file mode 100644 index 659770260..000000000 --- a/api-repo/src/test/resources/explain/updateMemberTypeCommandExplain.txt +++ /dev/null @@ -1,15 +0,0 @@ -update `MEMBER` -set - `MEMBER`.`TYPE_CD` = 120 -where ( - `MEMBER`.`ID` = 1 - and `MEMBER`.`DELETED_AT` is null -) - -Explain [cost=NaN, rows=1.00] - -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ -| id|select_type|table |partitions|type |possible_keys|key |key_len|ref |rows|filtered|Extra | -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ -| 1|UPDATE |MEMBER|{null} |range|PRIMARY |PRIMARY|8 |const| 1| 100.0|Using where| -+----+-----------+------+----------+-----+-------------+-------+-------+-----+----+--------+-----------+ diff --git a/api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt b/api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt deleted file mode 100644 index 50904a7ef..000000000 --- a/api-repo/src/test/resources/explain/upsertArticleViewCountQueryExplain.txt +++ /dev/null @@ -1,16 +0,0 @@ -insert into `ARTICLE_VIEW_COUNT` (`ARTICLE_ID`, `VIEW_COUNT`, `CATEGORY_CD`) -values ( - 1, - 1, - 0 -) -on duplicate key update - `ARTICLE_VIEW_COUNT`.`VIEW_COUNT` = (`ARTICLE_VIEW_COUNT`.`VIEW_COUNT` + 1) - -Explain [cost=NaN, rows=0.00] - -+----+-----------+------------------+----------+----+-------------+------+-------+------+------+--------+------+ -| id|select_type|table |partitions|type|possible_keys|key |key_len|ref | rows|filtered|Extra | -+----+-----------+------------------+----------+----+-------------+------+-------+------+------+--------+------+ -| 1|INSERT |ARTICLE_VIEW_COUNT|{null} |ALL |{null} |{null}|{null} |{null}|{null}| {null}|{null}| -+----+-----------+------------------+----------+----+-------------+------+-------+------+------+--------+------+ From 95502095b66d8ddd6667898140c6acc05eb70b31 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 20:15:04 +0900 Subject: [PATCH 7/8] =?UTF-8?q?docs:=20=EC=8B=A4=ED=96=89=EA=B3=84?= =?UTF-8?q?=ED=9A=8D=20=ED=8C=8C=EC=9D=BC=20gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 58041a262..23d73c64e 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ api-repo/**/*.sql batch/**/*.sql email/**/*.sql storage/**/*.sql + +# DB explain result files +**/resources/explain/ From 63e4cbacd3d1a658a246ce74ce4308592b2da8c9 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sun, 4 Aug 2024 20:30:52 +0900 Subject: [PATCH 8/8] =?UTF-8?q?fix:=20=EC=9E=91=EA=B0=80=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B0=98=EC=98=81=20?= =?UTF-8?q?=EC=B7=A8=EC=86=8C=20(=EC=9E=91=EA=B0=80=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=20=EA=B3=BC=EC=A0=95=20=EC=97=86=EC=9D=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt | 8 ++++---- .../repo/explain/member/MemberDaoExplainGenerateTest.kt | 4 ++-- .../few/api/domain/member/usecase/SaveMemberUseCase.kt | 4 ++-- .../few/api/domain/subscription/service/MemberService.kt | 4 ++-- .../api/domain/article/usecase/ReadArticleUseCaseTest.kt | 4 ++-- .../api/web/controller/article/ArticleControllerTest.kt | 6 +++--- .../code/{MemberDefaultImage.kt => WriterDefaultImage.kt} | 8 +++++--- 7 files changed, 20 insertions(+), 18 deletions(-) rename data/src/main/kotlin/com/few/data/common/code/{MemberDefaultImage.kt => WriterDefaultImage.kt} (63%) diff --git a/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt b/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt index f5586be29..a29367a57 100644 --- a/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt +++ b/api-repo/src/test/kotlin/com/few/api/repo/dao/member/MemberDaoTest.kt @@ -5,7 +5,7 @@ import com.few.api.repo.dao.member.query.SelectWritersQuery import com.few.api.repo.dao.member.support.WriterDescription import com.few.api.repo.dao.member.support.WriterDescriptionJsonMapper import com.few.api.repo.jooq.JooqTestSpec -import com.few.data.common.code.MemberDefaultImage +import com.few.data.common.code.MEMBER_DEFAULT_IMG_URL import com.few.data.common.code.MemberType import io.github.oshai.kotlinlogging.KotlinLogging import jooq.jooq_dsl.tables.Member @@ -41,7 +41,7 @@ class MemberDaoTest : JooqTestSpec() { .set(Member.MEMBER.ID, 1) .set(Member.MEMBER.EMAIL, "member@gmail.com") .set(Member.MEMBER.TYPE_CD, MemberType.NORMAL.code) - .set(Member.MEMBER.IMG_URL, MemberDefaultImage.getRandom().url) + .set(Member.MEMBER.IMG_URL, MEMBER_DEFAULT_IMG_URL) .execute() val writerDescription = writerDescriptionJsonMapper.toJson( @@ -53,7 +53,7 @@ class MemberDaoTest : JooqTestSpec() { .set(Member.MEMBER.EMAIL, "writer2@gmail.com") .set(Member.MEMBER.TYPE_CD, MemberType.WRITER.code) .set(Member.MEMBER.DESCRIPTION, JSON.valueOf(writerDescription)) - .set(Member.MEMBER.IMG_URL, MemberDefaultImage.getRandom().url) + .set(Member.MEMBER.IMG_URL, MEMBER_DEFAULT_IMG_URL) .execute() log.debug { "===== finish setUp =====" } } @@ -110,7 +110,7 @@ class MemberDaoTest : JooqTestSpec() { .set(Member.MEMBER.EMAIL, "writer$i@gmail.com") .set(Member.MEMBER.TYPE_CD, MemberType.WRITER.code) .set(Member.MEMBER.DESCRIPTION, JSON.valueOf(writerDescription)) - .set(Member.MEMBER.IMG_URL, MemberDefaultImage.getRandom().url) + .set(Member.MEMBER.IMG_URL, MEMBER_DEFAULT_IMG_URL) .execute() } } diff --git a/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt b/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt index 47f7cd48e..211764c83 100644 --- a/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt +++ b/api-repo/src/test/kotlin/com/few/api/repo/explain/member/MemberDaoExplainGenerateTest.kt @@ -11,7 +11,7 @@ import com.few.api.repo.dao.member.support.WriterDescriptionJsonMapper import com.few.api.repo.explain.InsertUpdateExplainGenerator import com.few.api.repo.explain.ResultGenerator import com.few.api.repo.jooq.JooqTestSpec -import com.few.data.common.code.MemberDefaultImage +import com.few.data.common.code.MEMBER_DEFAULT_IMG_URL import com.few.data.common.code.MemberType import io.github.oshai.kotlinlogging.KotlinLogging import jooq.jooq_dsl.tables.Member @@ -116,7 +116,7 @@ class MemberDaoExplainGenerateTest : JooqTestSpec() { val command = InsertMemberCommand( email = "test100@gmail.com", memberType = MemberType.NORMAL, - imageUrl = MemberDefaultImage.getRandom().url + imageUrl = MEMBER_DEFAULT_IMG_URL ).let { memberDao.insertMemberCommand(it) } diff --git a/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt b/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt index 254efb327..f4c9e7de7 100644 --- a/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/member/usecase/SaveMemberUseCase.kt @@ -8,7 +8,7 @@ import com.few.api.repo.dao.member.MemberDao import com.few.api.repo.dao.member.command.InsertMemberCommand import com.few.api.repo.dao.member.command.UpdateDeletedMemberTypeCommand import com.few.api.repo.dao.member.query.SelectMemberByEmailNotConsiderDeletedAtQuery -import com.few.data.common.code.MemberDefaultImage +import com.few.data.common.code.MEMBER_DEFAULT_IMG_URL import com.few.data.common.code.MemberType import com.few.email.service.member.SendAuthEmailService import com.few.email.service.member.dto.Content @@ -38,7 +38,7 @@ class SaveMemberUseCase( InsertMemberCommand( email = useCaseIn.email, memberType = MemberType.PREAUTH, - MemberDefaultImage.getRandom().url + MEMBER_DEFAULT_IMG_URL ).let { memberDao.insertMember(it) ?: throw InsertException("member.insertfail.record") } diff --git a/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt b/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt index 2d0bf77fa..12d2a76e8 100644 --- a/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt +++ b/api/src/main/kotlin/com/few/api/domain/subscription/service/MemberService.kt @@ -7,7 +7,7 @@ import com.few.api.exception.common.InsertException import com.few.api.repo.dao.member.MemberDao import com.few.api.repo.dao.member.command.InsertMemberCommand import com.few.api.repo.dao.member.query.SelectMemberByEmailQuery -import com.few.data.common.code.MemberDefaultImage +import com.few.data.common.code.MEMBER_DEFAULT_IMG_URL import org.springframework.stereotype.Service @Service @@ -20,7 +20,7 @@ class MemberService( } fun insertMember(dto: InsertMemberInDto): MemberIdOutDto { - return memberDao.insertMember(InsertMemberCommand(dto.email, dto.memberType, MemberDefaultImage.getRandom().url)) + return memberDao.insertMember(InsertMemberCommand(dto.email, dto.memberType, MEMBER_DEFAULT_IMG_URL)) ?.let { MemberIdOutDto(it) } ?: throw InsertException("member.insertfail.record") } diff --git a/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt index 028ab8837..25fa88ab1 100644 --- a/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt @@ -9,7 +9,7 @@ import com.few.api.domain.article.service.dto.ReadWriterOutDto import com.few.api.domain.article.usecase.dto.ReadArticleUseCaseIn import com.few.api.repo.dao.article.ArticleDao import com.few.api.repo.dao.article.record.SelectArticleRecord -import com.few.data.common.code.MemberDefaultImage +import com.few.data.common.code.MEMBER_DEFAULT_IMG_URL import io.github.oshai.kotlinlogging.KotlinLogging import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.BehaviorSpec @@ -59,7 +59,7 @@ class ReadArticleUseCaseTest : BehaviorSpec({ writerId = 1L, name = "hunca", url = URL("https://jh-labs.tistory.com/"), - imgUrl = URL(MemberDefaultImage.getRandom().url) + imgUrl = URL(MEMBER_DEFAULT_IMG_URL) ) val probSvcOutDto = BrowseArticleProblemsOutDto(problemIds = listOf(1, 2, 3)) diff --git a/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt b/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt index 9c38dc990..4c3e328c0 100644 --- a/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt +++ b/api/src/test/kotlin/com/few/api/web/controller/article/ArticleControllerTest.kt @@ -12,7 +12,7 @@ import com.few.api.web.controller.ControllerTestSpec import com.few.api.web.controller.description.Description import com.few.api.web.controller.helper.* import com.few.data.common.code.CategoryType -import com.few.data.common.code.MemberDefaultImage +import com.few.data.common.code.MEMBER_DEFAULT_IMG_URL import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test @@ -80,7 +80,7 @@ class ArticleControllerTest : ControllerTestSpec() { id = 1L, name = "안나포", url = URL("http://localhost:8080/api/v1/writers/1"), - imgUrl = URL(MemberDefaultImage.getRandom().url) + imgUrl = URL(MEMBER_DEFAULT_IMG_URL) ), mainImageUrl = URL("https://github.com/YAPP-Github/24th-Web-Team-1-BE/assets/102807742/0643d805-5f3a-4563-8c48-2a7d51795326"), title = "ETF(상장 지수 펀드)란? 모르면 손해라고?", @@ -166,7 +166,7 @@ class ArticleControllerTest : ControllerTestSpec() { id = 1L, name = "안나포", url = URL("http://localhost:8080/api/v1/writers/1"), - imgUrl = URL(MemberDefaultImage.getRandom().url) + imgUrl = URL(MEMBER_DEFAULT_IMG_URL) ), mainImageUrl = URL("https://github.com/YAPP-Github/24th-Web-Team-1-BE/assets/102807742/0643d805-5f3a-4563-8c48-2a7d51795326"), title = "ETF(상장 지수 펀드)란? 모르면 손해라고?", diff --git a/data/src/main/kotlin/com/few/data/common/code/MemberDefaultImage.kt b/data/src/main/kotlin/com/few/data/common/code/WriterDefaultImage.kt similarity index 63% rename from data/src/main/kotlin/com/few/data/common/code/MemberDefaultImage.kt rename to data/src/main/kotlin/com/few/data/common/code/WriterDefaultImage.kt index 80ad892b6..9c357299e 100644 --- a/data/src/main/kotlin/com/few/data/common/code/MemberDefaultImage.kt +++ b/data/src/main/kotlin/com/few/data/common/code/WriterDefaultImage.kt @@ -1,6 +1,6 @@ package com.few.data.common.code -enum class MemberDefaultImage(val url: String) { +enum class WriterDefaultImage(val url: String) { // TODO: 작가 저장 시 사용 DEFAULT_IMG1("https://github.com/user-attachments/assets/28df9078-488c-49d6-9375-54ce5a250742"), DEFAULT_IMG2("https://github.com/user-attachments/assets/385dcafd-6737-41d7-aaa0-9db4ea6f27ea"), DEFAULT_IMG3("https://github.com/user-attachments/assets/209da8ff-7c78-41b7-8e3e-40a2705f714a"), @@ -8,8 +8,10 @@ enum class MemberDefaultImage(val url: String) { ; companion object { - fun getRandom(): MemberDefaultImage { + fun getRandom(): WriterDefaultImage { return entries.toTypedArray().random() } } -} \ No newline at end of file +} + +const val MEMBER_DEFAULT_IMG_URL = "https://github.com/user-attachments/assets/c33361bd-978e-41c0-85e8-7ab5c9005687" \ No newline at end of file