Skip to content

Commit

Permalink
feat: GET 북토크 상세조회 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
onpyeong committed Jul 10, 2023
1 parent 3f1aeba commit 0135e6f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.sophy.sophy.controller.dto.request.BooktalkRequestDto;
import org.sophy.sophy.controller.dto.response.BooktalkCreateResponseDto;
import org.sophy.sophy.controller.dto.response.BooktalkDeleteResponseDto;
import org.sophy.sophy.controller.dto.response.BooktalkDetailResponseDto;
import org.sophy.sophy.exception.SuccessStatus;
import org.sophy.sophy.service.BooktalkService;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -37,4 +38,9 @@ public ApiResponseDto<BooktalkDeleteResponseDto> deleteBooktalk(@PathVariable("b
return ApiResponseDto.success(SuccessStatus.DELETE_BOOKTALK_SUCCESS, booktalkService.deleteBooktalk(booktalkId));
}

@GetMapping("/{booktalkId}/detail")
public ApiResponseDto<BooktalkDetailResponseDto> getBooktalkDetail(@PathVariable("booktalkId") Long booktalkId) {
return ApiResponseDto.success(SuccessStatus.GET_BOOKTALK_DETAIL_SUCCESS, booktalkService.getBooktalkDetail(booktalkId));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.sophy.sophy.controller.dto.response;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.sophy.sophy.domain.BookCategory;
import org.sophy.sophy.domain.Booktalk;
import org.sophy.sophy.domain.PreliminaryInfo;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class BooktalkDetailResponseDto {
private String booktalkImageUrl;
private String title;
private String Author;
private BookCategory bookCategory;
private String book; //TODO 추후 연결
private LocalDateTime startDate;
private LocalDateTime endDate;
private Integer participant;
private Integer participationFee;
private PreliminaryInfo preliminaryInfo;
private String description;
private String PlaceName;
private String PlaceAddress;

public static BooktalkDetailResponseDto of(Booktalk booktalk) {
return new BooktalkDetailResponseDto(
booktalk.getBooktalkImageUrl(),
booktalk.getTitle(),
booktalk.getMember().getName(),
booktalk.getBookCategory(),
"책이름", //TODO 추후 연결
booktalk.getStartDate(),
booktalk.getEndDate(),
booktalk.getParticipantList().size(),
booktalk.getParticipationFee(),
booktalk.getPreliminaryInfo(),
booktalk.getDescription(),
booktalk.getPlace().getName(),
booktalk.getPlace().getAddress()
);
}
}
1 change: 1 addition & 0 deletions src/main/java/org/sophy/sophy/exception/SuccessStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum SuccessStatus {
GET_PLACES_BY_CITY_SUCCESS(HttpStatus.OK, "지역으로 공간 리스트를 성공적으로 불러왔습니다."),
PATCH_BOOKTALK_SUCCESS(HttpStatus.OK, "북토크를 성공적으로 수정했습니다."),
DELETE_BOOKTALK_SUCCESS(HttpStatus.OK, "북토크를 성공적으로 삭제했습니다."),
GET_BOOKTALK_DETAIL_SUCCESS(HttpStatus.OK, "북토크 상세정보를 성공적으로 불러왔습니다."),
TEST_SUCCESS(HttpStatus.OK, "Test :: OK"),
/*
* 201 created
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/sophy/sophy/service/BooktalkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.sophy.sophy.controller.dto.request.BooktalkRequestDto;
import org.sophy.sophy.controller.dto.response.BooktalkCreateResponseDto;
import org.sophy.sophy.controller.dto.response.BooktalkDeleteResponseDto;
import org.sophy.sophy.controller.dto.response.BooktalkDetailResponseDto;
import org.sophy.sophy.domain.Booktalk;
import org.sophy.sophy.domain.Member;
import org.sophy.sophy.domain.Place;
Expand Down Expand Up @@ -43,6 +44,7 @@ public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto bookt
return booktalkUpdateDto;
}

@Transactional
public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) {
Booktalk booktalk = getBooktalkById(booktalkId);
//TODO soft delete?
Expand All @@ -53,6 +55,11 @@ public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) {
return BooktalkDeleteResponseDto.of(booktalkId);
}

public BooktalkDetailResponseDto getBooktalkDetail(Long booktalkId) {
Booktalk booktalk = getBooktalkById(booktalkId);
return BooktalkDetailResponseDto.of(booktalk);
}

private Member getMemberById(Long memberId) {
return memberRepository.findById(memberId)
.orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_USER_EXCEPTION, ErrorStatus.NOT_FOUND_USER_EXCEPTION.getMessage()));
Expand Down

0 comments on commit 0135e6f

Please sign in to comment.