diff --git a/src/main/kotlin/site/billilge/api/backend/domain/rental/controller/AdminRentalApi.kt b/src/main/kotlin/site/billilge/api/backend/domain/rental/controller/AdminRentalApi.kt new file mode 100644 index 0000000..7c36f96 --- /dev/null +++ b/src/main/kotlin/site/billilge/api/backend/domain/rental/controller/AdminRentalApi.kt @@ -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 + + @Operation( + summary = "모든 대여 기록 조회", + description = "모든 대여 기록을 조회하기 위한 관리자용 API" + ) + @ApiResponses( + value = [ + ApiResponse( + responseCode = "200", + description = "대여 기록 조회 성공" + ) + ] + ) + fun getAllRentalHistories( + @ModelAttribute pageableCondition: PageableCondition, + @ModelAttribute searchCondition: SearchCondition + ): ResponseEntity + + @Operation( + summary = "대여 상태 변경", + description = "대여 승인, 대여, 반납 승인, 반납 처리 등을 위해 대여 기록의 상태를 변경하는 관리자용 API" + ) + @ApiResponses( + value = [ + ApiResponse( + responseCode = "200", + description = "대여 상태 변경 성공" + ) + ] + ) + fun updateRentalStatus( + @PathVariable rentalHistoryId: Long, + @RequestBody request: RentalStatusUpdateRequest + ): ResponseEntity +} \ No newline at end of file diff --git a/src/main/kotlin/site/billilge/api/backend/domain/rental/controller/AdminRentalController.kt b/src/main/kotlin/site/billilge/api/backend/domain/rental/controller/AdminRentalController.kt index af992c7..299067f 100644 --- a/src/main/kotlin/site/billilge/api/backend/domain/rental/controller/AdminRentalController.kt +++ b/src/main/kotlin/site/billilge/api/backend/domain/rental/controller/AdminRentalController.kt @@ -21,14 +21,14 @@ import site.billilge.api.backend.global.dto.SearchCondition @OnlyAdmin class AdminRentalController( private val rentalService: RentalService -) { +) : AdminRentalApi { @GetMapping("/dashboard") - fun getAllDashboardApplications(): ResponseEntity { + override fun getAllDashboardApplications(): ResponseEntity { return ResponseEntity.ok(rentalService.getAllDashboardApplications()) } @GetMapping - fun getAllRentalHistories( + override fun getAllRentalHistories( @ModelAttribute pageableCondition: PageableCondition, @ModelAttribute searchCondition: SearchCondition ): ResponseEntity { @@ -36,7 +36,7 @@ class AdminRentalController( } @PatchMapping("/{rentalHistoryId}") - fun updateRentalStatus( + override fun updateRentalStatus( @PathVariable rentalHistoryId: Long, @RequestBody request: RentalStatusUpdateRequest ): ResponseEntity { diff --git a/src/main/kotlin/site/billilge/api/backend/domain/rental/dto/response/RentalHistoryDetail.kt b/src/main/kotlin/site/billilge/api/backend/domain/rental/dto/response/RentalHistoryDetail.kt index d7b6c7d..b51a85c 100644 --- a/src/main/kotlin/site/billilge/api/backend/domain/rental/dto/response/RentalHistoryDetail.kt +++ b/src/main/kotlin/site/billilge/api/backend/domain/rental/dto/response/RentalHistoryDetail.kt @@ -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)") @@ -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 diff --git a/src/main/kotlin/site/billilge/api/backend/global/config/SwaggerConfig.kt b/src/main/kotlin/site/billilge/api/backend/global/config/SwaggerConfig.kt index 8710bf0..39e26a0 100644 --- a/src/main/kotlin/site/billilge/api/backend/global/config/SwaggerConfig.kt +++ b/src/main/kotlin/site/billilge/api/backend/global/config/SwaggerConfig.kt @@ -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") @@ -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) } } \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 80cb3b4..9ca91bf 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -58,4 +58,8 @@ cloud: region: static: us-west-2 stack: - auto: false \ No newline at end of file + auto: false + +swagger: + server: + base-url: ${SWAGGER_SERVER_BASE_URL} \ No newline at end of file