diff --git a/src/main/java/com/book/backend/domain/opentalk/controller/OpentalkController.java b/src/main/java/com/book/backend/domain/opentalk/controller/OpentalkController.java index 20ad0966..f13b5c7f 100644 --- a/src/main/java/com/book/backend/domain/opentalk/controller/OpentalkController.java +++ b/src/main/java/com/book/backend/domain/opentalk/controller/OpentalkController.java @@ -52,10 +52,10 @@ public ResponseEntity opentalkMain() throws Exception { // [오픈톡 참여하기] - @Operation(summary="오픈톡 참여하기", description="isbn, pageSize를 입력으로 받아, 오픈톡 ID, 채팅 내역 반환", + @Operation(summary="오픈톡 참여하기", description="isbn, pageSize를 입력으로 받아 오픈톡 ID, 즐찾여부, 채팅 내역 반환", parameters = {@Parameter(name = "isbn", description = "책 ISBN"), @Parameter(name = "pageSize", description = "페이지 당 개수")}, - responses = {@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OpentalkResponseDto.class)), - description = OpentalkResponseDto.description)}) + responses = {@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OpentalkJoinResponseDto.class)), + description = OpentalkJoinResponseDto.description)}) @PostMapping("/join") public ResponseEntity joinOpentalk(@RequestParam String isbn, int pageSize) { RequestLogger.param(new String[]{"isbn"}, isbn); diff --git a/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkDto.java b/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkDto.java index eb5893ca..b3fbe961 100644 --- a/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkDto.java +++ b/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkDto.java @@ -9,6 +9,7 @@ @Setter public class OpentalkDto { private Long id; + private String isbn13; private String bookName; private String bookImageURL; } diff --git a/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkJoinResponseDto.java b/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkJoinResponseDto.java index 6d474e60..2404cf6a 100644 --- a/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkJoinResponseDto.java +++ b/src/main/java/com/book/backend/domain/opentalk/dto/OpentalkJoinResponseDto.java @@ -10,5 +10,8 @@ @Builder public class OpentalkJoinResponseDto { private final Long opentalkId; + private final boolean isFavorite; //즐찾 여부 private final List messageResponseDto; //nullable + + public static final String description = "opentalkId : 오픈톡 DB ID | isFavorite : 즐찾여부 | messageResponseDto : 0번째 페이지의 채팅 리스트"; } diff --git a/src/main/java/com/book/backend/domain/opentalk/service/OpentalkResponseParser.java b/src/main/java/com/book/backend/domain/opentalk/service/OpentalkResponseParser.java index be07662f..07477d72 100644 --- a/src/main/java/com/book/backend/domain/opentalk/service/OpentalkResponseParser.java +++ b/src/main/java/com/book/backend/domain/opentalk/service/OpentalkResponseParser.java @@ -13,6 +13,7 @@ public class OpentalkResponseParser { public void setSimpleBookInfo(OpentalkDto opentalkDto, DetailResponseDto responseDto){ log.trace("OpentalkResponseParser > setSimpleBookInfo()"); + opentalkDto.setIsbn13(responseDto.getBookInfoDto().getIsbn13()); opentalkDto.setBookName(responseDto.getBookInfoDto().getBookname()); opentalkDto.setBookImageURL(responseDto.getBookInfoDto().getBookImageURL()); } diff --git a/src/main/java/com/book/backend/domain/opentalk/service/OpentalkService.java b/src/main/java/com/book/backend/domain/opentalk/service/OpentalkService.java index c288d761..a7f352cc 100644 --- a/src/main/java/com/book/backend/domain/opentalk/service/OpentalkService.java +++ b/src/main/java/com/book/backend/domain/opentalk/service/OpentalkService.java @@ -139,12 +139,17 @@ public OpentalkJoinResponseDto joinOpentalk(String isbn, int pageSize){ Long opentalkId = checkExistOpentalk(isbn); if(opentalkId == null){ opentalkId = createOpentalkIdByIsbn(isbn); - return OpentalkJoinResponseDto.builder().opentalkId(opentalkId).messageResponseDto(null).build(); + return OpentalkJoinResponseDto.builder().opentalkId(opentalkId).messageResponseDto(null).isFavorite(false).build(); } Pageable pageRequest = PageRequest.of(0, pageSize, Sort.by("createdAt").descending()); Page messagePage = messageService.getMessage(opentalkId, pageRequest); List response = messageService.pageToDto(messagePage); - return OpentalkJoinResponseDto.builder().opentalkId(opentalkId).messageResponseDto(response).build(); + + // 즐찾 여부 + UserOpentalk userOpentalk= userOpentalkRepository.findByUserIdAndOpentalkId(userService.loadLoggedinUser(), opentalkRepository.findById(opentalkId).get()); + boolean isFavorite = userOpentalk != null; + + return OpentalkJoinResponseDto.builder().opentalkId(opentalkId).messageResponseDto(response).isFavorite(isFavorite).build(); } @Transactional