From 3f1f49bf5dd4ed19cb5629dd124b59a03e3fc641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=EC=98=81=EB=AF=BC=20=28YeongMin=20Song=29?= Date: Fri, 5 Jul 2024 10:56:46 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=BC=EC=A0=95=EC=97=90=20=EC=9E=A5?= =?UTF-8?q?=EC=86=8C=20=EC=9D=B4=EB=A6=84=20=EC=B6=94=EA=B0=80=20(#114)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 세션 장소에 이름 추가 * feat: api에 세션 장소 필드 추가 * feat: DB 마이그레이션 스크립트 추가 --- src/main/kotlin/com/depromeet/makers/domain/model/Place.kt | 6 ++++++ .../com/depromeet/makers/domain/usecase/CreateNewSession.kt | 2 ++ .../depromeet/makers/domain/usecase/UpdateSessionPlace.kt | 2 ++ .../makers/infrastructure/db/entity/SessionEntity.kt | 6 +++++- .../presentation/restapi/controller/SessionController.kt | 2 ++ .../restapi/dto/request/CreateNewSessionRequest.kt | 3 +++ .../restapi/dto/request/UpdateSessionPlaceRequest.kt | 3 +++ src/main/resources/db/migration/V3__add_place_name.sql | 1 + 8 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/migration/V3__add_place_name.sql diff --git a/src/main/kotlin/com/depromeet/makers/domain/model/Place.kt b/src/main/kotlin/com/depromeet/makers/domain/model/Place.kt index f7e8dd3..bf45eb8 100644 --- a/src/main/kotlin/com/depromeet/makers/domain/model/Place.kt +++ b/src/main/kotlin/com/depromeet/makers/domain/model/Place.kt @@ -2,6 +2,7 @@ package com.depromeet.makers.domain.model data class Place( val address: String, + val name: String?, val longitude: Double, val latitude: Double, ) { @@ -9,10 +10,12 @@ data class Place( address: String, longitude: Double, latitude: Double, + name: String?, ) = copy( address = address, longitude = longitude, latitude = latitude, + name = name, ) companion object { @@ -20,16 +23,19 @@ data class Place( address: String, longitude: Double, latitude: Double, + name: String?, ) = Place( address = address, longitude = longitude, latitude = latitude, + name = name, ) fun emptyPlace() = Place( address = "온라인", longitude = 0.0, latitude = 0.0, + name = null, ) } } diff --git a/src/main/kotlin/com/depromeet/makers/domain/usecase/CreateNewSession.kt b/src/main/kotlin/com/depromeet/makers/domain/usecase/CreateNewSession.kt index c8a0576..242e00a 100644 --- a/src/main/kotlin/com/depromeet/makers/domain/usecase/CreateNewSession.kt +++ b/src/main/kotlin/com/depromeet/makers/domain/usecase/CreateNewSession.kt @@ -21,6 +21,7 @@ class CreateNewSession( val address: String?, val longitude: Double?, val latitude: Double?, + val placeName: String?, ) override fun execute(input: CreateNewSessionInput): Session { @@ -55,6 +56,7 @@ class CreateNewSession( address = input.address, longitude = input.longitude, latitude = input.latitude, + name = input.placeName, ) } } diff --git a/src/main/kotlin/com/depromeet/makers/domain/usecase/UpdateSessionPlace.kt b/src/main/kotlin/com/depromeet/makers/domain/usecase/UpdateSessionPlace.kt index 921eb54..067deb8 100644 --- a/src/main/kotlin/com/depromeet/makers/domain/usecase/UpdateSessionPlace.kt +++ b/src/main/kotlin/com/depromeet/makers/domain/usecase/UpdateSessionPlace.kt @@ -11,6 +11,7 @@ class UpdateSessionPlace( val address: String, val latitude: Double, val longitude: Double, + val name: String?, ) override fun execute(input: UpdateSessionInput): Session { @@ -19,6 +20,7 @@ class UpdateSessionPlace( address = input.address, latitude = input.latitude, longitude = input.longitude, + name = input.name, ) return sessionGateway.save( diff --git a/src/main/kotlin/com/depromeet/makers/infrastructure/db/entity/SessionEntity.kt b/src/main/kotlin/com/depromeet/makers/infrastructure/db/entity/SessionEntity.kt index b3a6796..ade561b 100644 --- a/src/main/kotlin/com/depromeet/makers/infrastructure/db/entity/SessionEntity.kt +++ b/src/main/kotlin/com/depromeet/makers/infrastructure/db/entity/SessionEntity.kt @@ -40,6 +40,9 @@ class SessionEntity private constructor( @Column(name = "latitude") var latitude: Double, + @Column(name = "place_name", nullable = true, columnDefinition = "VARCHAR(255)") + var placeName: String?, + ) { fun toDomain(): Session { return Session( @@ -50,7 +53,7 @@ class SessionEntity private constructor( description = description, startTime = startTime, sessionType = sessionType, - place = Place.newPlace(address, longitude, latitude), + place = Place.newPlace(address, longitude, latitude, placeName), ) } @@ -68,6 +71,7 @@ class SessionEntity private constructor( address = place.address, longitude = place.longitude, latitude = place.latitude, + placeName = place.name, ) } } diff --git a/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt b/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt index 450c56a..3b20965 100644 --- a/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt +++ b/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt @@ -42,6 +42,7 @@ class SessionController( address = request.address, longitude = request.longitude, latitude = request.latitude, + placeName = request.placeName, ) ) return CreateNewSessionResponse.fromDomain(session) @@ -110,6 +111,7 @@ class SessionController( address = request.address, latitude = request.latitude, longitude = request.longitude, + name = request.placeName, ) ) return UpdateSessionPlaceResponse.fromDomain(updatedSession) diff --git a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/CreateNewSessionRequest.kt b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/CreateNewSessionRequest.kt index f6e03cf..763c091 100644 --- a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/CreateNewSessionRequest.kt +++ b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/CreateNewSessionRequest.kt @@ -41,5 +41,8 @@ data class CreateNewSessionRequest( @Schema(description = "위도", example = "126.9544") val latitude: Double?, + + @Schema(description = "세션 장소 이름", example = "모두의연구소 강남") + val placeName: String?, ) { } diff --git a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/UpdateSessionPlaceRequest.kt b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/UpdateSessionPlaceRequest.kt index 1f67edc..a2c980c 100644 --- a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/UpdateSessionPlaceRequest.kt +++ b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/UpdateSessionPlaceRequest.kt @@ -13,4 +13,7 @@ data class UpdateSessionPlaceRequest( @Schema(description = "위도", example = "126.9544") val latitude: Double, + + @Schema(description = "세션 장소 이름", example = "모두의연구소 강남") + val placeName: String?, ) diff --git a/src/main/resources/db/migration/V3__add_place_name.sql b/src/main/resources/db/migration/V3__add_place_name.sql new file mode 100644 index 0000000..4a26208 --- /dev/null +++ b/src/main/resources/db/migration/V3__add_place_name.sql @@ -0,0 +1 @@ +ALTER TABLE session ADD COLUMN `place_name` VARCHAR(255) DEFAULT NULL;