diff --git a/src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/ScreenController.kt b/src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/ScreenController.kt index 06f80fe..71a846b 100644 --- a/src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/ScreenController.kt +++ b/src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/ScreenController.kt @@ -1,8 +1,11 @@ package hs.kr.equus.feed.domain.screen.presentation +import hs.kr.equus.feed.domain.screen.presentation.dto.response.QueryScreenResponse import hs.kr.equus.feed.domain.screen.presentation.dto.response.ScreenResponse import hs.kr.equus.feed.domain.screen.service.CreateScreenService +import hs.kr.equus.feed.domain.screen.service.QueryScreenService import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestPart @@ -13,7 +16,8 @@ import org.springframework.web.multipart.MultipartFile @RestController @RequestMapping("/screen") class ScreenController( - private val createScreenService: CreateScreenService + private val createScreenService: CreateScreenService, + private val queryScreenService: QueryScreenService ) { @ResponseStatus(value = HttpStatus.CREATED) @@ -22,4 +26,8 @@ class ScreenController( @RequestPart(name = "image") image: MultipartFile ): ScreenResponse = createScreenService.execute(image) + + @GetMapping + fun queryScreen(): List = + queryScreenService.execute() } diff --git a/src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/dto/response/QueryScreenResponse.kt b/src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/dto/response/QueryScreenResponse.kt new file mode 100644 index 0000000..4181ef4 --- /dev/null +++ b/src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/dto/response/QueryScreenResponse.kt @@ -0,0 +1,11 @@ +package hs.kr.equus.feed.domain.screen.presentation.dto.response + +import java.time.LocalDateTime +import java.util.UUID + +data class QueryScreenResponse( + val id: UUID, + val image: String, + val createAt: LocalDateTime, + val modifyAt: LocalDateTime +) diff --git a/src/main/kotlin/hs/kr/equus/feed/domain/screen/service/QueryScreenService.kt b/src/main/kotlin/hs/kr/equus/feed/domain/screen/service/QueryScreenService.kt new file mode 100644 index 0000000..aa5d2ab --- /dev/null +++ b/src/main/kotlin/hs/kr/equus/feed/domain/screen/service/QueryScreenService.kt @@ -0,0 +1,26 @@ +package hs.kr.equus.feed.domain.screen.service + +import hs.kr.equus.feed.domain.screen.domain.repository.ScreenRepository +import hs.kr.equus.feed.domain.screen.presentation.dto.response.QueryScreenResponse +import hs.kr.equus.feed.infrastructure.s3.PathList +import hs.kr.equus.feed.infrastructure.s3.util.FileUtil +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional + +@Service +class QueryScreenService( + private val screenRepository: ScreenRepository, + private val fileUtil: FileUtil +) { + @Transactional(readOnly = true) + fun execute(): List = + screenRepository.findAll() + .map { it -> + QueryScreenResponse( + it.id!!, + fileUtil.generateObjectUrl(it.image, PathList.SCREEN), + it.createdAt, + it.modifiedAt + ) + } +}