From 60a4f6c099167f5b43f0414ec30c77f1b31275cd Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 02:08:03 +0900 Subject: [PATCH 01/26] =?UTF-8?q?add:=20BooktalkCreateRequestDto,=20Respon?= =?UTF-8?q?seDto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/BooktalkRequestDto.java | 56 +++++++++++++++++++ .../response/BooktalkCreateResponseDto.java | 17 ++++++ 2 files changed, 73 insertions(+) create mode 100644 src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java create mode 100644 src/main/java/org/sophy/sophy/controller/dto/response/BooktalkCreateResponseDto.java diff --git a/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java b/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java new file mode 100644 index 0000000..7d57d91 --- /dev/null +++ b/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java @@ -0,0 +1,56 @@ +package org.sophy.sophy.controller.dto.request; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.sophy.sophy.domain.*; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class BooktalkRequestDto { + @NotNull + private Long memberId; + @NotNull + private Long placeId; + + private String booktalkImageUrl; + @NotBlank + private String title; + @NotNull + private BookCategory bookCategory; + @NotNull + private Long bookId; //TODO 추후 연결 + @NotNull + private LocalDateTime startDate; //TODO 시작 시간은 오늘날짜 이전은 안되도록? + @NotNull + private LocalDateTime endDate; + @NotNull + private Integer participant; + @NotNull + private Integer participationFee; + @NotNull + private PreliminaryInfo preliminaryInfo; + @NotBlank + private String description; + + public Booktalk toBooktalk(Place place, Member member) { + return Booktalk.builder() + .place(place) + .title(title) + .booktalkImageUrl(booktalkImageUrl) + .member(member) + .bookCategory(bookCategory) + .startDate(startDate) + .endDate(endDate) + .maximum(participant) + .participationFee(participationFee) + .preliminaryInfo(preliminaryInfo) + .description(description) + .booktalkStatus(BooktalkStatus.APPLYING).build(); + } + +} diff --git a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkCreateResponseDto.java b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkCreateResponseDto.java new file mode 100644 index 0000000..2a369e8 --- /dev/null +++ b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkCreateResponseDto.java @@ -0,0 +1,17 @@ +package org.sophy.sophy.controller.dto.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.sophy.sophy.domain.Booktalk; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class BooktalkCreateResponseDto { + private Long booktalkId; + private String title; + + public static BooktalkCreateResponseDto of(Booktalk booktalk) { + return new BooktalkCreateResponseDto(booktalk.getId(), booktalk.getTitle()); + } +} From 43cdfc379312ef01e8a54aca9a62ed90043873b6 Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 02:08:50 +0900 Subject: [PATCH 02/26] =?UTF-8?q?feat:=20POST=20=EB=B6=81=ED=86=A0?= =?UTF-8?q?=ED=81=AC=20=EC=83=9D=EC=84=B1=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/controller/BooktalkController.java | 26 ++++++++++++++ .../sophy/sophy/exception/ErrorStatus.java | 1 + .../sophy/sophy/exception/SuccessStatus.java | 3 +- .../infrastructure/BooktalkRepository.java | 9 +++++ .../sophy/sophy/service/BooktalkService.java | 35 +++++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/sophy/sophy/controller/BooktalkController.java create mode 100644 src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java create mode 100644 src/main/java/org/sophy/sophy/service/BooktalkService.java diff --git a/src/main/java/org/sophy/sophy/controller/BooktalkController.java b/src/main/java/org/sophy/sophy/controller/BooktalkController.java new file mode 100644 index 0000000..dd60736 --- /dev/null +++ b/src/main/java/org/sophy/sophy/controller/BooktalkController.java @@ -0,0 +1,26 @@ +package org.sophy.sophy.controller; + +import lombok.RequiredArgsConstructor; +import org.sophy.sophy.common.dto.ApiResponseDto; +import org.sophy.sophy.controller.dto.request.BooktalkRequestDto; +import org.sophy.sophy.controller.dto.response.BooktalkCreateResponseDto; +import org.sophy.sophy.exception.SuccessStatus; +import org.sophy.sophy.service.BooktalkService; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/booktalk") +public class BooktalkController { + private final BooktalkService booktalkService; + + @PostMapping + @ResponseStatus(HttpStatus.CREATED) + public ApiResponseDto createBooktalk(@Valid @RequestBody BooktalkRequestDto booktalkRequestDto) { + return ApiResponseDto.success(SuccessStatus.CREATE_BOOKTALK_SUCCESS, booktalkService.createBooktalk(booktalkRequestDto)); + } + +} diff --git a/src/main/java/org/sophy/sophy/exception/ErrorStatus.java b/src/main/java/org/sophy/sophy/exception/ErrorStatus.java index 4e82687..6983fde 100644 --- a/src/main/java/org/sophy/sophy/exception/ErrorStatus.java +++ b/src/main/java/org/sophy/sophy/exception/ErrorStatus.java @@ -29,6 +29,7 @@ public enum ErrorStatus { NOT_FOUND_SAVE_IMAGE_EXCEPTION(HttpStatus.NOT_FOUND, "이미지 저장에 실패했습니다"), NOT_FOUND_IMAGE_EXCEPTION(HttpStatus.NOT_FOUND, "이미지 이름을 찾을 수 없습니다"), NOT_FOUND_CITY_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 지역입니다"), + NOT_FOUND_PLACE_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 공간입니다"), /** * 409 CONFLICT diff --git a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java index 705293d..b3d5d74 100644 --- a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java +++ b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java @@ -18,12 +18,13 @@ public enum SuccessStatus { GET_MYINFO_SUCCESS(HttpStatus.OK, "내 정보를 성공적으로 불러왔습니다."), PATCH_MYINFO_SUCCESS(HttpStatus.OK, "내 정보를 성공적으로 수정했습니다."), POST_ADDITIONALINFO_SUCCESS(HttpStatus.OK, "내 정보를 성공적으로 추가했습니다."), - GET_PLACES_BY_CITY_SUCCESS(HttpStatus.OK, "지역으로 공간 리스트를 성공적으로 불러왔습니다"), + GET_PLACES_BY_CITY_SUCCESS(HttpStatus.OK, "지역으로 공간 리스트를 성공적으로 불러왔습니다."), TEST_SUCCESS(HttpStatus.OK, "Test :: OK"), /* * 201 created */ SIGNUP_SUCCESS(HttpStatus.CREATED, "회원가입이 완료되었습니다."), + CREATE_BOOKTALK_SUCCESS(HttpStatus.CREATED, "북토크를 생성했습니다."), ; private final HttpStatus httpStatus; diff --git a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java new file mode 100644 index 0000000..8bff4fd --- /dev/null +++ b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java @@ -0,0 +1,9 @@ +package org.sophy.sophy.infrastructure; + +import org.sophy.sophy.domain.Booktalk; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface BooktalkRepository extends JpaRepository { +} diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java new file mode 100644 index 0000000..9a23173 --- /dev/null +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -0,0 +1,35 @@ +package org.sophy.sophy.service; + +import lombok.RequiredArgsConstructor; +import org.sophy.sophy.controller.dto.request.BooktalkRequestDto; +import org.sophy.sophy.controller.dto.response.BooktalkCreateResponseDto; +import org.sophy.sophy.domain.Booktalk; +import org.sophy.sophy.domain.Member; +import org.sophy.sophy.domain.Place; +import org.sophy.sophy.exception.ErrorStatus; +import org.sophy.sophy.exception.model.NotFoundException; +import org.sophy.sophy.infrastructure.BooktalkRepository; +import org.sophy.sophy.infrastructure.MemberRepository; +import org.sophy.sophy.infrastructure.PlaceRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class BooktalkService { + private final BooktalkRepository booktalkRepository; + private final PlaceRepository placeRepository; + private final MemberRepository memberRepository; + + @Transactional + public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkRequestDto) { + Place place = placeRepository.findById(booktalkRequestDto.getPlaceId()) + .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_PLACE_EXCEPTION, ErrorStatus.NOT_FOUND_PLACE_EXCEPTION.getMessage())); + //작가인지 확인할 필요가 있는지? + Member member = memberRepository.findById(booktalkRequestDto.getMemberId()) + .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_USER_EXCEPTION, ErrorStatus.NOT_FOUND_USER_EXCEPTION.getMessage())); + + Booktalk booktalk = booktalkRequestDto.toBooktalk(place, member); + return BooktalkCreateResponseDto.of(booktalkRepository.save(booktalk)); + } +} From 72c4a167c74b1dcd86bf8f4fe7605d6b10fda33f Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 04:11:12 +0900 Subject: [PATCH 03/26] =?UTF-8?q?add:=20BooktalkUpdateDto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/dto/BooktalkUpdateDto.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/org/sophy/sophy/controller/dto/BooktalkUpdateDto.java diff --git a/src/main/java/org/sophy/sophy/controller/dto/BooktalkUpdateDto.java b/src/main/java/org/sophy/sophy/controller/dto/BooktalkUpdateDto.java new file mode 100644 index 0000000..621e456 --- /dev/null +++ b/src/main/java/org/sophy/sophy/controller/dto/BooktalkUpdateDto.java @@ -0,0 +1,37 @@ +package org.sophy.sophy.controller.dto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.sophy.sophy.domain.BookCategory; +import org.sophy.sophy.domain.PreliminaryInfo; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class BooktalkUpdateDto { + @NotNull + private Long placeId; + private String booktalkImageUrl; + @NotBlank + private String title; + @NotNull + private BookCategory bookCategory; + @NotNull + private Long bookId; //TODO 추후 연결 + @NotNull + private LocalDateTime startDate; //TODO 시작 시간은 오늘날짜 이전은 안되도록? + @NotNull + private LocalDateTime endDate; + @NotNull + private Integer participant; + @NotNull + private Integer participationFee; + @NotNull + private PreliminaryInfo preliminaryInfo; + @NotBlank + private String description; +} From c65925295315154dcfa71760e2a97453f82a7095 Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 04:12:28 +0900 Subject: [PATCH 04/26] =?UTF-8?q?modify:=20Booktalk=EC=97=90=20patchBookta?= =?UTF-8?q?lk=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/Booktalk.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/sophy/sophy/domain/Booktalk.java b/src/main/java/org/sophy/sophy/domain/Booktalk.java index 1eaa792..8cbe85d 100644 --- a/src/main/java/org/sophy/sophy/domain/Booktalk.java +++ b/src/main/java/org/sophy/sophy/domain/Booktalk.java @@ -3,6 +3,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.sophy.sophy.controller.dto.BooktalkUpdateDto; import javax.persistence.*; import java.time.LocalDateTime; @@ -100,4 +101,16 @@ public Booktalk(Place place, String title, String booktalkImageUrl, Member membe this.booktalkStatus = booktalkStatus; this.participantList = new ArrayList<>(); } + + public void patchBooktalk(BooktalkUpdateDto booktalkUpdateDto) { + this.title = booktalkUpdateDto.getTitle(); + this.booktalkImageUrl = booktalkUpdateDto.getBooktalkImageUrl(); + this.bookCategory = booktalkUpdateDto.getBookCategory(); + this.startDate = booktalkUpdateDto.getStartDate(); + this.endDate = booktalkUpdateDto.getEndDate(); + this.maximum = booktalkUpdateDto.getParticipant(); + this.participationFee = booktalkUpdateDto.getParticipationFee(); + this.preliminaryInfo = booktalkUpdateDto.getPreliminaryInfo(); + this.description = booktalkUpdateDto.getDescription(); + } } \ No newline at end of file From 759e0d2b4664e51d833cf4d48680c59f5e62c14c Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 04:13:03 +0900 Subject: [PATCH 05/26] =?UTF-8?q?feat:=20PATCH=20=EB=B6=81=ED=86=A0?= =?UTF-8?q?=ED=81=AC=20=EC=88=98=EC=A0=95=ED=95=98=EA=B8=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/controller/BooktalkController.java | 9 ++++++ .../sophy/sophy/exception/ErrorStatus.java | 1 + .../sophy/sophy/exception/SuccessStatus.java | 1 + .../sophy/sophy/service/BooktalkService.java | 30 +++++++++++++++---- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/sophy/sophy/controller/BooktalkController.java b/src/main/java/org/sophy/sophy/controller/BooktalkController.java index dd60736..d9ea980 100644 --- a/src/main/java/org/sophy/sophy/controller/BooktalkController.java +++ b/src/main/java/org/sophy/sophy/controller/BooktalkController.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import org.sophy.sophy.common.dto.ApiResponseDto; import org.sophy.sophy.controller.dto.request.BooktalkRequestDto; +import org.sophy.sophy.controller.dto.BooktalkUpdateDto; import org.sophy.sophy.controller.dto.response.BooktalkCreateResponseDto; import org.sophy.sophy.exception.SuccessStatus; import org.sophy.sophy.service.BooktalkService; @@ -23,4 +24,12 @@ public ApiResponseDto createBooktalk(@Valid @RequestB return ApiResponseDto.success(SuccessStatus.CREATE_BOOKTALK_SUCCESS, booktalkService.createBooktalk(booktalkRequestDto)); } + @PatchMapping("/{booktalkId}") + @ResponseStatus(HttpStatus.OK) + public ApiResponseDto updateBooktalk(@PathVariable("booktalkId") Long booktalkId, @Valid @RequestBody BooktalkUpdateDto booktalkUpdateDto) { + return ApiResponseDto.success(SuccessStatus.PATCH_BOOKTALK_SUCCESS, booktalkService.updateBooktalk(booktalkId, booktalkUpdateDto)); + } + + + } diff --git a/src/main/java/org/sophy/sophy/exception/ErrorStatus.java b/src/main/java/org/sophy/sophy/exception/ErrorStatus.java index 6983fde..737d1ab 100644 --- a/src/main/java/org/sophy/sophy/exception/ErrorStatus.java +++ b/src/main/java/org/sophy/sophy/exception/ErrorStatus.java @@ -30,6 +30,7 @@ public enum ErrorStatus { NOT_FOUND_IMAGE_EXCEPTION(HttpStatus.NOT_FOUND, "이미지 이름을 찾을 수 없습니다"), NOT_FOUND_CITY_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 지역입니다"), NOT_FOUND_PLACE_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 공간입니다"), + NOT_FOUND_BOOKTALK_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 북토크입니다"), /** * 409 CONFLICT diff --git a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java index b3d5d74..991c3a2 100644 --- a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java +++ b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java @@ -19,6 +19,7 @@ public enum SuccessStatus { PATCH_MYINFO_SUCCESS(HttpStatus.OK, "내 정보를 성공적으로 수정했습니다."), POST_ADDITIONALINFO_SUCCESS(HttpStatus.OK, "내 정보를 성공적으로 추가했습니다."), GET_PLACES_BY_CITY_SUCCESS(HttpStatus.OK, "지역으로 공간 리스트를 성공적으로 불러왔습니다."), + PATCH_BOOKTALK_SUCCESS(HttpStatus.OK, "북토크를 성공적으로 수정했습니다."), TEST_SUCCESS(HttpStatus.OK, "Test :: OK"), /* * 201 created diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index 9a23173..0fdbc5c 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -2,6 +2,7 @@ import lombok.RequiredArgsConstructor; import org.sophy.sophy.controller.dto.request.BooktalkRequestDto; +import org.sophy.sophy.controller.dto.BooktalkUpdateDto; import org.sophy.sophy.controller.dto.response.BooktalkCreateResponseDto; import org.sophy.sophy.domain.Booktalk; import org.sophy.sophy.domain.Member; @@ -23,13 +24,32 @@ public class BooktalkService { @Transactional public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkRequestDto) { - Place place = placeRepository.findById(booktalkRequestDto.getPlaceId()) - .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_PLACE_EXCEPTION, ErrorStatus.NOT_FOUND_PLACE_EXCEPTION.getMessage())); + Place place = getPlaceById(booktalkRequestDto.getPlaceId()); //작가인지 확인할 필요가 있는지? - Member member = memberRepository.findById(booktalkRequestDto.getMemberId()) - .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_USER_EXCEPTION, ErrorStatus.NOT_FOUND_USER_EXCEPTION.getMessage())); - + Member member = getMemberById(booktalkRequestDto.getMemberId()); Booktalk booktalk = booktalkRequestDto.toBooktalk(place, member); return BooktalkCreateResponseDto.of(booktalkRepository.save(booktalk)); } + + @Transactional + public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto booktalkUpdateDto) { + Booktalk booktalk = booktalkRepository.findById(booktalkId) + .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION, ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION.getMessage())); + if (booktalkUpdateDto.getPlaceId() != booktalk.getPlace().getId()) { + Place place = getPlaceById(booktalkUpdateDto.getPlaceId()); + booktalk.setPlace(place); + } + booktalk.patchBooktalk(booktalkUpdateDto); + return booktalkUpdateDto; + } + + private Member getMemberById(Long memberId) { + return memberRepository.findById(memberId) + .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_USER_EXCEPTION, ErrorStatus.NOT_FOUND_USER_EXCEPTION.getMessage())); + } + + private Place getPlaceById(Long placeId) { + return placeRepository.findById(placeId) + .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_PLACE_EXCEPTION, ErrorStatus.NOT_FOUND_PLACE_EXCEPTION.getMessage())); + } } From 3a7b5bb34303cb6ba6913436a6047a27b580dfd9 Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 05:31:07 +0900 Subject: [PATCH 06/26] =?UTF-8?q?fix:=20=EB=B6=81=ED=86=A0=ED=81=AC=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=20member=EC=99=80=20place=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/controller/dto/request/BooktalkRequestDto.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java b/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java index 7d57d91..4561f79 100644 --- a/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java +++ b/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java @@ -39,10 +39,8 @@ public class BooktalkRequestDto { public Booktalk toBooktalk(Place place, Member member) { return Booktalk.builder() - .place(place) .title(title) .booktalkImageUrl(booktalkImageUrl) - .member(member) .bookCategory(bookCategory) .startDate(startDate) .endDate(endDate) @@ -50,7 +48,10 @@ public Booktalk toBooktalk(Place place, Member member) { .participationFee(participationFee) .preliminaryInfo(preliminaryInfo) .description(description) - .booktalkStatus(BooktalkStatus.APPLYING).build(); + .booktalkStatus(BooktalkStatus.APPLYING) + .member(member) + .place(place) + .build(); } } From 85efa8711547541329814199c0244d53e688a0ae Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 05:31:37 +0900 Subject: [PATCH 07/26] =?UTF-8?q?add:=20BooktalkDeleteResponseDto=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/BooktalkDeleteResponseDto.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDeleteResponseDto.java diff --git a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDeleteResponseDto.java b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDeleteResponseDto.java new file mode 100644 index 0000000..9b812e1 --- /dev/null +++ b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDeleteResponseDto.java @@ -0,0 +1,15 @@ +package org.sophy.sophy.controller.dto.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class BooktalkDeleteResponseDto { + private Long booktalkId; + + public static BooktalkDeleteResponseDto of(Long booktalkId) { + return new BooktalkDeleteResponseDto(booktalkId); + } +} From 968c91e84eabbdb906c4a44c270738f60b5d010a Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 05:32:17 +0900 Subject: [PATCH 08/26] =?UTF-8?q?modify:=20Author=EC=99=80=20Booktalk?= =?UTF-8?q?=EC=97=90=20deleteBooktalk=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/Author.java | 4 ++++ src/main/java/org/sophy/sophy/domain/Booktalk.java | 2 +- src/main/java/org/sophy/sophy/domain/Place.java | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sophy/sophy/domain/Author.java b/src/main/java/org/sophy/sophy/domain/Author.java index cf116a9..7bf0025 100644 --- a/src/main/java/org/sophy/sophy/domain/Author.java +++ b/src/main/java/org/sophy/sophy/domain/Author.java @@ -24,4 +24,8 @@ public class Author { //private List myBookList private Integer matchingBookTalkCount; private Integer recruitBookTalkCount; + + public void deleteBooktalk(Booktalk booktalk) { + myBookTalkList.remove(booktalk); + } } diff --git a/src/main/java/org/sophy/sophy/domain/Booktalk.java b/src/main/java/org/sophy/sophy/domain/Booktalk.java index 8cbe85d..b8d36b8 100644 --- a/src/main/java/org/sophy/sophy/domain/Booktalk.java +++ b/src/main/java/org/sophy/sophy/domain/Booktalk.java @@ -90,7 +90,7 @@ public Booktalk(Place place, String title, String booktalkImageUrl, Member membe setPlace(place); this.title = title; this.booktalkImageUrl = booktalkImageUrl; - this.member = member; + setMember(member); this.bookCategory = bookCategory; this.startDate = startDate; this.endDate = endDate; diff --git a/src/main/java/org/sophy/sophy/domain/Place.java b/src/main/java/org/sophy/sophy/domain/Place.java index 1b76ab6..36cf04e 100644 --- a/src/main/java/org/sophy/sophy/domain/Place.java +++ b/src/main/java/org/sophy/sophy/domain/Place.java @@ -46,4 +46,8 @@ public Place(City city, String name, String address, Integer maximum, String pla this.placeImage = placeImage; this.booktalkList = new ArrayList<>(); } + + public void deleteBooktalk(Booktalk booktalk) { + booktalkList.remove(booktalk); + } } From 3f1aeba7da67cee61e9f781c6fa3ae84e2fa609c Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 05:32:34 +0900 Subject: [PATCH 09/26] =?UTF-8?q?feat:=20DELETE=20=EB=B6=81=ED=86=A0?= =?UTF-8?q?=ED=81=AC=20=EC=82=AD=EC=A0=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/controller/BooktalkController.java | 9 ++++++-- .../sophy/sophy/exception/SuccessStatus.java | 1 + .../sophy/sophy/service/BooktalkService.java | 21 ++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/sophy/sophy/controller/BooktalkController.java b/src/main/java/org/sophy/sophy/controller/BooktalkController.java index d9ea980..1de8ad6 100644 --- a/src/main/java/org/sophy/sophy/controller/BooktalkController.java +++ b/src/main/java/org/sophy/sophy/controller/BooktalkController.java @@ -2,9 +2,10 @@ import lombok.RequiredArgsConstructor; import org.sophy.sophy.common.dto.ApiResponseDto; -import org.sophy.sophy.controller.dto.request.BooktalkRequestDto; import org.sophy.sophy.controller.dto.BooktalkUpdateDto; +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.exception.SuccessStatus; import org.sophy.sophy.service.BooktalkService; import org.springframework.http.HttpStatus; @@ -30,6 +31,10 @@ public ApiResponseDto updateBooktalk(@PathVariable("booktalkI return ApiResponseDto.success(SuccessStatus.PATCH_BOOKTALK_SUCCESS, booktalkService.updateBooktalk(booktalkId, booktalkUpdateDto)); } - + @DeleteMapping("/{booktalkId}") + @ResponseStatus(HttpStatus.OK) + public ApiResponseDto deleteBooktalk(@PathVariable("booktalkId") Long booktalkId) { + return ApiResponseDto.success(SuccessStatus.DELETE_BOOKTALK_SUCCESS, booktalkService.deleteBooktalk(booktalkId)); + } } diff --git a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java index 991c3a2..f29ea3c 100644 --- a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java +++ b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java @@ -20,6 +20,7 @@ public enum SuccessStatus { POST_ADDITIONALINFO_SUCCESS(HttpStatus.OK, "내 정보를 성공적으로 추가했습니다."), GET_PLACES_BY_CITY_SUCCESS(HttpStatus.OK, "지역으로 공간 리스트를 성공적으로 불러왔습니다."), PATCH_BOOKTALK_SUCCESS(HttpStatus.OK, "북토크를 성공적으로 수정했습니다."), + DELETE_BOOKTALK_SUCCESS(HttpStatus.OK, "북토크를 성공적으로 삭제했습니다."), TEST_SUCCESS(HttpStatus.OK, "Test :: OK"), /* * 201 created diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index 0fdbc5c..55a6972 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -1,9 +1,10 @@ package org.sophy.sophy.service; import lombok.RequiredArgsConstructor; -import org.sophy.sophy.controller.dto.request.BooktalkRequestDto; import org.sophy.sophy.controller.dto.BooktalkUpdateDto; +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.domain.Booktalk; import org.sophy.sophy.domain.Member; import org.sophy.sophy.domain.Place; @@ -33,8 +34,7 @@ public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkReque @Transactional public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto booktalkUpdateDto) { - Booktalk booktalk = booktalkRepository.findById(booktalkId) - .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION, ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION.getMessage())); + Booktalk booktalk = getBooktalkById(booktalkId); if (booktalkUpdateDto.getPlaceId() != booktalk.getPlace().getId()) { Place place = getPlaceById(booktalkUpdateDto.getPlaceId()); booktalk.setPlace(place); @@ -43,6 +43,16 @@ public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto bookt return booktalkUpdateDto; } + public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { + Booktalk booktalk = getBooktalkById(booktalkId); + //TODO soft delete? + //공간이 거절 됐거나 공간 매칭중일 때만 삭제가능 + booktalk.getPlace().deleteBooktalk(booktalk); + booktalk.getMember().getAuthor().deleteBooktalk(booktalk); + booktalkRepository.deleteById(booktalkId); + return BooktalkDeleteResponseDto.of(booktalkId); + } + private Member getMemberById(Long memberId) { return memberRepository.findById(memberId) .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_USER_EXCEPTION, ErrorStatus.NOT_FOUND_USER_EXCEPTION.getMessage())); @@ -52,4 +62,9 @@ private Place getPlaceById(Long placeId) { return placeRepository.findById(placeId) .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_PLACE_EXCEPTION, ErrorStatus.NOT_FOUND_PLACE_EXCEPTION.getMessage())); } + + private Booktalk getBooktalkById(Long booktalkId) { + return booktalkRepository.findById(booktalkId) + .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION, ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION.getMessage())); + } } From 0135e6fb1a690a5e134fedaeb9ee67445449690c Mon Sep 17 00:00:00 2001 From: onpyeong Date: Tue, 11 Jul 2023 05:51:50 +0900 Subject: [PATCH 10/26] =?UTF-8?q?feat:=20GET=20=EB=B6=81=ED=86=A0=ED=81=AC?= =?UTF-8?q?=20=EC=83=81=EC=84=B8=EC=A1=B0=ED=9A=8C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/controller/BooktalkController.java | 6 +++ .../response/BooktalkDetailResponseDto.java | 46 +++++++++++++++++++ .../sophy/sophy/exception/SuccessStatus.java | 1 + .../sophy/sophy/service/BooktalkService.java | 7 +++ 4 files changed, 60 insertions(+) create mode 100644 src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java diff --git a/src/main/java/org/sophy/sophy/controller/BooktalkController.java b/src/main/java/org/sophy/sophy/controller/BooktalkController.java index 1de8ad6..753d089 100644 --- a/src/main/java/org/sophy/sophy/controller/BooktalkController.java +++ b/src/main/java/org/sophy/sophy/controller/BooktalkController.java @@ -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; @@ -37,4 +38,9 @@ public ApiResponseDto deleteBooktalk(@PathVariable("b return ApiResponseDto.success(SuccessStatus.DELETE_BOOKTALK_SUCCESS, booktalkService.deleteBooktalk(booktalkId)); } + @GetMapping("/{booktalkId}/detail") + public ApiResponseDto getBooktalkDetail(@PathVariable("booktalkId") Long booktalkId) { + return ApiResponseDto.success(SuccessStatus.GET_BOOKTALK_DETAIL_SUCCESS, booktalkService.getBooktalkDetail(booktalkId)); + } + } diff --git a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java new file mode 100644 index 0000000..3dc0078 --- /dev/null +++ b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java @@ -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() + ); + } +} diff --git a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java index f29ea3c..fdef64f 100644 --- a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java +++ b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java @@ -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 diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index 55a6972..e9ca221 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -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; @@ -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? @@ -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())); From 219179c979967f77cad042bb670937624dd96c27 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 10:12:48 +0900 Subject: [PATCH 11/26] =?UTF-8?q?refactor:=20=EC=9B=90=EC=8B=9C=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/Booktalk.java | 2 +- src/main/java/org/sophy/sophy/domain/Member.java | 14 ++++++-------- src/main/java/org/sophy/sophy/domain/Place.java | 5 +++-- .../java/org/sophy/sophy/domain/dto/MyInfoDto.java | 4 +--- .../org/sophy/sophy/service/MemberService.java | 4 ++-- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/sophy/sophy/domain/Booktalk.java b/src/main/java/org/sophy/sophy/domain/Booktalk.java index b8d36b8..a2d93e0 100644 --- a/src/main/java/org/sophy/sophy/domain/Booktalk.java +++ b/src/main/java/org/sophy/sophy/domain/Booktalk.java @@ -17,7 +17,7 @@ public class Booktalk extends AuditingTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "booktalk_id") - private long id; + private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn diff --git a/src/main/java/org/sophy/sophy/domain/Member.java b/src/main/java/org/sophy/sophy/domain/Member.java index bd5bda7..471165a 100644 --- a/src/main/java/org/sophy/sophy/domain/Member.java +++ b/src/main/java/org/sophy/sophy/domain/Member.java @@ -1,8 +1,6 @@ package org.sophy.sophy.domain; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; import org.sophy.sophy.controller.dto.request.MemberAdditionalInfoDto; import org.sophy.sophy.domain.dto.MyInfoDto; @@ -13,7 +11,7 @@ @Entity @Getter -@NoArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Member extends AuditingTimeEntity{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -38,13 +36,13 @@ public class Member extends AuditingTimeEntity{ private City myCity; - private boolean marketingAgree; + private Boolean marketingAgree; @Column(nullable = false) - private boolean isAuthor; + private Boolean isAuthor; @Column(nullable = false) - private boolean isOperator; + private Boolean isOperator; @Enumerated(EnumType.STRING) private Authority authority; @@ -95,6 +93,6 @@ public void patchMyInfo(MyInfoDto myInfoDto) { this.gender = myInfoDto.getGender(); this.birth = myInfoDto.getBirth(); this.myCity = myInfoDto.getCity(); - this.marketingAgree = myInfoDto.isMarketingAgree(); + this.marketingAgree = myInfoDto.getMarketingAgree(); } } diff --git a/src/main/java/org/sophy/sophy/domain/Place.java b/src/main/java/org/sophy/sophy/domain/Place.java index 36cf04e..095fcc4 100644 --- a/src/main/java/org/sophy/sophy/domain/Place.java +++ b/src/main/java/org/sophy/sophy/domain/Place.java @@ -1,5 +1,6 @@ package org.sophy.sophy.domain; +import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,11 +11,11 @@ @Entity @Getter -@NoArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Place extends AuditingTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private long id; + private Long id; private City city; diff --git a/src/main/java/org/sophy/sophy/domain/dto/MyInfoDto.java b/src/main/java/org/sophy/sophy/domain/dto/MyInfoDto.java index 2ce3875..4e42e5d 100644 --- a/src/main/java/org/sophy/sophy/domain/dto/MyInfoDto.java +++ b/src/main/java/org/sophy/sophy/domain/dto/MyInfoDto.java @@ -3,7 +3,6 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import lombok.NoArgsConstructor; import org.sophy.sophy.domain.City; import javax.validation.constraints.Email; @@ -11,7 +10,6 @@ @Getter @AllArgsConstructor -@NoArgsConstructor @Builder public class MyInfoDto { @Email(message = "이메일 형식에 맞지 않습니다.") @@ -23,5 +21,5 @@ public class MyInfoDto { private String gender; private String birth; private City city; - private boolean marketingAgree; + private Boolean marketingAgree; } diff --git a/src/main/java/org/sophy/sophy/service/MemberService.java b/src/main/java/org/sophy/sophy/service/MemberService.java index 193f6c9..f9570a4 100644 --- a/src/main/java/org/sophy/sophy/service/MemberService.java +++ b/src/main/java/org/sophy/sophy/service/MemberService.java @@ -21,7 +21,7 @@ public class MemberService { public MyPageDto getMyPage(Long memberId) { Member member = getMemberById(memberId); //여기에 추가로 member에 있는 userBookTalk 리스트를 시간순으로 정렬해 가장 마감이 임박한 booktalk도 보여줌 - if(member.isAuthor()){ + if(member.getIsAuthor()){ return MyPageDto.builder() .name(member.getName()) .bookCount(member.getBookCount()) @@ -47,7 +47,7 @@ public MyInfoDto getMyInfo(Long memberId) { .gender(member.getGender()) .birth(member.getBirth()) .city(member.getMyCity()) - .marketingAgree(member.isMarketingAgree()) + .marketingAgree(member.getMarketingAgree()) .build(); } @Transactional From 7b5fb140ba24ce3893668d0e31ff309eb74e23f2 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 10:13:09 +0900 Subject: [PATCH 12/26] =?UTF-8?q?refactor:=20access=20level=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/Author.java | 9 ++------- src/main/java/org/sophy/sophy/domain/MemberBooktalk.java | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/sophy/sophy/domain/Author.java b/src/main/java/org/sophy/sophy/domain/Author.java index 7bf0025..ccfc112 100644 --- a/src/main/java/org/sophy/sophy/domain/Author.java +++ b/src/main/java/org/sophy/sophy/domain/Author.java @@ -1,18 +1,13 @@ package org.sophy.sophy.domain; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; import javax.persistence.*; import java.util.List; @Entity @Getter -@NoArgsConstructor -@AllArgsConstructor -@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Author { @Id @GeneratedValue diff --git a/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java b/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java index 626025b..44b95ef 100644 --- a/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java +++ b/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java @@ -1,5 +1,6 @@ package org.sophy.sophy.domain; +import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -8,7 +9,7 @@ @Entity @Getter -@NoArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class MemberBooktalk extends AuditingTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) From 887229d14c70d6f0618a0f64197be51c28b37635 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 10:18:17 +0900 Subject: [PATCH 13/26] =?UTF-8?q?refactor:=20=EC=9B=90=EC=8B=9C=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/sophy/sophy/controller/MemberController.java | 8 ++++---- src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/sophy/sophy/controller/MemberController.java b/src/main/java/org/sophy/sophy/controller/MemberController.java index 7a75e2d..ceed71b 100644 --- a/src/main/java/org/sophy/sophy/controller/MemberController.java +++ b/src/main/java/org/sophy/sophy/controller/MemberController.java @@ -18,25 +18,25 @@ public class MemberController { @GetMapping("/my-page/{memberId}") @ResponseStatus(HttpStatus.OK) - public ApiResponseDto getMyPage(@PathVariable("memberId") long memberId) { + public ApiResponseDto getMyPage(@PathVariable("memberId") Long memberId) { return ApiResponseDto.success(SuccessStatus.GET_MYPAGE_SUCCESS, memberService.getMyPage(memberId)); } @GetMapping("/my-info/{memberId}") @ResponseStatus(HttpStatus.OK) - public ApiResponseDto getInfo(@PathVariable("memberId") long memberId) { + public ApiResponseDto getInfo(@PathVariable("memberId") Long memberId) { return ApiResponseDto.success(SuccessStatus.GET_MYPAGE_SUCCESS, memberService.getMyInfo(memberId)); } @PostMapping("/my-info/{memberId}") @ResponseStatus(HttpStatus.OK) - public ApiResponseDto postAdditionalInfo(@PathVariable("memberId") long memberId, @RequestBody MemberAdditionalInfoDto memberAdditionalInfoDto) { + public ApiResponseDto postAdditionalInfo(@PathVariable("memberId") Long memberId, @RequestBody MemberAdditionalInfoDto memberAdditionalInfoDto) { return ApiResponseDto.success(SuccessStatus.POST_ADDITIONALINFO_SUCCESS, memberService.postAdditionalInfo(memberId, memberAdditionalInfoDto)); } @PatchMapping("/my-info/{memberId}") @ResponseStatus(HttpStatus.OK) - public ApiResponseDto patchInfo(@PathVariable("memberId") long memberId, @RequestBody MyInfoDto myInfoDto) { + public ApiResponseDto patchInfo(@PathVariable("memberId") Long memberId, @RequestBody MyInfoDto myInfoDto) { return ApiResponseDto.success(SuccessStatus.PATCH_MYINFO_SUCCESS, memberService.patchMyInfo(memberId, myInfoDto)); } } diff --git a/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java b/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java index f896dce..ddff642 100644 --- a/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java +++ b/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java @@ -3,10 +3,8 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor @AllArgsConstructor @Builder public class MyPageDto { From 4943b1a293dfd787b8ae02ecb3987af2e2369c4a Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 10:23:22 +0900 Subject: [PATCH 14/26] =?UTF-8?q?fix:=20=EB=A6=AC=ED=8C=A9=ED=84=B0=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/Author.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/sophy/sophy/domain/Author.java b/src/main/java/org/sophy/sophy/domain/Author.java index ccfc112..1db2968 100644 --- a/src/main/java/org/sophy/sophy/domain/Author.java +++ b/src/main/java/org/sophy/sophy/domain/Author.java @@ -8,6 +8,8 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Builder public class Author { @Id @GeneratedValue From 9ff02bd0c536d2b563f47cb53f55d604296dd012 Mon Sep 17 00:00:00 2001 From: Suhyeon <70002218+onpyeong@users.noreply.github.com> Date: Tue, 11 Jul 2023 10:49:37 +0900 Subject: [PATCH 15/26] =?UTF-8?q?feat:=20=EC=A7=80=EC=97=AD=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=81=ED=86=A0=ED=81=AC=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20(#35)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modify: 지역으로 공간 조회 RequestBody CityRequestDto로 통일 * feat: 지역으로 북토크 리스트 조회 * fix: @Transitional 추가 * fix: url과 Valid 설정 --- .../sophy/controller/BooktalkController.java | 41 ------------ .../infrastructure/BooktalkRepository.java | 5 -- .../sophy/sophy/service/BooktalkService.java | 65 +------------------ 3 files changed, 1 insertion(+), 110 deletions(-) diff --git a/src/main/java/org/sophy/sophy/controller/BooktalkController.java b/src/main/java/org/sophy/sophy/controller/BooktalkController.java index e2f1fe6..e68718c 100644 --- a/src/main/java/org/sophy/sophy/controller/BooktalkController.java +++ b/src/main/java/org/sophy/sophy/controller/BooktalkController.java @@ -2,47 +2,6 @@ import lombok.RequiredArgsConstructor; import org.sophy.sophy.common.dto.ApiResponseDto; -import org.sophy.sophy.controller.dto.BooktalkUpdateDto; -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; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - -@RestController -@RequiredArgsConstructor -@RequestMapping("/booktalk") -public class BooktalkController { - private final BooktalkService booktalkService; - - @PostMapping - @ResponseStatus(HttpStatus.CREATED) - public ApiResponseDto createBooktalk(@Valid @RequestBody BooktalkRequestDto booktalkRequestDto) { - return ApiResponseDto.success(SuccessStatus.CREATE_BOOKTALK_SUCCESS, booktalkService.createBooktalk(booktalkRequestDto)); - } - - @PatchMapping("/{booktalkId}") - @ResponseStatus(HttpStatus.OK) - public ApiResponseDto updateBooktalk(@PathVariable("booktalkId") Long booktalkId, @Valid @RequestBody BooktalkUpdateDto booktalkUpdateDto) { - return ApiResponseDto.success(SuccessStatus.PATCH_BOOKTALK_SUCCESS, booktalkService.updateBooktalk(booktalkId, booktalkUpdateDto)); - } - - @DeleteMapping("/{booktalkId}") - @ResponseStatus(HttpStatus.OK) - public ApiResponseDto deleteBooktalk(@PathVariable("booktalkId") Long booktalkId) { - return ApiResponseDto.success(SuccessStatus.DELETE_BOOKTALK_SUCCESS, booktalkService.deleteBooktalk(booktalkId)); - } - - @GetMapping("/{booktalkId}/detail") - public ApiResponseDto getBooktalkDetail(@PathVariable("booktalkId") Long booktalkId) { - return ApiResponseDto.success(SuccessStatus.GET_BOOKTALK_DETAIL_SUCCESS, booktalkService.getBooktalkDetail(booktalkId)); - } - import org.sophy.sophy.controller.dto.request.CityRequestDto; import org.sophy.sophy.controller.dto.response.BooktalkResponseDto; import org.sophy.sophy.exception.SuccessStatus; diff --git a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java index d345d71..26e9f91 100644 --- a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java +++ b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java @@ -1,11 +1,6 @@ package org.sophy.sophy.infrastructure; import org.sophy.sophy.domain.Booktalk; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface BooktalkRepository extends JpaRepository { import org.sophy.sophy.domain.City; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index 7839f45..e01efe4 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -1,18 +1,6 @@ package org.sophy.sophy.service; import lombok.RequiredArgsConstructor; -import org.sophy.sophy.controller.dto.BooktalkUpdateDto; -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; -import org.sophy.sophy.exception.ErrorStatus; -import org.sophy.sophy.exception.model.NotFoundException; -import org.sophy.sophy.infrastructure.BooktalkRepository; -import org.sophy.sophy.infrastructure.MemberRepository; import org.sophy.sophy.controller.dto.request.CityRequestDto; import org.sophy.sophy.controller.dto.response.BooktalkResponseDto; import org.sophy.sophy.domain.BooktalkStatus; @@ -21,6 +9,7 @@ import org.sophy.sophy.infrastructure.PlaceRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -28,59 +17,7 @@ @Service @RequiredArgsConstructor public class BooktalkService { - private final BooktalkRepository booktalkRepository; private final PlaceRepository placeRepository; - private final MemberRepository memberRepository; - - @Transactional - public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkRequestDto) { - Place place = getPlaceById(booktalkRequestDto.getPlaceId()); - //작가인지 확인할 필요가 있는지? - Member member = getMemberById(booktalkRequestDto.getMemberId()); - Booktalk booktalk = booktalkRequestDto.toBooktalk(place, member); - return BooktalkCreateResponseDto.of(booktalkRepository.save(booktalk)); - } - - @Transactional - public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto booktalkUpdateDto) { - Booktalk booktalk = getBooktalkById(booktalkId); - if (booktalkUpdateDto.getPlaceId() != booktalk.getPlace().getId()) { - Place place = getPlaceById(booktalkUpdateDto.getPlaceId()); - booktalk.setPlace(place); - } - booktalk.patchBooktalk(booktalkUpdateDto); - return booktalkUpdateDto; - } - - @Transactional - public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { - Booktalk booktalk = getBooktalkById(booktalkId); - //TODO soft delete? - //공간이 거절 됐거나 공간 매칭중일 때만 삭제가능 - booktalk.getPlace().deleteBooktalk(booktalk); - booktalk.getMember().getAuthor().deleteBooktalk(booktalk); - booktalkRepository.deleteById(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())); - } - - private Place getPlaceById(Long placeId) { - return placeRepository.findById(placeId) - .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_PLACE_EXCEPTION, ErrorStatus.NOT_FOUND_PLACE_EXCEPTION.getMessage())); - } - - private Booktalk getBooktalkById(Long booktalkId) { - return booktalkRepository.findById(booktalkId) - .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION, ErrorStatus.NOT_FOUND_BOOKTALK_EXCEPTION.getMessage())); @Transactional public List getBooktalksByCity(CityRequestDto cityRequestDto) { From 6669ce42ac4d023458bfe7a29c3db5f2f660dd52 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 11:17:17 +0900 Subject: [PATCH 16/26] =?UTF-8?q?feat:=20=EA=B0=80=EC=9E=A5=20=EA=B0=80?= =?UTF-8?q?=EA=B9=8C=EC=9A=B4=20=EB=B6=81=ED=86=A0=ED=81=AC=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=ED=95=84=EB=93=9C=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/Member.java | 13 ++++++++----- .../java/org/sophy/sophy/domain/dto/MyPageDto.java | 5 ++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/sophy/sophy/domain/Member.java b/src/main/java/org/sophy/sophy/domain/Member.java index 471165a..0b7c6a3 100644 --- a/src/main/java/org/sophy/sophy/domain/Member.java +++ b/src/main/java/org/sophy/sophy/domain/Member.java @@ -50,6 +50,9 @@ public class Member extends AuditingTimeEntity{ private Integer bookCount; private Integer bookTalkCount; + @OneToOne + private Booktalk imminentBooktalk; + @OneToMany(mappedBy = "member") private List userBookTalkList; @@ -57,15 +60,11 @@ public class Member extends AuditingTimeEntity{ private Author author; //(개설한 북토크 리스트 + 나의 책 리스트 + 공간 매칭 중 북토크 수 + 청중 모집 중 북토크 수) @Builder - public Member(String name, String email, String password, String phoneNum, String gender, String birth - , City myCity, boolean marketingAgree, boolean isAuthor, boolean isOperator, Authority authority) { + public Member(String name, String email, String password, String phoneNum, boolean marketingAgree, boolean isAuthor, boolean isOperator, Authority authority) { this.name = name; this.email = email; this.password = password; this.phoneNum = phoneNum; - this.gender = gender; - this.birth = birth; - this.myCity = myCity; this.marketingAgree = marketingAgree; this.isAuthor = isAuthor; this.isOperator = isOperator; @@ -84,6 +83,10 @@ public void setBookTalkCount(int count) { this.bookTalkCount = count; } + public void changeImminentBooktalk(Booktalk booktalk) { + this.imminentBooktalk = booktalk; + } + public void setAdditionalInfo(MemberAdditionalInfoDto memberAdditionalInfoDto) { this.gender = memberAdditionalInfoDto.getGender(); this.birth = memberAdditionalInfoDto.getBirth(); diff --git a/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java b/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java index ddff642..149ba8b 100644 --- a/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java +++ b/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java @@ -3,13 +3,16 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; +import org.sophy.sophy.domain.Booktalk; @Getter +@NoArgsConstructor @AllArgsConstructor @Builder public class MyPageDto { private String name; -// private Booktalk imminentBooktalk; + private Booktalk imminentBooktalk; private Integer bookCount; private Integer bookTalkCount; private Integer matchingBookTalkCount; From a5ab0cf410c69f818c3b37f201cd11da2179426f Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 13:16:07 +0900 Subject: [PATCH 17/26] =?UTF-8?q?feat:=20=EC=98=88=EC=A0=95=EB=90=9C=20?= =?UTF-8?q?=EB=B6=81=ED=86=A0=ED=81=AC=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/InitDb.java | 2 +- .../sophy/sophy/controller/MemberController.java | 9 +++++++++ src/main/java/org/sophy/sophy/domain/Member.java | 4 ++-- .../org/sophy/sophy/exception/SuccessStatus.java | 2 +- .../sophy/infrastructure/BooktalkRepository.java | 3 +-- .../org/sophy/sophy/service/MemberService.java | 16 ++++++++++++++++ 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/sophy/sophy/InitDb.java b/src/main/java/org/sophy/sophy/InitDb.java index e74b5cd..83d4389 100644 --- a/src/main/java/org/sophy/sophy/InitDb.java +++ b/src/main/java/org/sophy/sophy/InitDb.java @@ -59,7 +59,7 @@ public void dbInit() { .isOperator(false) .authority(Authority.ROLE_USER) .build(); - author.serAuthor(memauthor); + author.setAuthor(memauthor); author.setBookTalkCount(3); author.setBookCount(3); em.persist(author); diff --git a/src/main/java/org/sophy/sophy/controller/MemberController.java b/src/main/java/org/sophy/sophy/controller/MemberController.java index ceed71b..0f1c8fe 100644 --- a/src/main/java/org/sophy/sophy/controller/MemberController.java +++ b/src/main/java/org/sophy/sophy/controller/MemberController.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import org.sophy.sophy.common.dto.ApiResponseDto; import org.sophy.sophy.controller.dto.request.MemberAdditionalInfoDto; +import org.sophy.sophy.controller.dto.response.BooktalkResponseDto; import org.sophy.sophy.domain.dto.MyPageDto; import org.sophy.sophy.domain.dto.MyInfoDto; import org.sophy.sophy.exception.SuccessStatus; @@ -10,6 +11,8 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import java.util.List; + @RestController @RequiredArgsConstructor @RequestMapping("/member") @@ -39,4 +42,10 @@ public ApiResponseDto postAdditionalInfo(@PathVariable( public ApiResponseDto patchInfo(@PathVariable("memberId") Long memberId, @RequestBody MyInfoDto myInfoDto) { return ApiResponseDto.success(SuccessStatus.PATCH_MYINFO_SUCCESS, memberService.patchMyInfo(memberId, myInfoDto)); } + + @GetMapping("/my-booktalks/{memberId}") + @ResponseStatus(HttpStatus.OK) + public ApiResponseDto> getMyBooktalks(@PathVariable("memberId") Long memberId) { + return ApiResponseDto.success(SuccessStatus.GET_MY_BOOKTALKS_SUCCESS, memberService.getBooktalksByMemberId(memberId)); + } } diff --git a/src/main/java/org/sophy/sophy/domain/Member.java b/src/main/java/org/sophy/sophy/domain/Member.java index 0b7c6a3..e03a48b 100644 --- a/src/main/java/org/sophy/sophy/domain/Member.java +++ b/src/main/java/org/sophy/sophy/domain/Member.java @@ -11,7 +11,7 @@ @Entity @Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor public class Member extends AuditingTimeEntity{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -71,7 +71,7 @@ public Member(String name, String email, String password, String phoneNum, boole this.authority = authority; } - public void serAuthor(Author author) { + public void setAuthor(Author author) { this.author = author; } diff --git a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java index a9e7400..558f481 100644 --- a/src/main/java/org/sophy/sophy/exception/SuccessStatus.java +++ b/src/main/java/org/sophy/sophy/exception/SuccessStatus.java @@ -22,8 +22,8 @@ public enum SuccessStatus { PATCH_BOOKTALK_SUCCESS(HttpStatus.OK, "북토크를 성공적으로 수정했습니다."), DELETE_BOOKTALK_SUCCESS(HttpStatus.OK, "북토크를 성공적으로 삭제했습니다."), GET_BOOKTALK_DETAIL_SUCCESS(HttpStatus.OK, "북토크 상세정보를 성공적으로 불러왔습니다."), - GET_PLACES_BY_CITY_SUCCESS(HttpStatus.OK, "지역으로 공간 리스트를 성공적으로 불러왔습니다"), GET_BOOKTALKS_BY_CITY_SUCCESS(HttpStatus.OK, "지역으로 북토크 리스트를 성공적으로 불러왔습니다"), + GET_MY_BOOKTALKS_SUCCESS(HttpStatus.OK, "예정된 북토크 리스트를 성공적으로 불러왔습니다"), TEST_SUCCESS(HttpStatus.OK, "Test :: OK"), /* * 201 created diff --git a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java index 26e9f91..e880111 100644 --- a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java +++ b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java @@ -1,7 +1,6 @@ package org.sophy.sophy.infrastructure; import org.sophy.sophy.domain.Booktalk; -import org.sophy.sophy.domain.City; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -9,5 +8,5 @@ @Repository public interface BooktalkRepository extends JpaRepository { - + public List findAllByMemberId(Long memberId); } diff --git a/src/main/java/org/sophy/sophy/service/MemberService.java b/src/main/java/org/sophy/sophy/service/MemberService.java index f9570a4..d31e7f7 100644 --- a/src/main/java/org/sophy/sophy/service/MemberService.java +++ b/src/main/java/org/sophy/sophy/service/MemberService.java @@ -2,20 +2,27 @@ import lombok.RequiredArgsConstructor; import org.sophy.sophy.controller.dto.request.MemberAdditionalInfoDto; +import org.sophy.sophy.controller.dto.response.BooktalkResponseDto; +import org.sophy.sophy.domain.Booktalk; import org.sophy.sophy.domain.Member; import org.sophy.sophy.domain.dto.MyPageDto; import org.sophy.sophy.domain.dto.MyInfoDto; import org.sophy.sophy.exception.ErrorStatus; import org.sophy.sophy.exception.model.NotFoundException; +import org.sophy.sophy.infrastructure.BooktalkRepository; import org.sophy.sophy.infrastructure.MemberRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; + @Service @RequiredArgsConstructor public class MemberService { private final MemberRepository memberRepository; + private final BooktalkRepository booktalkRepository; @Transactional public MyPageDto getMyPage(Long memberId) { @@ -69,5 +76,14 @@ private Member getMemberById(Long memberId) { .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_USER_EXCEPTION, ErrorStatus.NOT_FOUND_USER_EXCEPTION.getMessage())); } + @Transactional + public List getBooktalksByMemberId(Long memberId) { + List booktalks = booktalkRepository.findAllByMemberId(memberId); + List booktalkResponseDtoList = new ArrayList<>(); + booktalks.forEach(booktalk -> { + booktalkResponseDtoList.add(BooktalkResponseDto.of(booktalk)); + }); + return booktalkResponseDtoList; + } } From 8810a7206cded10d8116cc12e5694156316f2f0d Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 18:12:48 +0900 Subject: [PATCH 18/26] =?UTF-8?q?chore:=20=EC=9B=90=EC=8B=9C=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=88=98=EC=A0=95=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java | 1 + .../java/org/sophy/sophy/infrastructure/BooktalkRepository.java | 2 ++ src/main/java/org/sophy/sophy/service/BooktalkService.java | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java b/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java index 555945c..ba52cb6 100644 --- a/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java +++ b/src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java @@ -3,6 +3,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import org.sophy.sophy.domain.Booktalk; @Getter @AllArgsConstructor diff --git a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java index fc78471..e880111 100644 --- a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java +++ b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java @@ -4,6 +4,8 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface BooktalkRepository extends JpaRepository { public List findAllByMemberId(Long memberId); diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index 6774856..cfa4b45 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -34,7 +34,7 @@ public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkReque Place place = getPlaceById(booktalkRequestDto.getPlaceId()); //작가인지 확인할 필요가 있는지? Member member = getMemberById(booktalkRequestDto.getMemberId()); - if(!member.isAuthor()) { + if(!member.getIsAuthor()) { throw new ForbiddenException(ErrorStatus.FORBIDDEN_USER_EXCEPTION, ErrorStatus.FORBIDDEN_USER_EXCEPTION.getMessage()); } Booktalk booktalk = booktalkRequestDto.toBooktalk(place, member); From 6f421e3537c42b25095161b82d705776a2ce934d Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 20:42:50 +0900 Subject: [PATCH 19/26] =?UTF-8?q?fix:=20=EC=98=88=EC=A0=95=EB=90=9C=20?= =?UTF-8?q?=EB=B6=81=ED=86=A0=ED=81=AC=20=EC=A1=B0=ED=9A=8C=ED=95=B4?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/service/MemberService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/sophy/sophy/service/MemberService.java b/src/main/java/org/sophy/sophy/service/MemberService.java index d31e7f7..2da9968 100644 --- a/src/main/java/org/sophy/sophy/service/MemberService.java +++ b/src/main/java/org/sophy/sophy/service/MemberService.java @@ -3,8 +3,8 @@ import lombok.RequiredArgsConstructor; import org.sophy.sophy.controller.dto.request.MemberAdditionalInfoDto; import org.sophy.sophy.controller.dto.response.BooktalkResponseDto; -import org.sophy.sophy.domain.Booktalk; import org.sophy.sophy.domain.Member; +import org.sophy.sophy.domain.MemberBooktalk; import org.sophy.sophy.domain.dto.MyPageDto; import org.sophy.sophy.domain.dto.MyInfoDto; import org.sophy.sophy.exception.ErrorStatus; @@ -78,10 +78,10 @@ private Member getMemberById(Long memberId) { @Transactional public List getBooktalksByMemberId(Long memberId) { - List booktalks = booktalkRepository.findAllByMemberId(memberId); + List userBookTalkList = getMemberById(memberId).getUserBookTalkList(); List booktalkResponseDtoList = new ArrayList<>(); - booktalks.forEach(booktalk -> { - booktalkResponseDtoList.add(BooktalkResponseDto.of(booktalk)); + userBookTalkList.forEach(booktalk -> { + booktalkResponseDtoList.add(BooktalkResponseDto.of(booktalk.getBooktalk())); }); return booktalkResponseDtoList; } From cdd03c22f84f55e636664ce826001001c9b05737 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 21:06:47 +0900 Subject: [PATCH 20/26] =?UTF-8?q?add:=20initDB=EC=97=90=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/InitDb.java | 23 +++++++++++++++++++ .../sophy/sophy/domain/MemberBooktalk.java | 7 ++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/sophy/sophy/InitDb.java b/src/main/java/org/sophy/sophy/InitDb.java index 83d4389..e969c65 100644 --- a/src/main/java/org/sophy/sophy/InitDb.java +++ b/src/main/java/org/sophy/sophy/InitDb.java @@ -8,6 +8,7 @@ import javax.annotation.PostConstruct; import javax.persistence.EntityManager; +import java.time.LocalDateTime; @Component @RequiredArgsConstructor @@ -78,6 +79,28 @@ public void dbInit() { .build(); em.persist(place); em.persist(place2); + + Booktalk booktalk = Booktalk.builder() + .place(place2) + .booktalkImageUrl("dwqE@EWQDQFQEWQ") + .author(author) + .bookCategory(BookCategory.HUMANITIES) + .startDate(LocalDateTime.of(2023, 7, 13, 13, 00)) + .endDate(LocalDateTime.of(2023, 7, 13, 15, 00)) + .maximum(6) + .participationFee(1000) + .preliminaryInfo(PreliminaryInfo.PRE_READING) + .description("테스트입니당") + .booktalkStatus(BooktalkStatus.RECRUITING) + .build(); + em.persist(booktalk); + + MemberBooktalk memberBooktalk = MemberBooktalk.builder() + .member(citizen) + .booktalk(booktalk) + .build(); + + em.persist(memberBooktalk); } } } diff --git a/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java b/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java index 44b95ef..3c865c3 100644 --- a/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java +++ b/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java @@ -24,8 +24,6 @@ public class MemberBooktalk extends AuditingTimeEntity { @JoinColumn(name = "booktalk_id", nullable = false, foreignKey = @ForeignKey(ConstraintMode.CONSTRAINT)) private Booktalk booktalk; - private Boolean isConfirmed; - // 연관 관계 편의 메서드 public void setMember(Member member) { this.member = member; @@ -42,9 +40,8 @@ public void setBooktalk(Booktalk booktalk) { } @Builder - public MemberBooktalk(Member member, Booktalk booktalk, Boolean isConfirmed) { - this.member = member; + public MemberBooktalk(Member member, Booktalk booktalk) { + setMember(member); setBooktalk(booktalk); - this.isConfirmed = isConfirmed; } } From bf977e2d6d7922bb3311061b0fc6cbbb5fa538f3 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 21:07:06 +0900 Subject: [PATCH 21/26] =?UTF-8?q?add:=20initDB=EC=97=90=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/InitDb.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/sophy/sophy/InitDb.java b/src/main/java/org/sophy/sophy/InitDb.java index e969c65..cc754ad 100644 --- a/src/main/java/org/sophy/sophy/InitDb.java +++ b/src/main/java/org/sophy/sophy/InitDb.java @@ -85,8 +85,8 @@ public void dbInit() { .booktalkImageUrl("dwqE@EWQDQFQEWQ") .author(author) .bookCategory(BookCategory.HUMANITIES) - .startDate(LocalDateTime.of(2023, 7, 13, 13, 00)) - .endDate(LocalDateTime.of(2023, 7, 13, 15, 00)) + .startDate(LocalDateTime.of(2023, 7, 13, 13, 0)) + .endDate(LocalDateTime.of(2023, 7, 13, 15, 0)) .maximum(6) .participationFee(1000) .preliminaryInfo(PreliminaryInfo.PRE_READING) From d19f54ea170700565367b0d3e33c3fd945173278 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 21:07:38 +0900 Subject: [PATCH 22/26] =?UTF-8?q?chore:=20Booktalk=EC=9D=98=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EB=B3=80=EC=88=98=20->=20author=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/domain/Booktalk.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/sophy/sophy/domain/Booktalk.java b/src/main/java/org/sophy/sophy/domain/Booktalk.java index e4f6131..269a519 100644 --- a/src/main/java/org/sophy/sophy/domain/Booktalk.java +++ b/src/main/java/org/sophy/sophy/domain/Booktalk.java @@ -30,7 +30,7 @@ public class Booktalk extends AuditingTimeEntity { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.CONSTRAINT)) - private Member member; + private Member author; @Column(nullable = false) @Enumerated(EnumType.STRING) @@ -75,22 +75,22 @@ public void setPlace(Place place) { } } - public void setMember(Member member) { - if (this.member != null) { - this.member.getAuthor().getMyBookTalkList().remove(this); + public void setAuthor(Member member) { + if (this.author != null) { + this.author.getAuthor().getMyBookTalkList().remove(this); } - this.member = member; + this.author = member; if (!member.getAuthor().getMyBookTalkList().contains(this)) { member.getAuthor().getMyBookTalkList().add(this); } } @Builder - public Booktalk(Place place, String title, String booktalkImageUrl, Member member, BookCategory bookCategory, LocalDateTime startDate, LocalDateTime endDate, Integer maximum, Integer participationFee, PreliminaryInfo preliminaryInfo, String description, BooktalkStatus booktalkStatus) { + public Booktalk(Place place, String title, String booktalkImageUrl, Member author, BookCategory bookCategory, LocalDateTime startDate, LocalDateTime endDate, Integer maximum, Integer participationFee, PreliminaryInfo preliminaryInfo, String description, BooktalkStatus booktalkStatus) { setPlace(place); this.title = title; this.booktalkImageUrl = booktalkImageUrl; - setMember(member); + setAuthor(author); this.bookCategory = bookCategory; this.startDate = startDate; this.endDate = endDate; From c2c7ce232b560067fcd7b805d87ccc5126f6d5c0 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 21:08:59 +0900 Subject: [PATCH 23/26] =?UTF-8?q?chore:=20Booktalk=EC=9D=98=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EB=B3=80=EC=88=98=20->=20author=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/controller/dto/request/BooktalkRequestDto.java | 2 +- .../controller/dto/response/BooktalkDetailResponseDto.java | 2 +- .../sophy/controller/dto/response/BooktalkResponseDto.java | 4 +--- src/main/java/org/sophy/sophy/service/BooktalkService.java | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java b/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java index 4561f79..8a1bc93 100644 --- a/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java +++ b/src/main/java/org/sophy/sophy/controller/dto/request/BooktalkRequestDto.java @@ -49,7 +49,7 @@ public Booktalk toBooktalk(Place place, Member member) { .preliminaryInfo(preliminaryInfo) .description(description) .booktalkStatus(BooktalkStatus.APPLYING) - .member(member) + .author(member) .place(place) .build(); } diff --git a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java index 3dc0078..80b74a2 100644 --- a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java +++ b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkDetailResponseDto.java @@ -30,7 +30,7 @@ public static BooktalkDetailResponseDto of(Booktalk booktalk) { return new BooktalkDetailResponseDto( booktalk.getBooktalkImageUrl(), booktalk.getTitle(), - booktalk.getMember().getName(), + booktalk.getAuthor().getName(), booktalk.getBookCategory(), "책이름", //TODO 추후 연결 booktalk.getStartDate(), diff --git a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java index 471a4fd..d466966 100644 --- a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java +++ b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java @@ -4,10 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Getter; import org.sophy.sophy.domain.Booktalk; -import org.sophy.sophy.domain.PreliminaryInfo; import java.time.LocalDateTime; -import java.util.ArrayList; @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) @@ -27,7 +25,7 @@ public static BooktalkResponseDto of(Booktalk booktalk) { booktalk.getId(), booktalk.getPreliminaryInfo().ordinal(), booktalk.getTitle(), - booktalk.getMember().getName(), + booktalk.getAuthor().getName(), booktalk.getStartDate(), booktalk.getEndDate(), booktalk.getPlace().getName(), diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index cfa4b45..fd64475 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -54,7 +54,7 @@ public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { //TODO soft delete? //공간이 거절 됐거나 공간 매칭중일 때만 삭제가능 booktalk.getPlace().deleteBooktalk(booktalk); - booktalk.getMember().getAuthor().deleteBooktalk(booktalk); + booktalk.getAuthor().getAuthor().deleteBooktalk(booktalk); booktalkRepository.deleteById(booktalkId); return BooktalkDeleteResponseDto.of(booktalkId); } From 22267e1667f48371e719d72a71a286b02c62d10a Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 21:43:17 +0900 Subject: [PATCH 24/26] =?UTF-8?q?refactor:=20Member=EA=B0=80=20=EA=B0=80?= =?UTF-8?q?=EC=A7=84=20Author=20=ED=95=84=EB=93=9C=EB=A5=BC=20AuthorProper?= =?UTF-8?q?ty=EB=A1=9C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/domain/{Author.java => AuthorProperty.java} | 4 ++-- src/main/java/org/sophy/sophy/domain/Booktalk.java | 6 +++--- src/main/java/org/sophy/sophy/domain/Member.java | 8 +++++--- .../sophy/sophy/infrastructure/BooktalkRepository.java | 2 +- .../java/org/sophy/sophy/service/BooktalkService.java | 2 +- src/main/java/org/sophy/sophy/service/MemberService.java | 4 ++-- 6 files changed, 14 insertions(+), 12 deletions(-) rename src/main/java/org/sophy/sophy/domain/{Author.java => AuthorProperty.java} (88%) diff --git a/src/main/java/org/sophy/sophy/domain/Author.java b/src/main/java/org/sophy/sophy/domain/AuthorProperty.java similarity index 88% rename from src/main/java/org/sophy/sophy/domain/Author.java rename to src/main/java/org/sophy/sophy/domain/AuthorProperty.java index 1db2968..0a24192 100644 --- a/src/main/java/org/sophy/sophy/domain/Author.java +++ b/src/main/java/org/sophy/sophy/domain/AuthorProperty.java @@ -10,10 +10,10 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor @Builder -public class Author { +public class AuthorProperty { @Id @GeneratedValue - @Column(name = "author_id") + @Column(name = "author_property_id") private Long id; @OneToMany diff --git a/src/main/java/org/sophy/sophy/domain/Booktalk.java b/src/main/java/org/sophy/sophy/domain/Booktalk.java index 269a519..2639765 100644 --- a/src/main/java/org/sophy/sophy/domain/Booktalk.java +++ b/src/main/java/org/sophy/sophy/domain/Booktalk.java @@ -77,11 +77,11 @@ public void setPlace(Place place) { public void setAuthor(Member member) { if (this.author != null) { - this.author.getAuthor().getMyBookTalkList().remove(this); + this.author.getAuthorProperty().getMyBookTalkList().remove(this); } this.author = member; - if (!member.getAuthor().getMyBookTalkList().contains(this)) { - member.getAuthor().getMyBookTalkList().add(this); + if (!member.getAuthorProperty().getMyBookTalkList().contains(this)) { + member.getAuthorProperty().getMyBookTalkList().add(this); } } diff --git a/src/main/java/org/sophy/sophy/domain/Member.java b/src/main/java/org/sophy/sophy/domain/Member.java index ade2a52..98d4d14 100644 --- a/src/main/java/org/sophy/sophy/domain/Member.java +++ b/src/main/java/org/sophy/sophy/domain/Member.java @@ -5,6 +5,7 @@ import org.sophy.sophy.domain.dto.MyInfoDto; import javax.persistence.*; +import java.util.ArrayList; import java.util.List; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; @@ -57,7 +58,7 @@ public class Member extends AuditingTimeEntity{ private List userBookTalkList; @OneToOne - private Author author; //(개설한 북토크 리스트 + 나의 책 리스트 + 공간 매칭 중 북토크 수 + 청중 모집 중 북토크 수) + private AuthorProperty authorProperty; //(개설한 북토크 리스트 + 나의 책 리스트 + 공간 매칭 중 북토크 수 + 청중 모집 중 북토크 수) @Builder public Member(String name, String email, String password, String phoneNum, boolean marketingAgree, boolean isAuthor, boolean isOperator, Authority authority) { @@ -69,10 +70,11 @@ public Member(String name, String email, String password, String phoneNum, boole this.isAuthor = isAuthor; this.isOperator = isOperator; this.authority = authority; + this.userBookTalkList = new ArrayList<>(); } - public void setAuthor(Author author) { - this.author = author; + public void setAuthor(AuthorProperty authorProperty) { + this.authorProperty = authorProperty; } public void setBookCount(int count) { diff --git a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java index e880111..6bcc8d2 100644 --- a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java +++ b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java @@ -8,5 +8,5 @@ @Repository public interface BooktalkRepository extends JpaRepository { - public List findAllByMemberId(Long memberId); + List findAllByAuthorId(Long authorId); //Booktalk의 작가 } diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index fd64475..64025b7 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -54,7 +54,7 @@ public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { //TODO soft delete? //공간이 거절 됐거나 공간 매칭중일 때만 삭제가능 booktalk.getPlace().deleteBooktalk(booktalk); - booktalk.getAuthor().getAuthor().deleteBooktalk(booktalk); + booktalk.getAuthor().getAuthorProperty().deleteBooktalk(booktalk); booktalkRepository.deleteById(booktalkId); return BooktalkDeleteResponseDto.of(booktalkId); } diff --git a/src/main/java/org/sophy/sophy/service/MemberService.java b/src/main/java/org/sophy/sophy/service/MemberService.java index 2da9968..6b5cfcb 100644 --- a/src/main/java/org/sophy/sophy/service/MemberService.java +++ b/src/main/java/org/sophy/sophy/service/MemberService.java @@ -33,8 +33,8 @@ public MyPageDto getMyPage(Long memberId) { .name(member.getName()) .bookCount(member.getBookCount()) .bookTalkCount(member.getBookTalkCount()) - .matchingBookTalkCount(member.getAuthor().getMatchingBookTalkCount()) - .recruitBookTalkCount(member.getAuthor().getRecruitBookTalkCount()) + .matchingBookTalkCount(member.getAuthorProperty().getMatchingBookTalkCount()) + .recruitBookTalkCount(member.getAuthorProperty().getRecruitBookTalkCount()) .build(); } else { return MyPageDto.builder() From 823f3c7cc72e3e142f3d608a1cc48586354a5ed3 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 21:43:47 +0900 Subject: [PATCH 25/26] =?UTF-8?q?feat:=20=ED=98=84=EC=9E=AC=20Issue?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20InitDb=EC=97=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/InitDb.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sophy/sophy/InitDb.java b/src/main/java/org/sophy/sophy/InitDb.java index cc754ad..85bfa11 100644 --- a/src/main/java/org/sophy/sophy/InitDb.java +++ b/src/main/java/org/sophy/sophy/InitDb.java @@ -9,6 +9,7 @@ import javax.annotation.PostConstruct; import javax.persistence.EntityManager; import java.time.LocalDateTime; +import java.util.ArrayList; @Component @RequiredArgsConstructor @@ -44,7 +45,8 @@ public void dbInit() { citizen.setBookTalkCount(5); em.persist(citizen); - Author memauthor = Author.builder() + AuthorProperty memauthor = AuthorProperty.builder() + .myBookTalkList(new ArrayList<>()) .matchingBookTalkCount(3) .recruitBookTalkCount(3) .build(); @@ -82,6 +84,7 @@ public void dbInit() { Booktalk booktalk = Booktalk.builder() .place(place2) + .title("테스트 타이틀") .booktalkImageUrl("dwqE@EWQDQFQEWQ") .author(author) .bookCategory(BookCategory.HUMANITIES) From 8efb249651983c1f36ccdeaa05915585b5b30aa4 Mon Sep 17 00:00:00 2001 From: dong2ast Date: Tue, 11 Jul 2023 21:52:19 +0900 Subject: [PATCH 26/26] =?UTF-8?q?fix:=20BooktalkResponseDto=EC=97=90=20ima?= =?UTF-8?q?ge=20String=EB=8F=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sophy/sophy/InitDb.java | 22 +++++++++++++++++++ .../dto/response/BooktalkResponseDto.java | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sophy/sophy/InitDb.java b/src/main/java/org/sophy/sophy/InitDb.java index 85bfa11..c4ae27c 100644 --- a/src/main/java/org/sophy/sophy/InitDb.java +++ b/src/main/java/org/sophy/sophy/InitDb.java @@ -98,12 +98,34 @@ public void dbInit() { .build(); em.persist(booktalk); + Booktalk booktalk2 = Booktalk.builder() + .place(place) + .title("테스트 타이틀2") + .booktalkImageUrl("dwqE@EWQDQFQEWQ") + .author(author) + .bookCategory(BookCategory.HEALTH_COOKING) + .startDate(LocalDateTime.of(2023, 7, 18, 16, 0)) + .endDate(LocalDateTime.of(2023, 7, 18, 18, 0)) + .maximum(6) + .participationFee(10000) + .preliminaryInfo(PreliminaryInfo.PRE_READING) + .description("재밌습니다~") + .booktalkStatus(BooktalkStatus.PLACE_CONFIRMED) + .build(); + em.persist(booktalk2); + MemberBooktalk memberBooktalk = MemberBooktalk.builder() .member(citizen) .booktalk(booktalk) .build(); + MemberBooktalk memberBooktalk2 = MemberBooktalk.builder() + .member(citizen) + .booktalk(booktalk2) + .build(); + em.persist(memberBooktalk); + em.persist(memberBooktalk2); } } } diff --git a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java index d466966..ad080b6 100644 --- a/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java +++ b/src/main/java/org/sophy/sophy/controller/dto/response/BooktalkResponseDto.java @@ -19,6 +19,7 @@ public class BooktalkResponseDto { private String place; private Integer participant; private Integer maximum; + private String booktalkImageUrl; public static BooktalkResponseDto of(Booktalk booktalk) { return new BooktalkResponseDto( @@ -30,6 +31,7 @@ public static BooktalkResponseDto of(Booktalk booktalk) { booktalk.getEndDate(), booktalk.getPlace().getName(), booktalk.getParticipantList().size(), - booktalk.getMaximum()); + booktalk.getMaximum(), + booktalk.getBooktalkImageUrl()); } }