-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge from main (resolve conflict)
- Loading branch information
Showing
45 changed files
with
1,091 additions
and
48 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.few.api.repo.dao.article | ||
|
||
import com.few.api.repo.dao.article.query.SelectArticleRecordQuery | ||
import com.few.api.repo.dao.article.query.SelectWorkBookArticleRecordQuery | ||
import com.few.api.repo.dao.article.record.SelectArticleRecord | ||
import com.few.api.repo.dao.article.record.SelectWorkBookArticleRecord | ||
import jooq.jooq_dsl.tables.ArticleIfo | ||
import jooq.jooq_dsl.tables.ArticleMst | ||
import jooq.jooq_dsl.tables.MappingWorkbookArticle | ||
import org.jooq.DSLContext | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
class ArticleDao( | ||
private val dslContext: DSLContext | ||
) { | ||
fun selectArticleRecord(query: SelectArticleRecordQuery): SelectArticleRecord { | ||
val articleId = query.articleId | ||
|
||
return dslContext.select( | ||
ArticleMst.ARTICLE_MST.ID.`as`(SelectArticleRecord::articleId.name), | ||
ArticleMst.ARTICLE_MST.MEMBER_ID.`as`(SelectArticleRecord::writerId.name), | ||
ArticleMst.ARTICLE_MST.MAIN_IMAGE_URL.`as`(SelectArticleRecord::mainImageURL.name), | ||
ArticleMst.ARTICLE_MST.TITLE.`as`(SelectArticleRecord::title.name), | ||
ArticleMst.ARTICLE_MST.CATEGORY_CD.`as`(SelectArticleRecord::category.name), | ||
ArticleIfo.ARTICLE_IFO.CONTENT.`as`(SelectArticleRecord::content.name), | ||
ArticleMst.ARTICLE_MST.CREATED_AT.`as`(SelectArticleRecord::createdAt.name) | ||
).from(ArticleMst.ARTICLE_MST) | ||
.join(ArticleIfo.ARTICLE_IFO) | ||
.on(ArticleMst.ARTICLE_MST.ID.eq(ArticleIfo.ARTICLE_IFO.ARTICLE_MST_ID)) | ||
.where(ArticleMst.ARTICLE_MST.ID.eq(articleId)) | ||
.fetchOneInto(SelectArticleRecord::class.java) | ||
?: throw IllegalArgumentException("cannot find article record by articleId: $articleId") | ||
} | ||
|
||
fun selectWorkBookArticleRecord(query: SelectWorkBookArticleRecordQuery): SelectWorkBookArticleRecord { | ||
val articleMst = ArticleMst.ARTICLE_MST | ||
val articleIfo = ArticleIfo.ARTICLE_IFO | ||
val mappingWorkbookArticle = MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE | ||
|
||
val articleId = query.articleId | ||
val workbookId = query.workbookId | ||
|
||
return dslContext.select( | ||
articleMst.ID.`as`(SelectWorkBookArticleRecord::articleId.name), | ||
articleMst.MEMBER_ID.`as`(SelectWorkBookArticleRecord::writerId.name), | ||
articleMst.MAIN_IMAGE_URL.`as`(SelectWorkBookArticleRecord::mainImageURL.name), | ||
articleMst.TITLE.`as`(SelectWorkBookArticleRecord::title.name), | ||
articleMst.CATEGORY_CD.`as`(SelectWorkBookArticleRecord::category.name), | ||
articleIfo.CONTENT.`as`(SelectWorkBookArticleRecord::content.name), | ||
articleMst.CREATED_AT.`as`(SelectWorkBookArticleRecord::createdAt.name), | ||
mappingWorkbookArticle.DAY_COL.`as`(SelectWorkBookArticleRecord::day.name) | ||
).from(articleMst) | ||
.join(articleIfo) | ||
.on(articleMst.ID.eq(articleIfo.ARTICLE_MST_ID)) | ||
.join(mappingWorkbookArticle) | ||
.on(mappingWorkbookArticle.WORKBOOK_ID.eq(workbookId)) | ||
.and(mappingWorkbookArticle.ARTICLE_ID.eq(articleMst.ID)) | ||
.where(articleMst.ID.eq(articleId)) | ||
.fetchOneInto(SelectWorkBookArticleRecord::class.java) | ||
?: throw IllegalArgumentException("cannot find $workbookId article record by articleId: $articleId") | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
api-repo/src/main/kotlin/com/few/api/repo/dao/article/query/SelectArticleRecordQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.few.api.repo.dao.article.query | ||
|
||
data class SelectArticleRecordQuery( | ||
val articleId: Long | ||
) |
6 changes: 6 additions & 0 deletions
6
...po/src/main/kotlin/com/few/api/repo/dao/article/query/SelectWorkBookArticleRecordQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.few.api.repo.dao.article.query | ||
|
||
data class SelectWorkBookArticleRecordQuery( | ||
val workbookId: Long, | ||
val articleId: Long | ||
) |
13 changes: 13 additions & 0 deletions
13
api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/SelectArticleRecord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.few.api.repo.dao.article.record | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class SelectArticleRecord( | ||
val articleId: Long, | ||
val writerId: Long, | ||
val mainImageURL: String, | ||
val title: String, | ||
val category: Byte, | ||
val content: String, | ||
val createdAt: LocalDateTime | ||
) |
14 changes: 14 additions & 0 deletions
14
api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/SelectWorkBookArticleRecord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.few.api.repo.dao.article.record | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class SelectWorkBookArticleRecord( | ||
val articleId: Long, | ||
val writerId: Long, | ||
val mainImageURL: String, | ||
val title: String, | ||
val category: Byte, | ||
val content: String, | ||
val createdAt: LocalDateTime, | ||
val day: Long | ||
) |
29 changes: 29 additions & 0 deletions
29
api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.few.api.repo.dao.member | ||
|
||
import com.few.api.repo.dao.member.query.SelectWriterQuery | ||
import com.few.api.repo.dao.member.record.WriterRecord | ||
import jooq.jooq_dsl.tables.Member | ||
import org.jooq.DSLContext | ||
import org.jooq.impl.DSL | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
class MemberDao( | ||
private val dslContext: DSLContext | ||
) { | ||
|
||
fun selectWriter(query: SelectWriterQuery): WriterRecord { | ||
val writerId = query.writerId | ||
|
||
return 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) | ||
) | ||
.from(Member.MEMBER) | ||
.where(Member.MEMBER.ID.eq(writerId)) | ||
.and(Member.MEMBER.TYPE_CD.eq(1)) // todo fix after considering the type_cd | ||
.fetchOneInto(WriterRecord::class.java) | ||
?: throw IllegalArgumentException("cannot find writer record by writerId: $writerId") | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
api-repo/src/main/kotlin/com/few/api/repo/dao/member/query/SelectWriterQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.few.api.repo.dao.member.query | ||
|
||
data class SelectWriterQuery( | ||
val writerId: Long | ||
) |
9 changes: 9 additions & 0 deletions
9
api-repo/src/main/kotlin/com/few/api/repo/dao/member/record/WriterRecord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.few.api.repo.dao.member.record | ||
|
||
import java.net.URL | ||
|
||
data class WriterRecord( | ||
val writerId: Long, | ||
val name: String, | ||
val url: URL | ||
) |
8 changes: 8 additions & 0 deletions
8
api-repo/src/main/kotlin/com/few/api/repo/dao/member/support/WriterDescription.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.few.api.repo.dao.member.support | ||
|
||
import java.net.URL | ||
|
||
data class WriterDescription( | ||
val name: String, | ||
val url: URL | ||
) |
22 changes: 22 additions & 0 deletions
22
api-repo/src/main/kotlin/com/few/api/repo/dao/member/support/WriterDescriptionJsonMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.few.api.repo.dao.member.support | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.registerKotlinModule | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class WriterDescriptionJsonMapper( | ||
private val objectMapper: ObjectMapper | ||
) { | ||
init { | ||
objectMapper.registerKotlinModule() | ||
} | ||
|
||
fun toJson(writerDescription: WriterDescription): String { | ||
return objectMapper.writeValueAsString(writerDescription) | ||
} | ||
|
||
fun toObject(value: String): WriterDescription { | ||
return objectMapper.readValue(value, WriterDescription::class.java) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
api-repo/src/main/kotlin/com/few/api/repo/dao/member/support/WriterDescriptionMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.few.api.repo.dao.member.support | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.registerKotlinModule | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class WriterDescriptionMapper( | ||
private val objectMapper: ObjectMapper | ||
) { | ||
init { | ||
objectMapper.registerKotlinModule() | ||
} | ||
|
||
fun toJson(writerDescription: WriterDescription): String { | ||
return objectMapper.writeValueAsString(writerDescription) | ||
} | ||
|
||
fun toObject(value: String): WriterDescription { | ||
return objectMapper.readValue(value, WriterDescription::class.java) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...repo/src/main/kotlin/com/few/api/repo/dao/problem/query/SelectProblemsByArticleIdQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.few.api.repo.dao.problem.query | ||
|
||
data class SelectProblemsByArticleIdQuery( | ||
val articleId: Long | ||
) |
5 changes: 5 additions & 0 deletions
5
api-repo/src/main/kotlin/com/few/api/repo/dao/problem/record/ProblemIdsRecord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.few.api.repo.dao.problem.record | ||
|
||
data class ProblemIdsRecord( | ||
val problemIds: List<Long> | ||
) |
10 changes: 10 additions & 0 deletions
10
api-repo/src/main/kotlin/com/few/api/repo/dao/problem/support/Contents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.few.api.repo.dao.problem.support | ||
|
||
data class Contents( | ||
val contents: List<Content> | ||
) | ||
|
||
data class Content( | ||
val number: Long, | ||
val content: String | ||
) |
23 changes: 23 additions & 0 deletions
23
api-repo/src/main/kotlin/com/few/api/repo/dao/problem/support/ContentsJsonMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.few.api.repo.dao.problem.support | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class ContentsJsonMapper( | ||
private val objectMapper: ObjectMapper | ||
) { | ||
|
||
fun toJson(contents: Contents): String { | ||
return objectMapper.writeValueAsString(contents) | ||
} | ||
|
||
fun toObject(value: String): Contents { | ||
val contents = objectMapper.readTree(value).get("contents") | ||
val contentList = mutableListOf<Content>() | ||
contents.forEach { | ||
contentList.add(Content(it.get("id").asLong(), it.get("content").asText())) | ||
} | ||
return Contents(contentList) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
api-repo/src/main/kotlin/com/few/api/repo/dao/problem/support/ContentsMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.few.api.repo.dao.problem.support | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class ContentsMapper( | ||
private val objectMapper: ObjectMapper | ||
) { | ||
|
||
fun toJson(contents: Contents): String { | ||
return objectMapper.writeValueAsString(contents) | ||
} | ||
|
||
fun toObject(value: String): Contents { | ||
val contents = objectMapper.readTree(value).get("contents") | ||
val contentList = mutableListOf<Content>() | ||
contents.forEach { | ||
contentList.add(Content(it.get("id").asLong(), it.get("content").asText())) | ||
} | ||
return Contents(contentList) | ||
} | ||
} |
Oops, something went wrong.