Skip to content

Commit

Permalink
Merge pull request #41 from EntryDSM/feature/entry-171-전형-요강-조회-api-개발
Browse files Browse the repository at this point in the history
🔀 :: (ENTRY-171) :: 전형 요강 조회 api 개발
  • Loading branch information
rudeh2926 authored Apr 16, 2024
2 parents c711e25 + 957cd5b commit 053b122
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -22,4 +26,8 @@ class ScreenController(
@RequestPart(name = "image") image: MultipartFile
): ScreenResponse =
createScreenService.execute(image)

@GetMapping
fun queryScreen(): List<QueryScreenResponse> =
queryScreenService.execute()
}
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -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<QueryScreenResponse> =
screenRepository.findAll()
.map { it ->
QueryScreenResponse(
it.id!!,
fileUtil.generateObjectUrl(it.image, PathList.SCREEN),
it.createdAt,
it.modifiedAt
)
}
}

0 comments on commit 053b122

Please sign in to comment.