Skip to content

Commit

Permalink
Merge pull request #28 from umc-5th-hackathon-team-I/feature/#27
Browse files Browse the repository at this point in the history
[ADD] íí편지 상세조회API
  • Loading branch information
2hy2on authored Jan 2, 2024
2 parents 684f4b3 + 61dee90 commit df22567
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ public ApiResponse<Boolean> addVisitorComment(@RequestBody VisitorCommentReq vis

@Operation(summary = "방명록 리스트 조회 API")
@GetMapping("/visitorComment")
public ApiResponse<List<VisitorCommentRes>> addVisitorComment(@RequestParam Long memberId){
public ApiResponse<List<VisitorCommentRes>> getVisitCommentList(@RequestParam Long memberId){
List<VisitorCommentRes> commentList = memberService.getVisitCommentList(memberId);
return ApiResponse.onSuccess(commentList);
}

@Operation(summary = "방명록 상세 조회 API")
@GetMapping("/visitorCommentDetail")
public ApiResponse<VisitorCommentRes> getVisitComment(@RequestParam Long memberId, @RequestParam Long calendarVisitorId){
VisitorCommentRes comment = memberService.getVisitComment(memberId,calendarVisitorId);
return ApiResponse.onSuccess(comment);
}
}
13 changes: 13 additions & 0 deletions src/main/java/com/teami/domain/member/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,17 @@ public List<VisitorCommentRes> getVisitCommentList(Long memberId) {
return dtoList;

}

public VisitorCommentRes getVisitComment(Long memberId, Long calendarVisitorId) {
if(memberRepository.findById(memberId).isEmpty()){
throw new ExceptionHandler(ErrorStatus.MEMBER_NOT_FOUND);
}
Optional<CalendarVisitor> v = calendarVisitorRepository.findById(calendarVisitorId);
if(v.isEmpty()){
throw new ExceptionHandler(ErrorStatus.VISITOR_NOT_FOUND);
}
VisitorCommentRes res = new VisitorCommentRes(v.get());

return res;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public enum ErrorStatus implements BaseErrorCode {
FOOD_CATEGORY_NOT_FOUND(HttpStatus.NOT_FOUND, "FOOD4001", "음식이이 없습니다."),


STORE_NOT_FOUND(HttpStatus.BAD_REQUEST, "STORE4000", "가게가 없습니다.");
STORE_NOT_FOUND(HttpStatus.BAD_REQUEST, "STORE4000", "가게가 없습니다."),

//편지 에러
VISITOR_NOT_FOUND(HttpStatus.BAD_REQUEST, "VISITOR4000", "해당 편지가 없습니다.");

private final HttpStatus httpStatus;
private final String code;
Expand Down

0 comments on commit df22567

Please sign in to comment.