Skip to content

Commit 5b74962

Browse files
authored
πŸ”§ chore: μŠ€μ›¨κ±° μ„ΈνŒ…
πŸ”§ chore: μŠ€μ›¨κ±° μ„ΈνŒ…
2 parents 2ea77b7 + ac77213 commit 5b74962

File tree

5 files changed

+118
-2
lines changed

5 files changed

+118
-2
lines changed

β€Žbuild.gradleβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,26 @@ repositories {
2424
}
2525

2626
dependencies {
27+
// JPA
2728
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
2829

2930
implementation 'org.springframework.boot:spring-boot-starter-web'
31+
32+
// Lombok
3033
compileOnly 'org.projectlombok:lombok'
34+
3135
runtimeOnly 'com.mysql:mysql-connector-j'
3236
annotationProcessor 'org.projectlombok:lombok'
3337
testImplementation 'org.springframework.boot:spring-boot-starter-test'
3438
testImplementation 'org.springframework.security:spring-security-test'
3539
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
3640

41+
// Swagger UI
42+
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0'
43+
44+
implementation 'org.apache.commons:commons-lang3:3.12.0'
45+
46+
// Validation
3747
implementation 'org.springframework.boot:spring-boot-starter-validation'
3848

3949
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.example.Centralthon.domain.order.web.controller;
2+
3+
import com.example.Centralthon.domain.order.web.dto.CompleteOrderReq;
4+
import com.example.Centralthon.domain.order.web.dto.CreateOrderReq;
5+
import com.example.Centralthon.domain.order.web.dto.CreateOrderRes;
6+
import com.example.Centralthon.global.response.SuccessResponse;
7+
import io.swagger.v3.oas.annotations.Operation;
8+
import io.swagger.v3.oas.annotations.media.Content;
9+
import io.swagger.v3.oas.annotations.media.ExampleObject;
10+
import io.swagger.v3.oas.annotations.media.Schema;
11+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
12+
import io.swagger.v3.oas.annotations.tags.Tag;
13+
import org.springframework.http.ResponseEntity;
14+
15+
@Tag(name = "Orders", description = "μ£Όλ¬Έ/ν”½μ—… κ΄€λ ¨ API")
16+
public interface OrderApi {
17+
18+
@Operation(
19+
summary = "μ£Όλ¬Έ 생성",
20+
description = "ν”½μ—… μ˜ˆμ•½μ„ μƒμ„±ν•©λ‹ˆλ‹€. μ™„λ£Œ μ‹œ ν”½μ—… μ½”λ“œμ™€ μ£Όλ¬Έν•œ κ°€κ²Œλ“€μ˜ κΈ°λ³Έν‚€λ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€."
21+
)
22+
@ApiResponse(
23+
responseCode = "201",
24+
description = "μ£Όλ¬Έ 생성 성곡",
25+
content = @Content(
26+
mediaType = "application/json",
27+
schema = @Schema(implementation = SuccessResponse.class),
28+
examples = @ExampleObject(
29+
name = "SUCCESS_201",
30+
value = """
31+
{
32+
"timestamp": "2025-08-15 04:22:54",
33+
"code": "SUCCESS_201",
34+
"httpStatus": 201,
35+
"message": "ν˜ΈμΆœμ— μ„±κ³΅ν•˜μ˜€μŠ΅λ‹ˆλ‹€.",
36+
"data": {
37+
"code": "PE8512",
38+
"storeList": [1, 3]
39+
},
40+
"isSuccess": true
41+
}
42+
"""
43+
)
44+
)
45+
)
46+
ResponseEntity<SuccessResponse<CreateOrderRes>> createOrder(CreateOrderReq orderReq);
47+
48+
@Operation(
49+
summary = "ν”½μ—… μ™„λ£Œ 처리",
50+
description = "ν”½μ—… μ½”λ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ 주문을 ν”½μ—… μ™„λ£Œλ‘œ μ²˜λ¦¬ν•©λ‹ˆλ‹€."
51+
)
52+
@ApiResponse(
53+
responseCode = "200",
54+
description = "ν”½μ—… μ™„λ£Œ 성곡",
55+
content = @Content(
56+
mediaType = "application/json",
57+
schema = @Schema(implementation = SuccessResponse.class),
58+
examples = @ExampleObject(
59+
name = "SUCCESS_200",
60+
value = """
61+
{
62+
"timestamp": "2025-08-15 04:45:14",
63+
"code": "SUCCESS_200",
64+
"httpStatus": 200,
65+
"message": "ν˜ΈμΆœμ— μ„±κ³΅ν•˜μ˜€μŠ΅λ‹ˆλ‹€.",
66+
"data": null,
67+
"isSuccess": true
68+
}
69+
"""
70+
)
71+
)
72+
)
73+
ResponseEntity<SuccessResponse<?>> completePickUp(CompleteOrderReq completeOrderReq);
74+
}

β€Žsrc/main/java/com/example/Centralthon/domain/order/web/controller/OrderController.javaβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
@RestController
1616
@RequiredArgsConstructor
1717
@RequestMapping("/api/orders")
18-
public class OrderController {
18+
public class OrderController implements OrderApi {
1919
private final OrderService orderService;
2020

2121
@PostMapping
22+
@Override
2223
public ResponseEntity<SuccessResponse<CreateOrderRes>> createOrder(@RequestBody @Valid CreateOrderReq orderReq) {
2324
CreateOrderRes createOrderRes = orderService.orderMenus(orderReq);
2425
return ResponseEntity.status(HttpStatus.CREATED).body(SuccessResponse.of(createOrderRes, SuccessResponseCode.SUCCESS_CREATED));
2526
}
2627

2728
@PutMapping("/complete")
29+
@Override
2830
public ResponseEntity<SuccessResponse<?>> completePickUp(@RequestBody @Valid CompleteOrderReq completeOrderReq){
2931
orderService.completePickUp(completeOrderReq);
3032
return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.empty());
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.example.Centralthon.global.config;
2+
3+
import io.swagger.v3.oas.models.Components;
4+
import io.swagger.v3.oas.models.OpenAPI;
5+
import io.swagger.v3.oas.models.info.Info;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
@Configuration
10+
public class SwaggerConfig {
11+
@Bean
12+
public OpenAPI openAPI(){
13+
Info info = new Info()
14+
.title("μž”λ°˜ν”ŒλŸ¬νŒ… API Document")
15+
.version("v0.0.1")
16+
.description("μž”λ°˜ ν”ŒλŸ¬νŒ… API λͺ…μ„Έμ„œμž…λ‹ˆλ‹€.");
17+
18+
return new OpenAPI()
19+
.components(new Components())
20+
.info(info);
21+
}
22+
}

β€Žsrc/main/resources/application.propertiesβ€Ž

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ spring.datasource.password=${DATABASE_PASSWORD}
1212
spring.jpa.hibernate.ddl-auto=update
1313
spring.jpa.show-sql=true
1414
spring.jpa.properties.hibernate.format_sql=true
15-
spring.jpa.properties.hibernate.use_sql_comments=true
15+
spring.jpa.properties.hibernate.use_sql_comments=true
16+
17+
# Swagger
18+
springdoc.swagger-ui.path=/swagger-ui.html
19+
springdoc.api-docs.path=/api-docs
20+
springdoc.group-configs[0].group=default
21+
springdoc.group-configs[0].paths-to-match=/**
22+
springdoc.api-docs.enabled=true
23+
springdoc.swagger-ui.enabled=true

0 commit comments

Comments
Β (0)