Skip to content

Commit

Permalink
Feat/actions ci (#11)
Browse files Browse the repository at this point in the history
* update deploy.yml

* modify ktlint options & apply ktlintFormat

* compatibility issue solved
  • Loading branch information
endermaru authored Dec 25, 2024
1 parent a9288d2 commit dabebca
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.{kt,kts}]
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_package-name = disabled
max_line_length = off
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

plugins {
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
Expand All @@ -6,7 +7,7 @@ plugins {
id("org.jlleitschuh.gradle.ktlint") version "12.1.2"
}

group = "com.ToyProject"
group = "com.waffletoy"
version = "0.0.1-SNAPSHOT"

java {
Expand All @@ -17,14 +18,14 @@ java {

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")

developmentOnly("org.springframework.boot:spring-boot-devtools")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
Expand All @@ -35,7 +36,8 @@ dependencies {
testImplementation("org.glassfish:jakarta.el:5.0.0-M1")

implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0")
implementation("com.mysql:mysql-connector-j:8.2.0")
}

kotlin {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
spring-app:
build:
context: . # 현재 디렉토리에서 Dockerfile을 사용하여 이미지 빌드
image: endermaru/22-5-team1-server:latest
container_name: spring-app-container
depends_on:
mysql:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
Expand All @@ -24,4 +23,4 @@ class EchoController(
val value = input ?: "no input"
return echoService.convertToUpperCase(value)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.waffletoy.team1server.pretotype
import com.waffletoy.team1server.DomainException
import org.springframework.http.HttpStatus

class PretotypeEmailConflictException: DomainException(0, HttpStatus.CONFLICT, "Email already exists")
class PretotypeEmailConflictException : DomainException(0, HttpStatus.CONFLICT, "Email already exists")
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.waffletoy.team1server.pretotype.controller
import com.waffletoy.team1server.pretotype.persistence.PretotypeEntity
import java.time.Instant

class Pretotype (
class Pretotype(
val email: String,
val isSubscribed: Boolean,
val createdAt: Instant,
Expand All @@ -13,8 +13,8 @@ class Pretotype (
return Pretotype(
email = entity.email,
isSubscribed = entity.isSubscribed,
createdAt = entity.createdAt
)
createdAt = entity.createdAt,
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController

@RestController
class TestResponseController (
class TestResponseController(
private val pretotypeService: PretotypeService,
){
) {
@PostMapping("/api/pretotype")
fun createPretotype(
@RequestBody request: PretotypeRequest
@RequestBody request: PretotypeRequest,
): ResponseEntity<Pretotype> {
val pretotype = pretotypeService.createPretotype(request.email, request.isSubscribed)
return ResponseEntity.ok(pretotype)
Expand All @@ -28,5 +28,5 @@ class TestResponseController (

data class PretotypeRequest(
val email: String,
val isSubscribed: Boolean
val isSubscribed: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class PretotypeEntity(
@Column(name = "is_subscribed")
var isSubscribed: Boolean = false,
@Column(name = "created_at")
var createdAt: Instant = Instant.now()
var createdAt: Instant = Instant.now(),
) {
// No-args constructor for Hibernate
constructor() : this(null, "", false, Instant.now())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.waffletoy.team1server.pretotype.persistence

import org.springframework.data.jpa.repository.JpaRepository

interface PretotypeRepository: JpaRepository<PretotypeEntity, String> {
interface PretotypeRepository : JpaRepository<PretotypeEntity, String> {
fun findByEmail(email: String): PretotypeEntity?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import org.springframework.stereotype.Service
import java.time.Instant

@Service
class PretotypeService (
private val pretotypeRepository: PretotypeRepository
){
class PretotypeService(
private val pretotypeRepository: PretotypeRepository,
) {
@Transactional
fun createPretotype(
email: String,
Expand All @@ -20,11 +20,12 @@ class PretotypeService (
pretotypeRepository.findByEmail(email) ?.let {
throw PretotypeEmailConflictException()
} ?: run {
val pretotypeEntity = PretotypeEntity(
email = email,
isSubscribed = isSubscribed,
createdAt = Instant.now()
)
val pretotypeEntity =
PretotypeEntity(
email = email,
isSubscribed = isSubscribed,
createdAt = Instant.now(),
)
pretotypeRepository.save(pretotypeEntity)
return Pretotype.fromEntity(pretotypeEntity)
}
Expand All @@ -35,4 +36,4 @@ class PretotypeService (
Pretotype.fromEntity(it)
}
}
}
}

0 comments on commit dabebca

Please sign in to comment.