Skip to content

Commit deeb0c0

Browse files
committed
Fix: 병합 오류 수정
1 parent 5b93c82 commit deeb0c0

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

src/main/java/cmf/commitField/domain/pet/controller/PetController.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public class PetController {
2323

2424
// 현재 펫 경험치 상승 및 상승 시 레벨업 처리
2525
@GetMapping("/getall")
26-
public ResponseEntity<List<UserPetDto>> getUserPets(@AuthenticationPrincipal CustomOAuth2User oAuth2User){
26+
public ResponseEntity<List<PetsDto>> getUserPets(@AuthenticationPrincipal CustomOAuth2User oAuth2User){
2727
String username = oAuth2User.getName(); // CustomOAuth2User의 getName()은 user.getUsername()을 반환
2828

29-
List<UserPetDto> userPetDto = petService.getAllPets(username);
29+
List<PetsDto> userPetDto = petService.getAllPets(username);
3030
return ResponseEntity.ok(userPetDto);
3131
}
3232

@@ -40,13 +40,6 @@ public ResponseEntity<UserPetDto> getPetExp(@AuthenticationPrincipal CustomOAuth
4040
return ResponseEntity.ok(userPetDto);
4141
}
4242

43-
@GetMapping("/getall")
44-
public ResponseEntity<List<PetsDto>> getUserAllPets(@AuthenticationPrincipal CustomOAuth2User oAuth2User){
45-
String username = oAuth2User.getName();
46-
List<PetsDto> userPetDto = petService.getAllPets(username);
47-
return ResponseEntity.ok(userPetDto);
48-
}
49-
5043
// *************************************
5144
// TODO : 아래는 확장 기능, 추가 시 개선 필요
5245
// *************************************

src/main/java/cmf/commitField/domain/pet/service/PetService.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
import org.springframework.transaction.annotation.Transactional;
1515

1616
import java.io.IOException;
17-
import java.util.ArrayList;
18-
import java.util.List;
19-
import java.util.Optional;
20-
import java.util.Random;
17+
import java.util.*;
2118

2219
@Service
2320
@RequiredArgsConstructor
@@ -38,24 +35,6 @@ public Pet createPet(String petname, String username) throws IOException {
3835
return petRepository.save(newPet);
3936
}
4037

41-
public List<UserPetDto> getAllPets(String username){
42-
List<Pet> pets = petRepository.findByUserUsername(username);
43-
List<UserPetDto> userPetDtoList = new ArrayList<>();
44-
45-
for(Pet pet : pets){
46-
userPetDtoList.add(UserPetDto.builder().
47-
username(username).
48-
petId(pet.getId()).
49-
petName(pet.getName()).
50-
grow(pet.getGrow().toString()).
51-
type(pet.getType()).
52-
build());
53-
}
54-
55-
return userPetDtoList;
56-
}
57-
58-
5938
// 유저가 소유한 펫 도감 조회
6039
public UserPetListDto getUserCollection(String username) {
6140
List<Pet> pets = petRepository.findByUserUsername(username);

0 commit comments

Comments
 (0)