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
@@ -0,0 +1,20 @@
package gomushin.backend.couple.dto.response

import gomushin.backend.couple.domain.entity.Anniversary
import java.time.LocalDate

data class AnniversaryDetailResponse(
val id: Long,
val title: String,
val anniversaryDate: LocalDate,
) {
companion object {
fun of(anniversary: Anniversary): AnniversaryDetailResponse {
return AnniversaryDetailResponse(
id = anniversary.id,
title = anniversary.title,
anniversaryDate = anniversary.anniversaryDate,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package gomushin.backend.couple.facade

import gomushin.backend.core.CustomUserDetails
import gomushin.backend.core.common.web.PageResponse
import gomushin.backend.core.infrastructure.exception.BadRequestException
import gomushin.backend.couple.domain.service.AnniversaryService
import gomushin.backend.couple.dto.response.AnniversaryDetailResponse
import gomushin.backend.couple.dto.response.MainAnniversaryResponse
import gomushin.backend.couple.dto.response.TotalAnniversaryResponse
import org.springframework.data.domain.PageRequest
Expand Down Expand Up @@ -32,7 +34,17 @@ class AnniversaryFacade(
return PageResponse.from(anniversaryResponses)
}

fun get(customUserDetails: CustomUserDetails, anniversaryId: Long): AnniversaryDetailResponse {
val anniversary = anniversaryService.getById(anniversaryId)
if (anniversary.coupleId != customUserDetails.getCouple().id) {
throw BadRequestException("sarangggun.anniversary.unauthorized")
}
return AnniversaryDetailResponse.of(anniversary)
}

fun delete(customUserDetails: CustomUserDetails, anniversaryId: Long) {
anniversaryService.delete(customUserDetails.getCouple(), anniversaryId)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import gomushin.backend.core.CustomUserDetails
import gomushin.backend.core.common.web.PageResponse
import gomushin.backend.core.common.web.response.ApiResponse
import gomushin.backend.couple.dto.request.GenerateAnniversaryRequest
import gomushin.backend.couple.dto.response.AnniversaryDetailResponse
import gomushin.backend.couple.dto.response.MainAnniversaryResponse
import gomushin.backend.couple.dto.response.TotalAnniversaryResponse
import gomushin.backend.couple.facade.AnniversaryFacade
Expand All @@ -15,7 +16,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.*

@RestController
@Tag(name = "기념일 생성", description = "AnniversaryController")
@Tag(name = "기념일", description = "AnniversaryController")
class AnniversaryController(
private val coupleFacade: CoupleFacade,
private val anniversaryFacade: AnniversaryFacade
Expand Down Expand Up @@ -74,4 +75,20 @@ class AnniversaryController(
val anniversaries = anniversaryFacade.getAnniversaryList(customUserDetails, safePage, size)
return anniversaries
}

@ResponseStatus(HttpStatus.OK)
@GetMapping(ApiPath.ANNIVERSARY)
@Operation(
summary = "기념일 상세 조회",
description = "getAnniversary"
)
fun getAnniversary(
@AuthenticationPrincipal customUserDetails: CustomUserDetails,
@PathVariable anniversaryId: Long
): ApiResponse<AnniversaryDetailResponse> {
val anniversary = anniversaryFacade.get(customUserDetails, anniversaryId)
return ApiResponse.success(anniversary)
}


}