Skip to content

Commit

Permalink
feat: 헌트 요청 개별 조회 -> loginId로 요청(#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinheekim committed Jun 28, 2024
1 parent 1dc3ab0 commit d0684f0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public BaseResponse<BughuntListResDto> bughuntFindAll(){
return BaseResponse.success(SuccessCode.GET_SUCCESS, bughuntListResDto);
}
@Operation(summary = "헌트 요청 개별 id 조회", description = "개별 id로 헌트 요청 조회하기")
@GetMapping("/{id}")
public BaseResponse<BughuntInfoResDto> bughuntFindById(@PathVariable Long id){
BughuntInfoResDto bughuntInfoResDto = bughuntService.findById(id);
@GetMapping("/user")
public BaseResponse<BughuntInfoResDto> bughuntFindById(@RequestParam String loginId){ //requestparam
BughuntInfoResDto bughuntInfoResDto = bughuntService.findByLoginId(loginId);
return BaseResponse.success(SuccessCode.GET_SUCCESS, bughuntInfoResDto);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

public interface BughuntRepository extends JpaRepository<Bughunt, Long> {
List<Bughunt> findByLatitudeBetweenAndLongitudeBetween(BigDecimal minLat, BigDecimal maxLat, BigDecimal minLng, BigDecimal maxLng);

Bughunt findByUser(User user);

Optional<Bughunt> findByUserLoginId(String loginId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ public BughuntListResDto findAll(){
return BughuntListResDto.from(bughuntInfoResDtoList);
}

public BughuntInfoResDto findById(Long id){
/* public BughuntInfoResDto findById(Long id){
Bughunt bughunt = bughuntRepository.findById(id).orElseThrow(
() -> new EntityNotFoundException("버그 헌트 요청 id 조회 불가: " + id));
return BughuntInfoResDto.from(bughunt);
}*/

public BughuntInfoResDto findByLoginId(String loginId) { // bughunt id 조회 -> loginId(사용자당 하나의 구인 올릴 수 있음)
Bughunt bughunt = bughuntRepository.findByUserLoginId(loginId)
.orElseThrow(() -> new EntityNotFoundException("해당 아이디 조회 불가: " + loginId));
return BughuntInfoResDto.from(bughunt);
}

public BughuntListResDto findByRadius(BughuntLocationReqDto bughuntLocationReqDto) {
Expand Down

0 comments on commit d0684f0

Please sign in to comment.