Skip to content

Commit

Permalink
Merge branch 'main' into feat/#97_belljun3395
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 authored Jul 1, 2024
2 parents 9cef3bb + 854f3ef commit eaf3797
Show file tree
Hide file tree
Showing 44 changed files with 451 additions and 496 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/batch-cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Batch Cron

on:
schedule:
# 매 오전 8시에 실행
- cron: '0 8 * * *'
workflow_dispatch:

jobs:
code-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
run: |
curl -X 'POST' \
'https://api.fewletter.site/batch/article' \
-H 'accept: application/json' \
-H 'Content-Type: application/json'
20 changes: 14 additions & 6 deletions .github/workflows/code-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:

env:
RELEASE_VERSION: ${{ github.sha }}
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}

jobs:
build:
Expand All @@ -25,19 +25,27 @@ jobs:

- name: Jooq Code Generation
run: |
./gradlew --info jooqCodegen
./gradlew --info jooqCodegenAll
- name: Test with Gradle
run: |
./gradlew --info test
- name: Build with Gradle
run: |
./gradlew --info api:build
./gradlew --info api:build -x test
- name: Test with Gradle
- name: Generate OpenAPI3
run: |
./gradlew --info test
./gradlew --info api:openapi3 -PserverUrl=https://api.fewletter.site
- name: Generate Swagger
run: |
./gradlew --info api:generateStaticSwaggerUIApi
- name : Docker Login
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker Image
run: |
./gradlew --info api:buildDockerImage
./gradlew --info api:buildDockerImage -PimageName=fewletter/api -PreleaseVersion=${{ env.RELEASE_VERSION }}
8 changes: 2 additions & 6 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
contents: read

env:
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}

jobs:
build:
Expand All @@ -24,11 +24,7 @@ jobs:

- name: Jooq Code Generation
run: |
./gradlew --info jooqCodegen
- name: Build with Gradle
run: |
./gradlew --info api:build
./gradlew --info jooqCodegenAll
- name: Test with Gradle
run: |
Expand Down
118 changes: 0 additions & 118 deletions api-repo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@ tasks.getByName("jar") {
enabled = true
}

plugins {
/** jooq */
id("org.jooq.jooq-codegen-gradle") version DependencyVersion.JOOQ
}

sourceSets {
main {
java {
val mainDir = "src/main/kotlin"
val jooqDir = "src/generated"
srcDirs(mainDir, jooqDir)
}
}
}

