-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeliveryPartyController.java
More file actions
105 lines (79 loc) · 3.22 KB
/
Copy pathDeliveryPartyController.java
File metadata and controls
105 lines (79 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.leets.tdd.party.controller;
import java.util.List;
import com.leets.tdd.party.dto.request.CreateDeliveryPartyRequest;
import com.leets.tdd.party.dto.request.UpdateDeliveryPartyRequest;
import com.leets.tdd.party.dto.response.CreateDeliveryPartyResponse;
import com.leets.tdd.party.dto.response.DeliveryPartyDetailResponse;
import com.leets.tdd.party.service.DeliveryPartyService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/delivery-parties")
@RequiredArgsConstructor
public class DeliveryPartyController {
private final DeliveryPartyService deliveryPartyService;
// 배달팟 생성 API
@PostMapping
public ResponseEntity<CreateDeliveryPartyResponse> createDeliveryParty(
@RequestBody CreateDeliveryPartyRequest request
) {
CreateDeliveryPartyResponse response =
deliveryPartyService.createDeliveryParty(request);
return ResponseEntity
.status(HttpStatus.CREATED)
.body(response);
}
// 배달팟 목록 조회 API
@GetMapping
public ResponseEntity<List<CreateDeliveryPartyResponse>> getDeliveryParties() {
List<CreateDeliveryPartyResponse> response =
deliveryPartyService.getDeliveryParties();
return ResponseEntity.ok(response);
}
// 배달팟 상세 조회 API
@GetMapping("/{partyId}")
public ResponseEntity<DeliveryPartyDetailResponse> getDeliveryPartyDetail(
@PathVariable Long partyId
) {
DeliveryPartyDetailResponse response =
deliveryPartyService.getDeliveryPartyDetail(partyId);
return ResponseEntity.ok(response);
}
// 배달팟 수정 API
@PutMapping("/{partyId}")
public ResponseEntity<Void> updateDeliveryParty(
@PathVariable Long partyId,
@RequestBody UpdateDeliveryPartyRequest request,
@AuthenticationPrincipal Long currentUserId
) {
deliveryPartyService.updateDeliveryParty(
partyId,
request,
currentUserId
);
return ResponseEntity.ok().build();
}
// 배달팟 삭제(취소) API
@DeleteMapping("/{partyId}")
public ResponseEntity<Long> deleteDeliveryParty(
@PathVariable Long partyId,
@AuthenticationPrincipal Long currentUserId
) {
Long deletedPartyId =
deliveryPartyService.deleteDeliveryParty(
partyId,
currentUserId
);
return ResponseEntity.ok(deletedPartyId);
}
}