Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@ import io.swagger.v3.oas.annotations.media.Schema
@Schema(description = "장소 생성 Request")
data class LocationCreateRequest(
val name: String,
val category: String,
val description: String?,
val telephone: String?,
val address: String?,
val roadAddress: String?,
val latitude: Double,
val longitude: Double,
) {
fun to(): Location {
return Location.create(
name,
category,
description,
telephone,
address,
roadAddress,
latitude,
longitude
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.retrip.map.application.`in`.request

import com.retrip.map.domain.entity.LocationDetail
import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "장소 상세 생성 Request")
data class LocationDetailCreateRequest(
val name: String,
val category: String,
val description: String?,
val telephone: String?,
val address: String?,
val roadAddress: String?,
val latitude: Double,
val longitude: Double,
) {
fun to(): LocationDetail {
return LocationDetail.create(
name,
category,
description,
telephone,
address,
roadAddress,
latitude,
longitude
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.retrip.map.application.`in`.request

import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "장소 상세 수정 Request")
data class LocationDetailUpdateRequest(
val name: String,
val category: String,
val description: String?,
val telephone: String?,
val address: String?,
val roadAddress: String?,
val latitude: Double,
val longitude: Double,
) {
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package com.retrip.map.application.`in`.request

import com.retrip.map.domain.entity.Location
import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "장소 수정 Request")
data class LocationUpdateRequest(
val name: String,
val category: String,
val description: String?,
val telephone: String?,
val address: String?,
val roadAddress: String?,
val latitude: Double,
val longitude: Double,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@ package com.retrip.map.application.`in`.response
import io.swagger.v3.oas.annotations.media.Schema
import java.util.UUID

@Schema(description = "장소 생성 응답")
data class LocationCreateResponse(
@Schema(description = "장소 id")
val id: UUID,
@Schema(description = "장소명")
val name: String,
@Schema(description = "장소 카테고리")
val category: String,
@Schema(description = "장소 설명")
val description: String?,
@Schema(description = "장소 전화번호")
val telephone: String?,
@Schema(description = "장소 주소")
val address: String?,
@Schema(description = "장소 도로명 주소")
val roadAddress: String?,
@Schema(description = "장소 위도")
val latitude: Double?,
@Schema(description = "장소 경도")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.retrip.map.application.`in`.response

import io.swagger.v3.oas.annotations.media.Schema
import java.util.UUID

@Schema(description = "장소 상세 생성 응답")
data class LocationDetailCreateResponse(
@Schema(description = "장소 상세 id")
val id: UUID,
@Schema(description = "장소 상세명")
val name: String,
@Schema(description = "장소 상세 카테고리")
val category: String,
@Schema(description = "장소 상세 설명")
val description: String?,
@Schema(description = "장소 상세 전화번호")
val telephone: String?,
@Schema(description = "장소 상세 주소")
val address: String?,
@Schema(description = "장소 상세 도로명 주소")
val roadAddress: String?,
@Schema(description = "장소 상세 위도")
val latitude: Double?,
@Schema(description = "장소 상세 경도")
val longitude: Double?,
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.retrip.map.application.`in`.response

import io.swagger.v3.oas.annotations.media.Schema
import java.util.UUID

@Schema(description = "장소 상세 조회 Response")
data class LocationDetailResponse(
@Schema(description = "장소 상세 id")
val id: UUID,
@Schema(description = "장소 상세명")
val name: String,
@Schema(description = "장소 상세 카테고리")
val category: String,
@Schema(description = "장소 상세 설명")
val description: String?,
@Schema(description = "장소 상세 전화번호")
val telephone: String?,
@Schema(description = "장소 상세 주소")
val address: String?,
@Schema(description = "장소 상세 도로명 주소")
val roadAddress: String?,
@Schema(description = "장소 상세 위도")
val latitude: Double?,
@Schema(description = "장소 상세 경도")
val longitude: Double?,
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.retrip.map.application.`in`.response

import io.swagger.v3.oas.annotations.media.Schema
import java.util.UUID

@Schema(description = "장소 상세 업데이트 Response")
data class LocationDetailUpdateResponse(
@Schema(description = "장소 상세 id")
val id: UUID,
@Schema(description = "장소 상세명")
val name: String,
@Schema(description = "장소 상세 카테고리")
val category: String,
@Schema(description = "장소 상세 설명")
val description: String?,
@Schema(description = "장소 상세 전화번호")
val telephone: String?,
@Schema(description = "장소 상세 주소")
val address: String?,
@Schema(description = "장소 상세 도로명 주소")
val roadAddress: String?,
@Schema(description = "장소 상세 위도")
val latitude: Double?,
@Schema(description = "장소 상세 경도")
val longitude: Double?,
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ data class LocationResponse(
val id: UUID,
@Schema(description = "장소명")
val name: String,
@Schema(description = "장소 카테고리")
val category: String,
@Schema(description = "장소 설명")
val description: String?,
@Schema(description = "장소 전화번호")
val telephone: String?,
@Schema(description = "장소 주소")
val address: String?,
@Schema(description = "장소 도로명 주소")
val roadAddress: String?,
@Schema(description = "장소 위도")
val latitude: Double?,
@Schema(description = "장소 경도")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.retrip.map.application.`in`.response

import io.swagger.v3.oas.annotations.media.Schema
import java.util.UUID

@Schema(description = "장소 빠른 조회 Response")
data class LocationSearchResponse(
@Schema(description = "장소 id")
val id: UUID,
@Schema(description = "장소명")
val name: String,
@Schema(description = "장소 위도")
val latitude: Double?,
@Schema(description = "장소 경도")
val longitude: Double?,
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@ package com.retrip.map.application.`in`.response
import io.swagger.v3.oas.annotations.media.Schema
import java.util.UUID

@Schema(description = "장소 업데이트 Response")
data class LocationUpdateResponse(
@Schema(description = "장소 id")
val id: UUID,
@Schema(description = "장소명")
val name: String,
@Schema(description = "장소 카테고리")
val category: String,
@Schema(description = "장소 설명")
val description: String?,
@Schema(description = "장소 전화번호")
val telephone: String?,
@Schema(description = "장소 주소")
val address: String?,
@Schema(description = "장소 도로명 주소")
val roadAddress: String?,
@Schema(description = "장소 위도")
val latitude: Double?,
@Schema(description = "장소 경도")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.retrip.map.application.`in`.service

import com.retrip.map.application.`in`.usecase.LocationIndexUseCase
import com.retrip.map.application.out.repository.LocationDetailElasticRepository
import com.retrip.map.infra.adapter.out.search.elasticsearch.entity.LocationDetailDocument
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
@Transactional
class LocationDetailIndexService(
private val locationDetailElasticRepository: LocationDetailElasticRepository
) : LocationIndexUseCase {
override fun indexLocationDetailDocuments(documents: List<LocationDetailDocument>?) {
documents?.let { locationDetailElasticRepository.saveAll(it) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.retrip.map.application.`in`.service

import co.elastic.clients.elasticsearch.core.search.ContextBuilders.location
import com.retrip.map.application.`in`.request.LocationDetailCreateRequest
import com.retrip.map.application.`in`.request.LocationDetailUpdateRequest
import com.retrip.map.application.`in`.response.LocationDetailCreateResponse
import com.retrip.map.application.`in`.response.LocationDetailResponse
import com.retrip.map.application.`in`.response.LocationDetailUpdateResponse
import com.retrip.map.application.`in`.usecase.LocationDetailUseCase
import com.retrip.map.application.out.repository.LocationDetailQueryRepository
import com.retrip.map.application.out.repository.LocationDetailRepository
import com.retrip.map.domain.exception.LocationDetailNotFoundException
import com.retrip.map.domain.exception.common.RequireException
import lombok.RequiredArgsConstructor
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.util.*

@Service
@RequiredArgsConstructor
@Transactional
class LocationDetailService(
val locationDetailRepository: LocationDetailRepository,
val locationDetailQueryRepository: LocationDetailQueryRepository
) : LocationDetailUseCase {

@Transactional(readOnly = true)
override fun getLocationDetail(id: UUID?, page: Pageable): Page<LocationDetailResponse> {
return locationDetailQueryRepository.findLocationDetails(id, page)
}

override fun createLocationDetail(request: LocationDetailCreateRequest): LocationDetailCreateResponse {
val locationDetail = locationDetailRepository.save(request.to())
return LocationDetailCreateResponse(
locationDetail.id ?: throw LocationDetailNotFoundException(),
locationDetail.name?.value ?: throw RequireException(),
locationDetail.category?.value ?: throw RequireException(),
locationDetail.description?.value,
locationDetail.telephone,
locationDetail.address?.address,
locationDetail.address?.roadAddress,
locationDetail.geoPoint?.latitude,
locationDetail.geoPoint?.longitude,
)
}

override fun updateLocationDetail(id: UUID, request: LocationDetailUpdateRequest): LocationDetailUpdateResponse {
val location = locationDetailRepository.findByIdOrNull(id) ?: throw LocationDetailNotFoundException()
location.update(
request.name,
request.category,
request.description,
request.telephone,
request.address,
request.roadAddress,
request.latitude,
request.longitude,
)
return LocationDetailUpdateResponse(
location.id ?: throw LocationDetailNotFoundException(),
location.name?.value ?: throw RequireException(),
location.category?.value ?: throw RequireException(),
location.description?.value,
location.telephone,
location.address?.address,
location.address?.roadAddress,
location.geoPoint?.latitude,
location.geoPoint?.longitude,
)
}

override fun deleteLocationDetail(locationDetailId: UUID) {
locationDetailRepository.deleteById(locationDetailId)
}
}

This file was deleted.

Loading