Skip to content

Commit

Permalink
Merge pull request #14 from belljun3395/fix/temp
Browse files Browse the repository at this point in the history
Fix/temp
  • Loading branch information
belljun3395 authored Jun 25, 2024
2 parents 6633100 + 75d7d1c commit 7983a03
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:

- name: Build Docker Image
run: |
./gradlew --info api:buildDockerImage
./gradlew --info api:buildDockerImage -PreleaseVersion=${{ env.RELEASE_VERSION }} -PserverUrl=https://api.fewletter.site

This file was deleted.

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.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class ContentsJsonMapperTest {
{
"contents": [
{
"id": 1,
"number": 1,
"content": "this is number one"
},
{
"id": 2,
"number": 2,
"content": "this is number two"
}
]
Expand Down

This file was deleted.

130 changes: 127 additions & 3 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import org.hidetake.gradle.swagger.generator.GenerateSwaggerUI

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

dependencies {
/** module */
implementation(project(":api-repo"))
Expand All @@ -10,10 +20,17 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")

/** swagger & restdocs */
implementation("org.springdoc:springdoc-openapi-ui:${DependencyVersion.SPRINGDOC}")
implementation("org.springdoc:springdoc-openapi-starter-webflux-ui:${DependencyVersion.SPRINGDOC}")
implementation("org.springframework.restdocs:spring-restdocs-webtestclient")
implementation("com.epages:restdocs-api-spec-mockmvc:${DependencyVersion.EPAGES_REST_DOCS_API_SPEC}")

/** 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")
Expand All @@ -23,11 +40,118 @@ plugins {
id("org.asciidoctor.jvm.convert") version DependencyVersion.ASCIIDOCTOR
id("com.epages.restdocs-api-spec") version DependencyVersion.EPAGES_REST_DOCS_API_SPEC
id("org.hidetake.swagger.generator") version DependencyVersion.SWAGGER_GENERATOR

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

/** 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"
}
}
}
}

val serverUrl = project.hasProperty("serverUrl").let {
if (it) {
project.property("serverUrl") as String
} else {
"http://localhost:8080"
}
}

/** convert snippet to swagger */
openapi3 {
this.setServer("http://localhost:8080") // todo refactor to use setServers
this.setServer(serverUrl)
title = project.name
version = project.version.toString()
format = "yaml"
Expand All @@ -40,7 +164,7 @@ openapi3 {
postman {
title = project.name
version = project.version.toString()
baseUrl = "http://localhost:8080"
baseUrl = serverUrl
outputDirectory = "src/main/resources/static/"
outputFileNamePrefix = "postman"
}
Expand Down
2 changes: 0 additions & 2 deletions api/src/main/kotlin/com/few/api/config/ApiConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import com.few.batch.config.BatchConfig
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import
import org.springframework.web.servlet.config.annotation.EnableWebMvc

@Configuration
@ComponentScan(basePackages = [ApiConfig.BASE_PACKAGE])
@Import(ApiRepoConfig::class, BatchConfig::class)
@EnableWebMvc
class ApiConfig {
companion object {
const val BASE_PACKAGE = "com.few.api"
Expand Down
Loading

0 comments on commit 7983a03

Please sign in to comment.