|
2 | 2 |
|
3 | 3 | import com.closetnangam.be.domain.wardrobe.dto.response.WardrobeResponse; |
4 | 4 | import com.closetnangam.be.domain.wardrobe.service.WardrobeService; |
| 5 | +import com.closetnangam.be.global.auth.util.SecurityUtils; |
| 6 | +import com.closetnangam.be.global.common.response.ApiResponse; |
5 | 7 | import io.swagger.v3.oas.annotations.Operation; |
6 | 8 | import io.swagger.v3.oas.annotations.tags.Tag; |
7 | 9 | import lombok.RequiredArgsConstructor; |
8 | 10 | import org.springframework.http.HttpStatus; |
| 11 | +import org.springframework.http.ResponseEntity; |
9 | 12 | import org.springframework.web.bind.annotation.GetMapping; |
10 | 13 | import org.springframework.web.bind.annotation.PathVariable; |
11 | 14 | import org.springframework.web.bind.annotation.PostMapping; |
12 | 15 | import org.springframework.web.bind.annotation.RequestMapping; |
13 | | -import org.springframework.web.bind.annotation.ResponseStatus; |
14 | 16 | import org.springframework.web.bind.annotation.RestController; |
15 | 17 |
|
16 | 18 | @Tag(name = "Wardrobe", description = "옷장 API") |
17 | 19 | @RestController |
18 | | -@RequestMapping("/api/wardrobes") |
| 20 | +@RequestMapping("/api/v1/wardrobes") |
19 | 21 | @RequiredArgsConstructor |
20 | 22 | public class WardrobeController { |
21 | 23 |
|
22 | 24 | private final WardrobeService wardrobeService; |
23 | 25 |
|
24 | 26 | @Operation(summary = "회원 옷장 조회", description = "회원당 1개의 옷장을 조회합니다.") |
25 | 27 | @GetMapping("/users/{userId}") |
26 | | - public WardrobeResponse getWardrobeByUserId(@PathVariable Long userId) { |
27 | | - return wardrobeService.getWardrobeByUserId(userId); |
| 28 | + public ResponseEntity<ApiResponse<WardrobeResponse>> getWardrobeByUserId(@PathVariable Long userId) { |
| 29 | + SecurityUtils.verifyUserIdMatch(userId); |
| 30 | + return ResponseEntity.ok(ApiResponse.ok(wardrobeService.getWardrobeByUserId(userId))); |
28 | 31 | } |
29 | 32 |
|
30 | 33 | @Operation(summary = "회원 옷장 생성", description = "회원 가입 후 옷장을 1회 생성합니다.") |
31 | 34 | @PostMapping("/users/{userId}") |
32 | | - @ResponseStatus(HttpStatus.CREATED) |
33 | | - public WardrobeResponse createWardrobe(@PathVariable Long userId) { |
34 | | - return wardrobeService.createWardrobe(userId); |
| 35 | + public ResponseEntity<ApiResponse<WardrobeResponse>> createWardrobe(@PathVariable Long userId) { |
| 36 | + SecurityUtils.verifyUserIdMatch(userId); |
| 37 | + return ResponseEntity.status(HttpStatus.CREATED) |
| 38 | + .body(ApiResponse.ok(wardrobeService.createWardrobe(userId))); |
35 | 39 | } |
36 | 40 | } |
0 commit comments