Skip to content

Commit

Permalink
#9 fix: 상세 조회 시 예외처리 없이 빈 리스트로 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
JoongHyun-Kim committed Feb 6, 2024
1 parent 2efad3a commit 8108d07
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class GiveawayService {
private String bucketName;

// 나눔글 목록 조회
public GiveawayListResponse getGiveawayList() throws BaseException { // TODO: 나눔완료 글도 목록 조회 시 포함하도록 수정 팔요
public GiveawayListResponse getGiveawayList() throws BaseException {
try {
// 나눔중 상태인 글 최신순으로 조회
List<GiveawayListResponse.GiveawayDto> giveawayList = giveawayRepository.findByStatusEqualsOrderByCreatedDateDesc(GIVEAWAY).stream()
Expand All @@ -58,10 +58,8 @@ public GiveawayListResponse getGiveawayList() throws BaseException { // TODO:
List<GiveawayListResponse.GiveawayDto> giveawayDtoList = new ArrayList<>();
giveawayDtoList.addAll(giveawayList);
giveawayDtoList.addAll(doneList);
//if (giveawayList.isEmpty()) throw new BaseException(NULL_GIVEAWAY_LIST);

return new GiveawayListResponse(giveawayDtoList);
// } catch (BaseException e) {
// throw e;
} catch (Exception e) {
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -77,7 +75,6 @@ public GiveawayResponse getGiveawayPost(Long giveawayIdx) throws BaseException {
if (userIdx != null && giveaway.getUser() != null) {
isWriter = userIdx.equals(giveaway.getUser().getUserIdx());
}
// TODO: 나눔완료 글 상세 페이지 구현에 따라 status 로직 변경 필요
return new GiveawayResponse(giveaway.getGiveawayIdx(), giveaway.getTitle(), giveaway.getContent(), giveaway.getGiveawayImage(), giveaway.getStatus(),
giveaway.getUser().getNickname(), giveaway.getUser().getContact(), giveaway.getUser().getProfileImage(), isWriter);
} catch (BaseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ public ProduceListResponse getProduceList() throws BaseException {
produce.getProduceImage(),
produce.getStatus())).toList();

// validation
//if (forSaleList.isEmpty() && soldOutList.isEmpty()) throw new BaseException(NULL_PRODUCE_LIST);

//forSaleList.addAll(soldOutList);
List<ProduceListResponse.ProduceDto> produceList = new ArrayList<>();
produceList.addAll(forSaleList);
produceList.addAll(soldOutList);

return new ProduceListResponse(produceList);
// } catch (BaseException e) {
// throw e;
} catch (Exception e) {
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -81,7 +75,6 @@ public ProduceResponse getProducePost(Long produceIdx) throws BaseException {
if (userIdx != null && produce.getUser() != null) {
isWriter = userIdx.equals(produce.getUser().getUserIdx());
}
// TODO: 판매완료 글 상세 페이지 구현에 따라 status 로직 변경 필요
return new ProduceResponse(produce.getProduceIdx(), produce.getTitle(), produce.getContent(), produce.getPrice(), produce.getProduceImage(), produce.getStatus(),
produce.getUser().getNickname(), produce.getUser().getContact(), produce.getUser().getProfileImage(), isWriter);
} catch (BaseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class RecipeService {
// 레시피글 목록 조회
public RecipeListResponse getRecipeList() throws BaseException {
try {
// TODO: 글 없을 때 예외처리 여부 결정 후 수정
List<RecipeListResponse.RecipeDto> recipeDtoList = recipeRepository.findByStatusEqualsOrderByCreatedDateDesc(ACTIVE).stream()
.map(recipe -> new RecipeListResponse.RecipeDto(
recipe.getRecipeIdx(),
Expand All @@ -38,8 +37,6 @@ public RecipeListResponse getRecipeList() throws BaseException {
recipe.getUser().getNickname(),
recipe.getUser().getProfileImage())).toList();
return new RecipeListResponse(recipeDtoList);
// } catch (BaseException e) {
// throw e;
} catch (Exception e) {
throw new BaseException(DATABASE_ERROR);
}
Expand Down

0 comments on commit 8108d07

Please sign in to comment.