-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserPetController.java
More file actions
32 lines (27 loc) ยท 1.31 KB
/
UserPetController.java
File metadata and controls
32 lines (27 loc) ยท 1.31 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
package cmf.commitField.domain.pet.controller;
import cmf.commitField.domain.pet.dto.UserPetListDto;
import cmf.commitField.domain.pet.service.PetService;
import cmf.commitField.domain.pet.service.UserPetService;
import cmf.commitField.domain.user.entity.CustomOAuth2User;
import cmf.commitField.domain.user.service.CustomOAuth2UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/user/")
@RequiredArgsConstructor
public class UserPetController {
private final UserPetService userPetService;
private final CustomOAuth2UserService customOAuth2UserService;
private final PetService petService;
// ์ ์ ์ ๋๊ฐ ์กฐํ (๋ณด์ ํ ํซ ๋ชฉ๋ก)
@GetMapping("/collection")
public ResponseEntity<UserPetListDto> getUserPetCollection(@AuthenticationPrincipal CustomOAuth2User oAuth2User) {
String username = oAuth2User.getName();
UserPetListDto userPetListDto = petService.getUserCollection(username);
return ResponseEntity.ok(userPetListDto);
}
}