Skip to content

Commit

Permalink
feat: 일정에 장소 이름 추가 (#114)
Browse files Browse the repository at this point in the history
* feat: 세션 장소에 이름 추가

* feat: api에 세션 장소 필드 추가

* feat: DB 마이그레이션 스크립트 추가
  • Loading branch information
CChuYong authored Jul 5, 2024
1 parent a670d5d commit 3f1f49b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/kotlin/com/depromeet/makers/domain/model/Place.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@ package com.depromeet.makers.domain.model

data class Place(
val address: String,
val name: String?,
val longitude: Double,
val latitude: Double,
) {
fun update(
address: String,
longitude: Double,
latitude: Double,
name: String?,
) = copy(
address = address,
longitude = longitude,
latitude = latitude,
name = name,
)

companion object {
fun newPlace(
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,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CreateNewSession(
val address: String?,
val longitude: Double?,
val latitude: Double?,
val placeName: String?,
)

override fun execute(input: CreateNewSessionInput): Session {
Expand Down Expand Up @@ -55,6 +56,7 @@ class CreateNewSession(
address = input.address,
longitude = input.longitude,
latitude = input.latitude,
name = input.placeName,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class UpdateSessionPlace(
val address: String,
val latitude: Double,
val longitude: Double,
val name: String?,
)

override fun execute(input: UpdateSessionInput): Session {
Expand All @@ -19,6 +20,7 @@ class UpdateSessionPlace(
address = input.address,
latitude = input.latitude,
longitude = input.longitude,
name = input.name,
)

return sessionGateway.save(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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),
)
}

Expand All @@ -68,6 +71,7 @@ class SessionEntity private constructor(
address = place.address,
longitude = place.longitude,
latitude = place.latitude,
placeName = place.name,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SessionController(
address = request.address,
longitude = request.longitude,
latitude = request.latitude,
placeName = request.placeName,
)
)
return CreateNewSessionResponse.fromDomain(session)
Expand Down Expand Up @@ -110,6 +111,7 @@ class SessionController(
address = request.address,
latitude = request.latitude,
longitude = request.longitude,
name = request.placeName,
)
)
return UpdateSessionPlaceResponse.fromDomain(updatedSession)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ data class CreateNewSessionRequest(

@Schema(description = "위도", example = "126.9544")
val latitude: Double?,

@Schema(description = "세션 장소 이름", example = "모두의연구소 강남")
val placeName: String?,
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ data class UpdateSessionPlaceRequest(

@Schema(description = "위도", example = "126.9544")
val latitude: Double,

@Schema(description = "세션 장소 이름", example = "모두의연구소 강남")
val placeName: String?,
)
1 change: 1 addition & 0 deletions src/main/resources/db/migration/V3__add_place_name.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE session ADD COLUMN `place_name` VARCHAR(255) DEFAULT NULL;

0 comments on commit 3f1f49b

Please sign in to comment.