Skip to content

Commit

Permalink
add: log 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Song-EunJu committed Nov 17, 2022
1 parent 3520328 commit 0c2634e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/com/example/goorm/oreum/OreumService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import com.example.goorm.oreum.repository.MyOreumRepository;
import com.example.goorm.oreum.repository.OreumRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;

import java.io.*;

@Slf4j
@Service
@RequiredArgsConstructor
public class OreumService {
Expand All @@ -21,11 +23,12 @@ public OreumResponse getOreum(BirthDayRequest request){
int month = request.getMonth();
int day = request.getDay();
Oreum oreum = oreumRepository.findByBirthday(month, day); // 저장된 오름을 찾아서
log.info("Oreum id: "+oreum.getId());
MyOreum myOreum = MyOreum.builder() // 나의 오름을 저장하고
.nickname(request.getNickname())
.oreumId(oreum.getId())
.build();

log.info("MyOreum id: "+myOreum.getId());
myOreumRepository.save(myOreum);
return OreumResponse.of(oreum, myOreum, request);
}
Expand All @@ -34,9 +37,11 @@ public OreumResponse getMyOreum(Long myOreumId){
MyOreum myOreum = myOreumRepository.findById(myOreumId).orElseThrow(() -> {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "해당하는 오름 스티커 번호가 없습니다");
});
log.info("MyOreum id: "+myOreum.getId());
Oreum oreumInfo = oreumRepository.findById(myOreum.getOreumId()).orElseThrow(() -> {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "해당하는 오름의 번호가 없습니다");
});
log.info("Oreum id: "+oreumInfo.getId());
return OreumResponse.ofOthers(oreumInfo, myOreum);
}

Expand Down

0 comments on commit 0c2634e

Please sign in to comment.