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,66 @@
package site.billilge.api.backend.domain.rental.controller

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestBody
import site.billilge.api.backend.domain.rental.dto.request.RentalStatusUpdateRequest
import site.billilge.api.backend.domain.rental.dto.response.AdminRentalHistoryFindAllResponse
import site.billilge.api.backend.domain.rental.dto.response.DashboardResponse
import site.billilge.api.backend.global.dto.PageableCondition
import site.billilge.api.backend.global.dto.SearchCondition

@Tag(name = "(Admin) Rental", description = "관리자용 대여 API")
interface AdminRentalApi {
@Operation(
summary = "관리자 대시보드 목록 조회",
description = "관리자 대시보드 페이지 조회를 위한 API"
)
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "대시보드 목록 조회 성공"
)
]
)
fun getAllDashboardApplications(): ResponseEntity<DashboardResponse>

@Operation(
summary = "모든 대여 기록 조회",
description = "모든 대여 기록을 조회하기 위한 관리자용 API"
)
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "대여 기록 조회 성공"
)
]
)
fun getAllRentalHistories(
@ModelAttribute pageableCondition: PageableCondition,
@ModelAttribute searchCondition: SearchCondition
): ResponseEntity<AdminRentalHistoryFindAllResponse>

@Operation(
summary = "대여 상태 변경",
description = "대여 승인, 대여, 반납 승인, 반납 처리 등을 위해 대여 기록의 상태를 변경하는 관리자용 API"
)
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "대여 상태 변경 성공"
)
]
)
fun updateRentalStatus(
@PathVariable rentalHistoryId: Long,
@RequestBody request: RentalStatusUpdateRequest
): ResponseEntity<Void>
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ import site.billilge.api.backend.global.dto.SearchCondition
@OnlyAdmin
class AdminRentalController(
private val rentalService: RentalService
) {
) : AdminRentalApi {
@GetMapping("/dashboard")
fun getAllDashboardApplications(): ResponseEntity<DashboardResponse> {
override fun getAllDashboardApplications(): ResponseEntity<DashboardResponse> {
return ResponseEntity.ok(rentalService.getAllDashboardApplications())
}

@GetMapping
fun getAllRentalHistories(
override fun getAllRentalHistories(
@ModelAttribute pageableCondition: PageableCondition,
@ModelAttribute searchCondition: SearchCondition
): ResponseEntity<AdminRentalHistoryFindAllResponse> {
return ResponseEntity.ok(rentalService.getAllRentalHistories(pageableCondition, searchCondition))
}

@PatchMapping("/{rentalHistoryId}")
fun updateRentalStatus(
override fun updateRentalStatus(
@PathVariable rentalHistoryId: Long,
@RequestBody request: RentalStatusUpdateRequest
): ResponseEntity<Void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ data class RentalHistoryDetail(
@field:Schema(description = "대여 이력 ID", example = "123")
val rentalHistoryId: Long,
@field:Schema(description = "대여한 회원의 요약 정보", required = true)
val memberId: MemberSummary,
val member: MemberSummary,
@field:Schema(description = "대여한 물품의 요약 정보", required = true)
val itemId: ItemSummary,
val item: ItemSummary,
@field:Schema(description = "대여 시작 시각")
val rentAt: LocalDateTime,
@field:Schema(description = "반납 시각 (반납되지 않았으면 null)")
Expand All @@ -28,8 +28,8 @@ data class RentalHistoryDetail(
fun from(rentalHistory: RentalHistory): RentalHistoryDetail {
return RentalHistoryDetail(
rentalHistoryId = rentalHistory.id!!,
memberId = MemberSummary.from(rentalHistory.member),
itemId = ItemSummary.from(rentalHistory.item),
member = MemberSummary.from(rentalHistory.member),
item = ItemSummary.from(rentalHistory.item),
rentAt = rentalHistory.rentAt,
returnedAt = rentalHistory.returnedAt,
rentalStatus = rentalHistory.rentalStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ import io.swagger.v3.oas.models.Components
import io.swagger.v3.oas.models.OpenAPI
import io.swagger.v3.oas.models.security.SecurityRequirement
import io.swagger.v3.oas.models.security.SecurityScheme
import io.swagger.v3.oas.models.servers.Server
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@OpenAPIDefinition(info = Info(title = "빌릴게(Billilge) API", description = "국민대학교 소프트웨어융합대학 복지물품 대여 서비스", version = "v1"))
@OpenAPIDefinition(
info = Info(
title = "빌릴게(Billilge) API",
description = "국민대학교 소프트웨어융합대학 복지물품 대여 서비스",
version = "v1"
)
)
@Configuration
class SwaggerConfig {
class SwaggerConfig(
@Value("\${swagger.server.base-url}")
private val serverBaseUrl: String,
) {
@Bean
fun openAPI(): OpenAPI {
val securityRequirement = SecurityRequirement().addList("JWT")
Expand All @@ -22,9 +33,14 @@ class SwaggerConfig {
.scheme("bearer")
.bearerFormat("JWT")
)

val server = Server()
.apply { url = serverBaseUrl }

return OpenAPI()
.components(Components())
.addSecurityItem(securityRequirement)
.servers(listOf(server))
.components(components)
}
}
6 changes: 5 additions & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ cloud:
region:
static: us-west-2
stack:
auto: false
auto: false

swagger:
server:
base-url: ${SWAGGER_SERVER_BASE_URL}
Loading