dependencies {
/** module */
api(project(":data"))
Expand All @@ -33,110 +18,7 @@ dependencies {
implementation("org.flywaydb:flyway-core:${DependencyVersion.FLYWAY}")
implementation("org.flywaydb:flyway-mysql")

/** jooq */
implementation("org.springframework.boot:spring-boot-starter-jooq")
implementation("org.jooq:jooq:${DependencyVersion.JOOQ}")
implementation("org.jooq:jooq-meta:${DependencyVersion.JOOQ}")
implementation("org.jooq:jooq-codegen:${DependencyVersion.JOOQ}")
jooqCodegen("org.jooq:jooq-meta-extensions:${DependencyVersion.JOOQ}")

/** test container */
implementation(platform("org.testcontainers:testcontainers-bom:${DependencyVersion.TEST_CONTAINER}"))
testImplementation("org.testcontainers:mysql")
}

/** copy data migration */
tasks.create("copyDataMigration") {
doLast {
val root = rootDir
val flyWayResourceDir = "/db/migration/entity"
val dataMigrationDir = "$root/data/$flyWayResourceDir"
File(dataMigrationDir).walkTopDown().forEach {
if (it.isFile) {
it.copyTo(
File("${project.projectDir}/src/main/resources$flyWayResourceDir/${it.name}"),
true
)
}
}
}
}

/** copy data migration before compile kotlin */
tasks.getByName("compileKotlin") {
dependsOn("copyDataMigration")
}

/** jooq codegen after copy data migration */
tasks.getByName("jooqCodegen") {
dependsOn("copyDataMigration")
}

jooq {
configuration {
generator {
database {
name = "org.jooq.meta.extensions.ddl.DDLDatabase"
properties {
// Specify the location of your SQL script.
// You may use ant-style file matching, e.g. /path/**/to/*.sql
//
// Where:
// - ** matches any directory subtree
// - * matches any number of characters in a directory / file name
// - ? matches a single character in a directory / file name
property {
key = "scripts"
value = "src/main/resources/db/migration/**/*.sql"
}

// The sort order of the scripts within a directory, where:
//
// - semantic: sorts versions, e.g. v-3.10.0 is after v-3.9.0 (default)
// - alphanumeric: sorts strings, e.g. v-3.10.0 is before v-3.9.0
// - flyway: sorts files the same way as flyway does
// - none: doesn't sort directory contents after fetching them from the directory
property {
key = "sort"
value = "flyway"
}

// The default schema for unqualified objects:
//
// - public: all unqualified objects are located in the PUBLIC (upper case) schema
// - none: all unqualified objects are located in the default schema (default)
//
// This configuration can be overridden with the schema mapping feature
property {
key = "unqualifiedSchema"
value = "none"
}

// The default name case for unquoted objects:
//
// - as_is: unquoted object names are kept unquoted
// - upper: unquoted object names are turned into upper case (most databases)
// - lower: unquoted object names are turned into lower case (e.g. PostgreSQL)
property {
key = "defaultNameCase"
value = "as_is"
}
}
}

generate {
isDeprecated = false
isRecords = true
isImmutablePojos = true
isFluentSetters = true
isJavaTimeTypes = true
}

target {
packageName = "jooq.jooq_dsl"
directory = "src/generated"
encoding = "UTF-8"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.springframework.stereotype.Repository
class ArticleDao(
private val dslContext: DSLContext
) {
fun selectArticleRecord(query: SelectArticleRecordQuery): SelectArticleRecord {
fun selectArticleRecord(query: SelectArticleRecordQuery): SelectArticleRecord? {
val articleId = query.articleId

return dslContext.select(
Expand All @@ -33,10 +33,9 @@ class ArticleDao(
.where(ArticleMst.ARTICLE_MST.ID.eq(articleId))
.and(ArticleMst.ARTICLE_MST.DELETED_AT.isNull)
.fetchOneInto(SelectArticleRecord::class.java)
?: throw IllegalArgumentException("cannot find article record by articleId: $articleId")
}

fun selectWorkBookArticleRecord(query: SelectWorkBookArticleRecordQuery): SelectWorkBookArticleRecord {
fun selectWorkBookArticleRecord(query: SelectWorkBookArticleRecordQuery): SelectWorkBookArticleRecord? {
val articleMst = ArticleMst.ARTICLE_MST
val articleIfo = ArticleIfo.ARTICLE_IFO
val mappingWorkbookArticle = MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE
Expand All @@ -62,7 +61,6 @@ class ArticleDao(
.where(articleMst.ID.eq(articleId))
.and(articleMst.DELETED_AT.isNull)
.fetchOneInto(SelectWorkBookArticleRecord::class.java)
?: throw IllegalArgumentException("cannot find $workbookId article record by articleId: $articleId")
}

fun selectWorkbookMappedArticleRecords(query: SelectWorkbookMappedArticleRecordsQuery): List<SelectWorkBookMappedArticleRecord> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.few.api.repo.dao.member.command.InsertMemberCommand
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.MemberRecord
import com.few.api.repo.dao.member.record.MemberIdRecord
import com.few.api.repo.dao.member.record.WriterRecord
import com.few.data.common.code.MemberType
import jooq.jooq_dsl.tables.Member
Expand Down Expand Up @@ -47,17 +47,16 @@ class MemberDao(
.fetchInto(WriterRecord::class.java)
}

fun selectMemberByEmail(query: SelectMemberByEmailQuery): MemberRecord {
fun selectMemberByEmail(query: SelectMemberByEmailQuery): MemberIdRecord? {
val email = query.email

return dslContext.select(
Member.MEMBER.ID.`as`(MemberRecord::memberId.name)
Member.MEMBER.ID.`as`(MemberIdRecord::memberId.name)
)
.from(Member.MEMBER)
.where(Member.MEMBER.EMAIL.eq(email))
.and(Member.MEMBER.DELETED_AT.isNull)
.fetchOneInto(MemberRecord::class.java)
?: throw IllegalArgumentException("cannot find member record by email: $email")
.fetchOneInto(MemberIdRecord::class.java)
}

fun insertMember(command: InsertMemberCommand): Long {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.api.repo.dao.member.record

data class MemberRecord(
data class MemberIdRecord(
val memberId: Long
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component
class ProblemDao(
private val dslContext: DSLContext
) {
fun selectProblemContents(query: SelectProblemQuery): SelectProblemRecord {
fun selectProblemContents(query: SelectProblemQuery): SelectProblemRecord? {
return dslContext.select(
Problem.PROBLEM.ID.`as`(SelectProblemRecord::id.name),
Problem.PROBLEM.TITLE.`as`(SelectProblemRecord::title.name),
Expand All @@ -26,10 +26,9 @@ class ProblemDao(
.where(Problem.PROBLEM.ID.eq(query.problemId))
.and(Problem.PROBLEM.DELETED_AT.isNull)
.fetchOneInto(SelectProblemRecord::class.java)
?: throw RuntimeException("Problem with ID ${query.problemId} not found") // TODO: 에러 표준화
}

fun selectProblemAnswer(query: SelectProblemAnswerQuery): SelectProblemAnswerRecord {
fun selectProblemAnswer(query: SelectProblemAnswerQuery): SelectProblemAnswerRecord? {
return dslContext.select(
Problem.PROBLEM.ID.`as`(SelectProblemAnswerRecord::id.name),
Problem.PROBLEM.ANSWER.`as`(SelectProblemAnswerRecord::answer.name),
Expand All @@ -39,10 +38,9 @@ class ProblemDao(
.where(Problem.PROBLEM.ID.eq(query.problemId))
.and(Problem.PROBLEM.DELETED_AT.isNull)
.fetchOneInto(SelectProblemAnswerRecord::class.java)
?: throw RuntimeException("Problem Answer with ID ${query.problemId} not found") // TODO: 에러 표준화
}

fun selectProblemsByArticleId(query: SelectProblemsByArticleIdQuery): ProblemIdsRecord {
fun selectProblemsByArticleId(query: SelectProblemsByArticleIdQuery): ProblemIdsRecord? {
val articleId = query.articleId

return dslContext.select()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ContentsJsonMapper(
val contents = objectMapper.readTree(value).get("contents")
val contentList = mutableListOf<Content>()
contents.forEach {
contentList.add(Content(it.get("id").asLong(), it.get("content").asText()))
contentList.add(Content(it.get("number").asLong(), it.get("content").asText()))
}
return Contents(contentList)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository
class WorkbookDao(
private val dslContext: DSLContext
) {
fun selectWorkBook(query: SelectWorkBookRecordQuery): SelectWorkBookRecord {
fun selectWorkBook(query: SelectWorkBookRecordQuery): SelectWorkBookRecord? {
return dslContext.select(
Workbook.WORKBOOK.ID.`as`(SelectWorkBookRecord::id.name),
Workbook.WORKBOOK.TITLE.`as`(SelectWorkBookRecord::title.name),
Expand All @@ -23,6 +23,5 @@ class WorkbookDao(
.where(Workbook.WORKBOOK.ID.eq(query.id))
.and(Workbook.WORKBOOK.DELETED_AT.isNull)
.fetchOneInto(SelectWorkBookRecord::class.java)
?: throw RuntimeException("WorkBook with ID ${query.id} not found")
}
}
Loading

0 comments on commit eaf3797

Please sign in to comment.