-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#3-order-tosspayments
- Loading branch information
Showing
23 changed files
with
546 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,4 @@ out/ | |
.vscode/ | ||
|
||
env | ||
.env | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
DB_USERNAME=root | ||
DB_PASSWORD=!123456 | ||
DB_URL=jdbc:mariadb://localhost:3306/ttukttak_parking?serverTimezone\=Asia/Seoul | ||
|
||
FRONTEND_URL=http://localhost:3000 | ||
|
||
KAKAO_API_KEY=0314d8afcdad5de6365ef17c1d0ab606 | ||
|
||
SECRET_KEY=4d9715cf62ea78542329e546846afdbe01fe82abc1d06c37b7131d97836b42740fe28ee7c322500563d6a828f3659c13ce5b5666082e80cbc139e902b76fd21d8493a94283239d14577f6ee4aeb655651488e8fe9cdf772021c6fbaf4b6ab43daacb0a6ed6cdc170a995c108dcf0063d339970960c816147fe789a98931bfc74235b7fd2d3299cd9e83ef3a1a9400f950e0eb70c14004e5a566aa16b776a847c56d687809da1e8ea5c4b612b9a1185efe68570bd18fd1d39ae5119d2d239a409054190d0550bdb7eb96704af63ce3a834d808e2fe5136db025e3494236a645236cf41f2816154fff131175bc650fbb5b2964188f43b390a32a98e4f9ee75ff4cf8a4f8fbe1f8d44148c83b907d50fbbf9da30ece7918fa9024c98501e42c574932921ab2f583a7da9d4aa5e32620476dc210f53c1bf0ae1c9e47461f2341f26944dba471706f06646e312b0fc537c7788751928abb8c7cff2915f76c66bf2d48b599d755ee8d7a1d80bbb11c9e9c4379c1f0dba3026f5f4dc6ab1ea711e6938d73d60de53f6e89aef60eeb0bc5a79f7ceece7be906f2f9dc2e6d5cc6242d239515023733faf254af3fb4e6235bb02b9e7c859efcbb112e1ceba472ad6ee286477f85219dcc765d614395c618829d0b905fc88839bf22a96905c8edaee812492e4a6de5a6de56df104da0d4a73effae2e13c3f0594c6689f753ee64965d12a6f5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
pluginManagement { | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' version '1.9.0' | ||
id 'org.jetbrains.kotlin.jvm' version '1.9.24' | ||
} | ||
} | ||
rootProject.name = 'ttukttak_parking' |
74 changes: 74 additions & 0 deletions
74
backend/src/main/java/com/nbe2_3_3_team4/backend/controller/OrderController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.nbe2_3_3_team4.backend.controller | ||
|
||
import com.nbe2_3_3_team4.backend.domain.order.dto.OrderRequest | ||
import com.nbe2_3_3_team4.backend.domain.order.dto.OrderResponse | ||
import com.nbe2_3_3_team4.backend.domain.order.service.OrderService | ||
import com.nbe2_3_3_team4.backend.global.response.ApiResponse | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.security.core.userdetails.User | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal | ||
import org.springframework.web.bind.annotation.* | ||
|
||
|
||
@RestController | ||
@RequestMapping("/api/orders") | ||
@Tag(name = "Order API", description = "주차권 주문 관련 API") | ||
class OrderController( | ||
private val orderService: OrderService | ||
) { | ||
|
||
@Operation(summary = "주차권 주문 요청 API", description = "주차권 구매를 요청합니다.") | ||
@ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "성공")) | ||
@PostMapping("/tickets") | ||
fun createOrder( | ||
@RequestBody dto: OrderRequest.CreateOrder, | ||
@AuthenticationPrincipal user: User | ||
): ResponseEntity<ApiResponse<OrderResponse.CreateOrder>> { | ||
val response = orderService.createOrder(dto, user.username) | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ApiResponse.createSuccess(response)) | ||
} | ||
|
||
@Operation(summary = "주차권 주문 결제 성공 API", description = "주차권 결제 성공 시 상태 변경합니다") | ||
@ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "성공")) | ||
@PutMapping("/{payId}/success") | ||
fun completePay(@PathVariable payId: String): ResponseEntity<ApiResponse<String>> { | ||
val response = orderService.completePay(payId) | ||
return ResponseEntity.ok(ApiResponse.createSuccess(response)) | ||
} | ||
|
||
@Operation(summary = "주차권 구매 기록 상세 조회 API", description = "주차권 구매 세부 기록을 조회합니다.") | ||
@ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "성공")) | ||
@GetMapping("/{orderId}") | ||
fun getOrder(@PathVariable orderId: String): ResponseEntity<ApiResponse<OrderResponse>> { | ||
val response = orderService.getOrder(orderId) | ||
return ResponseEntity.ok(ApiResponse.createSuccess(response)) | ||
} | ||
|
||
@Operation(summary = "주차권 취소 요청 API", description = "주차권 취소를 요청합니다.") | ||
@ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "성공")) | ||
@PutMapping("/{orderId}/cancel") | ||
fun cancelTicket( | ||
@AuthenticationPrincipal user: User, | ||
@PathVariable orderId: String | ||
): ResponseEntity<ApiResponse<String>> { | ||
val response = orderService.cancelTicket(user.username, orderId) | ||
return ResponseEntity.ok(ApiResponse.createSuccess(response)) | ||
} | ||
|
||
@DeleteMapping("/{payId}") | ||
fun deleteOrder(@PathVariable payId: String): ResponseEntity<ApiResponse<Void?>> { | ||
return ResponseEntity.ok(ApiResponse.createSuccess(orderService.deleteOrder(payId))) | ||
} | ||
|
||
@Operation(summary = "주차권 구매 기록 조회 API", description = "주차권 구매 기록을 조회합니다.") | ||
@ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "성공")) | ||
@GetMapping("/order-history") | ||
fun getOrderHistory(@AuthenticationPrincipal user: User): ResponseEntity<ApiResponse<List<OrderResponse.GetOrderHistory>>> { | ||
val response = orderService.getOrderHistory(user.username) | ||
return ResponseEntity.ok(ApiResponse.createSuccess(response)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/com/nbe2_3_3_team4/backend/domain/order/dto/OrderRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.nbe2_3_3_team4.backend.domain.order.dto | ||
|
||
import com.nbe2_3_3_team4.backend.domain.order.entity.enum.PaymentStatus | ||
|
||
data class OrderRequest( | ||
val createOrder: CreateOrder | ||
) { | ||
data class CreateOrder( | ||
val paymentId: String, | ||
val ticketId: Long, | ||
val carNumber: String, | ||
val paymentStatus: PaymentStatus | ||
) | ||
} |
91 changes: 91 additions & 0 deletions
91
backend/src/main/java/com/nbe2_3_3_team4/backend/domain/order/dto/OrderResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.nbe2_3_3_team4.backend.domain.order.dto | ||
|
||
import com.nbe2_3_3_team4.backend.domain.order.entity.Order | ||
import com.nbe2_3_3_team4.backend.domain.order.entity.OrderDetail | ||
import com.nbe2_3_3_team4.backend.domain.parking.entity.Parking | ||
import com.nbe2_3_3_team4.backend.domain.ticket.entity.Ticket | ||
import com.nbe2_3_3_team4.backend.domain.order.entity.enum.OrderStatus.* | ||
import java.time.format.DateTimeFormatter | ||
|
||
data class OrderResponse( | ||
val parking: String?, | ||
val addr: String?, | ||
val carNum: String, | ||
val startTime: String?, | ||
val endTime: String, | ||
val pkDuration: Int?, | ||
val price: Int?, | ||
val addPkDuration: Int, | ||
val addPrice: Int, | ||
val totalPrice: Int | ||
) { | ||
companion object { | ||
fun from(parking: Parking, orderDetail: OrderDetail, ticket: Ticket, addPkDuration: Int, addPrice: Int): OrderResponse { | ||
val formatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일 a h시 mm분") | ||
val start = orderDetail.startParkingTime?.format(formatter) | ||
val end = orderDetail.endParkingTime?.format(formatter) ?: "주차중" | ||
|
||
return OrderResponse( | ||
parking.name, | ||
parking.address, | ||
orderDetail.carNumber, | ||
start, | ||
end, | ||
ticket.parkingDuration, | ||
ticket.price, | ||
addPkDuration, | ||
addPrice, | ||
ticket.price!! + addPrice | ||
) | ||
} | ||
} | ||
|
||
|
||
|
||
data class CreateOrder( | ||
val orderId: String, | ||
val ticketId: Long, | ||
val memberId: Long, | ||
val carNum: String | ||
) { | ||
companion object { | ||
fun from(orderId: String, ticketId: Long, memberId: Long, carNum: String): CreateOrder { | ||
return CreateOrder(orderId, ticketId, memberId, carNum) | ||
} | ||
} | ||
} | ||
|
||
data class GetOrderHistory( | ||
val orderId: String, | ||
val parkingId: Long, | ||
val carNum: String, | ||
val time: String, | ||
val status: String, | ||
val duration: Int, | ||
val price: Int | ||
) { | ||
companion object { | ||
fun from(order: Order, parking: Parking, ticket: Ticket): GetOrderHistory { | ||
val start = order.createdAt!! | ||
val formatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일 a h시 mm분") | ||
val time = start.format(formatter) | ||
val status = when (order.orderStatus) { | ||
WAITING -> "주차 대기" | ||
PARKING -> "주차중" | ||
CANCELED -> "환불" | ||
else -> "주차 완료" | ||
} | ||
|
||
return GetOrderHistory( | ||
order.id, | ||
parking.parkingId!!, | ||
order.orderDetail.carNumber, | ||
time, | ||
status, | ||
ticket.parkingDuration!!, | ||
ticket.price!! | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/com/nbe2_3_3_team4/backend/domain/order/entity/enum/OrderStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nbe2_3_3_team4.backend.domain.order.entity.enum | ||
|
||
enum class OrderStatus(val message: String) { | ||
WAITING("주차 대기"), | ||
PARKING("주차 중"), | ||
FINISHED("주차 종료"), | ||
CANCELED("취소"); | ||
|
||
override fun toString(): String = message | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/com/nbe2_3_3_team4/backend/domain/order/entity/enum/PaymentStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.nbe2_3_3_team4.backend.domain.order.entity.enum | ||
|
||
enum class PaymentStatus(val message : String) { | ||
WAITING("결제 대기"), | ||
COMPLETE("결제 완료"); | ||
|
||
override fun toString(): String = message | ||
} |
8 changes: 8 additions & 0 deletions
8
...src/main/java/com/nbe2_3_3_team4/backend/domain/order/repository/OrderDetailRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.nbe2_3_3_team4.backend.domain.order.repository | ||
|
||
import com.nbe2_3_3_team4.backend.domain.order.entity.OrderDetail | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface OrderDetailRepository : JpaRepository<OrderDetail, Long> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.