From 154006e07eda04342c3aa4a6a6c5056206440001 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 16:15:16 +0900 Subject: [PATCH 01/12] =?UTF-8?q?rename:=20CafeSearchResponse=EB=A5=BC=20C?= =?UTF-8?q?afeSearchListResponse=EB=A1=9C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/demo/controller/CafeController.java | 6 +++--- .../demo/controller/StudyOnceController.java | 6 +++--- ...chResponse.java => CafeSearchListResponse.java} | 2 +- .../java/com/example/demo/mapper/CafeMapper.java | 14 +++++++------- .../com/example/demo/service/cafe/CafeService.java | 6 +++--- .../example/demo/service/cafe/CafeServiceImpl.java | 14 +++++++------- 6 files changed, 24 insertions(+), 24 deletions(-) rename src/main/java/com/example/demo/dto/cafe/{CafeSearchResponse.java => CafeSearchListResponse.java} (93%) diff --git a/src/main/java/com/example/demo/controller/CafeController.java b/src/main/java/com/example/demo/controller/CafeController.java index 8e51c8d..477bca4 100644 --- a/src/main/java/com/example/demo/controller/CafeController.java +++ b/src/main/java/com/example/demo/controller/CafeController.java @@ -12,8 +12,8 @@ import com.example.demo.domain.auth.CafegoryTokenManager; import com.example.demo.dto.PagedResponse; import com.example.demo.dto.cafe.CafeResponse; +import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; -import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.service.cafe.CafeService; import lombok.RequiredArgsConstructor; @@ -26,9 +26,9 @@ public class CafeController { private final CafegoryTokenManager cafegoryTokenManager; @GetMapping("/cafe/list") - public ResponseEntity> searchCafeList( + public ResponseEntity> searchCafeList( @ModelAttribute CafeSearchRequest cafeSearchRequest) { - PagedResponse response = cafeService.searchWithPagingByDynamicFilter( + PagedResponse response = cafeService.searchWithPagingByDynamicFilter( cafeSearchRequest); return new ResponseEntity<>(response, HttpStatus.OK); } diff --git a/src/main/java/com/example/demo/controller/StudyOnceController.java b/src/main/java/com/example/demo/controller/StudyOnceController.java index dec8ca4..eabf0bc 100644 --- a/src/main/java/com/example/demo/controller/StudyOnceController.java +++ b/src/main/java/com/example/demo/controller/StudyOnceController.java @@ -21,7 +21,7 @@ import com.example.demo.domain.auth.CafegoryTokenManager; import com.example.demo.dto.PagedResponse; -import com.example.demo.dto.cafe.CafeSearchResponse; +import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.study.StudyMembersResponse; import com.example.demo.dto.study.StudyOnceCommentRequest; import com.example.demo.dto.study.StudyOnceCommentResponse; @@ -129,12 +129,12 @@ public ResponseEntity takeAttendance(@PathVariable Lon } @PatchMapping("/{studyOnceId:[0-9]+}/location") - public ResponseEntity changeCafe(@PathVariable Long studyOnceId, + public ResponseEntity changeCafe(@PathVariable Long studyOnceId, @RequestHeader("Authorization") String authorization, @RequestBody Long cafeId) { long leaderId = cafegoryTokenManager.getIdentityId(authorization); Long changedCafeId = studyOnceService.changeCafe(leaderId, studyOnceId, cafeId); - CafeSearchResponse response = cafeService.searchCafeBasicInfoById(changedCafeId); + CafeSearchListResponse response = cafeService.searchCafeBasicInfoById(changedCafeId); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchListResponse.java similarity index 93% rename from src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java rename to src/main/java/com/example/demo/dto/cafe/CafeSearchListResponse.java index f7b7f48..2187f10 100644 --- a/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchListResponse.java @@ -7,7 +7,7 @@ @Getter @RequiredArgsConstructor -public class CafeSearchResponse { +public class CafeSearchListResponse { private final long cafeId; private final String name; diff --git a/src/main/java/com/example/demo/mapper/CafeMapper.java b/src/main/java/com/example/demo/mapper/CafeMapper.java index 4337e26..98f40ca 100644 --- a/src/main/java/com/example/demo/mapper/CafeMapper.java +++ b/src/main/java/com/example/demo/mapper/CafeMapper.java @@ -11,8 +11,8 @@ import com.example.demo.dto.cafe.BusinessHourResponse; import com.example.demo.dto.cafe.CafeBasicInfoResponse; import com.example.demo.dto.cafe.CafeResponse; +import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; -import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.dto.cafe.SnsResponse; import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.study.CanMakeStudyOnceResponse; @@ -20,17 +20,17 @@ public class CafeMapper { - public List toCafeSearchResponses(List cafes, + public List toCafeSearchListResponses(List cafes, OpenChecker openChecker) { return cafes.stream() .map(cafe -> - produceCafeSearchResponse(cafe, openChecker) + produceCafeSearchListResponse(cafe, openChecker) ) .collect(Collectors.toList()); } - private CafeSearchResponse produceCafeSearchResponse(Cafe cafe, OpenChecker openChecker) { - return new CafeSearchResponse( + private CafeSearchListResponse produceCafeSearchListResponse(Cafe cafe, OpenChecker openChecker) { + return new CafeSearchListResponse( cafe.getId(), cafe.getName(), cafe.showFullAddress(), @@ -50,8 +50,8 @@ private CafeSearchResponse produceCafeSearchResponse(Cafe cafe, OpenChecker openChecker) { - return produceCafeSearchResponse(cafe, openChecker); + public CafeSearchListResponse toCafeSearchResponse(Cafe cafe, OpenChecker openChecker) { + return produceCafeSearchListResponse(cafe, openChecker); } public CafeBasicInfoResponse toCafeBasicInfoResponse(Cafe cafe, diff --git a/src/main/java/com/example/demo/service/cafe/CafeService.java b/src/main/java/com/example/demo/service/cafe/CafeService.java index 61deff5..2655512 100644 --- a/src/main/java/com/example/demo/service/cafe/CafeService.java +++ b/src/main/java/com/example/demo/service/cafe/CafeService.java @@ -2,14 +2,14 @@ import com.example.demo.dto.PagedResponse; import com.example.demo.dto.cafe.CafeResponse; +import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; -import com.example.demo.dto.cafe.CafeSearchResponse; public interface CafeService { - PagedResponse searchWithPagingByDynamicFilter(CafeSearchRequest request); + PagedResponse searchWithPagingByDynamicFilter(CafeSearchRequest request); - CafeSearchResponse searchCafeBasicInfoById(Long cafeId); + CafeSearchListResponse searchCafeBasicInfoById(Long cafeId); CafeResponse searchCafeForMemberByCafeId(Long cafeId, Long memberId); diff --git a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java index e0b7910..ac7716c 100644 --- a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java +++ b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java @@ -16,8 +16,8 @@ import com.example.demo.domain.cafe.OpenChecker; import com.example.demo.dto.PagedResponse; import com.example.demo.dto.cafe.CafeResponse; +import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; -import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.mapper.BusinessHourMapper; import com.example.demo.mapper.CafeMapper; @@ -47,18 +47,18 @@ public class CafeServiceImpl implements CafeService { private final StudyOnceMapper studyOnceMapper; @Override - public PagedResponse searchWithPagingByDynamicFilter(CafeSearchRequest request) { + public PagedResponse searchWithPagingByDynamicFilter(CafeSearchRequest request) { Pageable pageable = PageRequestCustom.of(request.getPage(), request.getSizePerPage()); CafeSearchCondition cafeSearchCondition = cafeMapper.toCafeSearchCondition(request); Page pagedCafes = cafeQueryDslRepository.findWithDynamicFilter(cafeSearchCondition, pageable); return createPagedResponse(pagedCafes, - cafeMapper.toCafeSearchResponses(pagedCafes.getContent(), openChecker)); + cafeMapper.toCafeSearchListResponses(pagedCafes.getContent(), openChecker)); } @Override - public CafeSearchResponse searchCafeBasicInfoById(Long cafeId) { + public CafeSearchListResponse searchCafeBasicInfoById(Long cafeId) { return cafeMapper.toCafeSearchResponse(findCafeById(cafeId), openChecker); } @@ -95,13 +95,13 @@ public CafeResponse searchCafeForNotMemberByCafeId(Long cafeId) { ); } - private PagedResponse createPagedResponse(Page pagedCafes, - List cafeSearchResponses) { + private PagedResponse createPagedResponse(Page pagedCafes, + List cafeSearchListRespons) { return PagedResponse.createWithFirstPageAsOne( pagedCafes.getNumber(), pagedCafes.getTotalPages(), pagedCafes.getNumberOfElements(), - cafeSearchResponses + cafeSearchListRespons ); } From 4551c7172edd074480c24ca3c5efc80eb7a7c35f Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 16:20:15 +0900 Subject: [PATCH 02/12] =?UTF-8?q?rename:=20CafeResponse=EB=A5=BC=20CafeSea?= =?UTF-8?q?rchResponse=EB=A1=9C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/demo/controller/CafeController.java | 8 ++++---- .../{CafeResponse.java => CafeSearchResponse.java} | 2 +- .../java/com/example/demo/mapper/CafeMapper.java | 10 +++++----- .../com/example/demo/service/cafe/CafeService.java | 6 +++--- .../example/demo/service/cafe/CafeServiceImpl.java | 14 +++++++------- 5 files changed, 20 insertions(+), 20 deletions(-) rename src/main/java/com/example/demo/dto/cafe/{CafeResponse.java => CafeSearchResponse.java} (93%) diff --git a/src/main/java/com/example/demo/controller/CafeController.java b/src/main/java/com/example/demo/controller/CafeController.java index 477bca4..27cf048 100644 --- a/src/main/java/com/example/demo/controller/CafeController.java +++ b/src/main/java/com/example/demo/controller/CafeController.java @@ -11,9 +11,9 @@ import com.example.demo.domain.auth.CafegoryTokenManager; import com.example.demo.dto.PagedResponse; -import com.example.demo.dto.cafe.CafeResponse; import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; +import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.service.cafe.CafeService; import lombok.RequiredArgsConstructor; @@ -34,14 +34,14 @@ public ResponseEntity> searchCafeList( } @GetMapping("/cafe/{cafeId}") - public ResponseEntity searchCafe(@PathVariable Long cafeId, + public ResponseEntity searchCafe(@PathVariable Long cafeId, @RequestHeader(value = "Authorization", required = false) String authorization) { if (StringUtils.hasText(authorization)) { long memberId = cafegoryTokenManager.getIdentityId(authorization); - CafeResponse response = cafeService.searchCafeForMemberByCafeId(cafeId, memberId); + CafeSearchResponse response = cafeService.searchCafeForMemberByCafeId(cafeId, memberId); return new ResponseEntity<>(response, HttpStatus.OK); } - CafeResponse response = cafeService.searchCafeForNotMemberByCafeId(cafeId); + CafeSearchResponse response = cafeService.searchCafeForNotMemberByCafeId(cafeId); return new ResponseEntity<>(response, HttpStatus.OK); } diff --git a/src/main/java/com/example/demo/dto/cafe/CafeResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java similarity index 93% rename from src/main/java/com/example/demo/dto/cafe/CafeResponse.java rename to src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java index d8b9f42..99ca1d6 100644 --- a/src/main/java/com/example/demo/dto/cafe/CafeResponse.java +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java @@ -11,7 +11,7 @@ @Getter @Builder -public class CafeResponse { +public class CafeSearchResponse { private final CafeBasicInfoResponse basicInfo; private final List review; diff --git a/src/main/java/com/example/demo/mapper/CafeMapper.java b/src/main/java/com/example/demo/mapper/CafeMapper.java index 98f40ca..2f2436d 100644 --- a/src/main/java/com/example/demo/mapper/CafeMapper.java +++ b/src/main/java/com/example/demo/mapper/CafeMapper.java @@ -10,9 +10,9 @@ import com.example.demo.domain.cafe.OpenChecker; import com.example.demo.dto.cafe.BusinessHourResponse; import com.example.demo.dto.cafe.CafeBasicInfoResponse; -import com.example.demo.dto.cafe.CafeResponse; import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; +import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.dto.cafe.SnsResponse; import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.study.CanMakeStudyOnceResponse; @@ -82,14 +82,14 @@ public CafeSearchCondition toCafeSearchCondition(CafeSearchRequest request) { .build(); } - public CafeResponse toCafeResponse( + public CafeSearchResponse toCafeSearchResponse( Cafe findCafe, List businessHourResponses, List snsResponses, List reviewResponses, List studyOnceForCafeResponses, OpenChecker openChecker) { - return CafeResponse.builder() + return CafeSearchResponse.builder() .basicInfo( toCafeBasicInfoResponse( findCafe, @@ -109,14 +109,14 @@ public CafeResponse toCafeResponse( .build(); } - public CafeResponse toCafeResponseWithEmptyInfo( + public CafeSearchResponse toCafeSearchResponseWithEmptyInfo( Cafe findCafe, List businessHourResponses, List snsResponses, List reviewResponses, OpenChecker openChecker ) { - return CafeResponse.builder() + return CafeSearchResponse.builder() .basicInfo( toCafeBasicInfoResponse( findCafe, diff --git a/src/main/java/com/example/demo/service/cafe/CafeService.java b/src/main/java/com/example/demo/service/cafe/CafeService.java index 2655512..009b0d1 100644 --- a/src/main/java/com/example/demo/service/cafe/CafeService.java +++ b/src/main/java/com/example/demo/service/cafe/CafeService.java @@ -1,9 +1,9 @@ package com.example.demo.service.cafe; import com.example.demo.dto.PagedResponse; -import com.example.demo.dto.cafe.CafeResponse; import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; +import com.example.demo.dto.cafe.CafeSearchResponse; public interface CafeService { @@ -11,8 +11,8 @@ public interface CafeService { CafeSearchListResponse searchCafeBasicInfoById(Long cafeId); - CafeResponse searchCafeForMemberByCafeId(Long cafeId, Long memberId); + CafeSearchResponse searchCafeForMemberByCafeId(Long cafeId, Long memberId); - CafeResponse searchCafeForNotMemberByCafeId(Long cafeId); + CafeSearchResponse searchCafeForNotMemberByCafeId(Long cafeId); } diff --git a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java index ac7716c..1cf4b1d 100644 --- a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java +++ b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java @@ -15,9 +15,9 @@ import com.example.demo.domain.cafe.CafeSearchCondition; import com.example.demo.domain.cafe.OpenChecker; import com.example.demo.dto.PagedResponse; -import com.example.demo.dto.cafe.CafeResponse; import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; +import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.mapper.BusinessHourMapper; import com.example.demo.mapper.CafeMapper; @@ -68,12 +68,12 @@ private Cafe findCafeById(Long cafeId) { } @Override - public CafeResponse searchCafeForMemberByCafeId(Long cafeId, Long memberId) { + public CafeSearchResponse searchCafeForMemberByCafeId(Long cafeId, Long memberId) { Cafe findCafe = findCafeById(cafeId); if (!memberRepository.existsById(memberId)) { throw new CafegoryException(MEMBER_NOT_FOUND); } - return cafeMapper.toCafeResponse( + return cafeMapper.toCafeSearchResponse( findCafe, businessHourMapper.toBusinessHourResponses(findCafe.getBusinessHours()), snsDetailMapper.toSnsResponses(findCafe.getSnsDetails()), @@ -84,9 +84,9 @@ public CafeResponse searchCafeForMemberByCafeId(Long cafeId, Long memberId) { } @Override - public CafeResponse searchCafeForNotMemberByCafeId(Long cafeId) { + public CafeSearchResponse searchCafeForNotMemberByCafeId(Long cafeId) { Cafe findCafe = findCafeById(cafeId); - return cafeMapper.toCafeResponseWithEmptyInfo( + return cafeMapper.toCafeSearchResponseWithEmptyInfo( findCafe, businessHourMapper.toBusinessHourResponses(findCafe.getBusinessHours()), snsDetailMapper.toSnsResponses(findCafe.getSnsDetails()), @@ -96,12 +96,12 @@ public CafeResponse searchCafeForNotMemberByCafeId(Long cafeId) { } private PagedResponse createPagedResponse(Page pagedCafes, - List cafeSearchListRespons) { + List cafeSearchListResponse) { return PagedResponse.createWithFirstPageAsOne( pagedCafes.getNumber(), pagedCafes.getTotalPages(), pagedCafes.getNumberOfElements(), - cafeSearchListRespons + cafeSearchListResponse ); } From b6a820bbf375f3a3b4234d347663565544abc725 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 17:31:47 +0900 Subject: [PATCH 03/12] =?UTF-8?q?refactor:=20=EC=B9=B4=ED=8E=98=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20dto=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/CafeController.java | 6 +++--- .../demo/dto/cafe/CafeSearchListRequest.java | 19 +++++++++++++++++++ .../com/example/demo/mapper/CafeMapper.java | 11 +++++++++++ .../demo/service/cafe/CafeService.java | 4 ++-- .../demo/service/cafe/CafeServiceImpl.java | 4 ++-- 5 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchListRequest.java diff --git a/src/main/java/com/example/demo/controller/CafeController.java b/src/main/java/com/example/demo/controller/CafeController.java index 27cf048..496836f 100644 --- a/src/main/java/com/example/demo/controller/CafeController.java +++ b/src/main/java/com/example/demo/controller/CafeController.java @@ -11,8 +11,8 @@ import com.example.demo.domain.auth.CafegoryTokenManager; import com.example.demo.dto.PagedResponse; +import com.example.demo.dto.cafe.CafeSearchListRequest; import com.example.demo.dto.cafe.CafeSearchListResponse; -import com.example.demo.dto.cafe.CafeSearchRequest; import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.service.cafe.CafeService; @@ -27,9 +27,9 @@ public class CafeController { @GetMapping("/cafe/list") public ResponseEntity> searchCafeList( - @ModelAttribute CafeSearchRequest cafeSearchRequest) { + @ModelAttribute CafeSearchListRequest cafeSearchListRequest) { PagedResponse response = cafeService.searchWithPagingByDynamicFilter( - cafeSearchRequest); + cafeSearchListRequest); return new ResponseEntity<>(response, HttpStatus.OK); } diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchListRequest.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchListRequest.java new file mode 100644 index 0000000..ee2b77f --- /dev/null +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchListRequest.java @@ -0,0 +1,19 @@ +package com.example.demo.dto.cafe; + +import com.example.demo.dto.PagedRequest; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class CafeSearchListRequest extends PagedRequest { + private int startTime = 0; + private int endTime = 24; + private boolean canStudy; + private int minBeveragePrice = 0; + private int maxTime = 0; + private String area; +} diff --git a/src/main/java/com/example/demo/mapper/CafeMapper.java b/src/main/java/com/example/demo/mapper/CafeMapper.java index 2f2436d..8fd758b 100644 --- a/src/main/java/com/example/demo/mapper/CafeMapper.java +++ b/src/main/java/com/example/demo/mapper/CafeMapper.java @@ -10,6 +10,7 @@ import com.example.demo.domain.cafe.OpenChecker; import com.example.demo.dto.cafe.BusinessHourResponse; import com.example.demo.dto.cafe.CafeBasicInfoResponse; +import com.example.demo.dto.cafe.CafeSearchListRequest; import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; import com.example.demo.dto.cafe.CafeSearchResponse; @@ -82,6 +83,16 @@ public CafeSearchCondition toCafeSearchCondition(CafeSearchRequest request) { .build(); } + public CafeSearchCondition toCafeSearchCondition(CafeSearchListRequest request) { + return new CafeSearchCondition.Builder(request.isCanStudy(), + request.getArea()) + .maxTime(request.getMaxTime()) + .minMenuPrice(request.getMinBeveragePrice()) + .startTime(request.getStartTime()) + .endTime(request.getEndTime()) + .build(); + } + public CafeSearchResponse toCafeSearchResponse( Cafe findCafe, List businessHourResponses, diff --git a/src/main/java/com/example/demo/service/cafe/CafeService.java b/src/main/java/com/example/demo/service/cafe/CafeService.java index 009b0d1..dd4f6dc 100644 --- a/src/main/java/com/example/demo/service/cafe/CafeService.java +++ b/src/main/java/com/example/demo/service/cafe/CafeService.java @@ -1,13 +1,13 @@ package com.example.demo.service.cafe; import com.example.demo.dto.PagedResponse; +import com.example.demo.dto.cafe.CafeSearchListRequest; import com.example.demo.dto.cafe.CafeSearchListResponse; -import com.example.demo.dto.cafe.CafeSearchRequest; import com.example.demo.dto.cafe.CafeSearchResponse; public interface CafeService { - PagedResponse searchWithPagingByDynamicFilter(CafeSearchRequest request); + PagedResponse searchWithPagingByDynamicFilter(CafeSearchListRequest request); CafeSearchListResponse searchCafeBasicInfoById(Long cafeId); diff --git a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java index 1cf4b1d..810db38 100644 --- a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java +++ b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java @@ -15,8 +15,8 @@ import com.example.demo.domain.cafe.CafeSearchCondition; import com.example.demo.domain.cafe.OpenChecker; import com.example.demo.dto.PagedResponse; +import com.example.demo.dto.cafe.CafeSearchListRequest; import com.example.demo.dto.cafe.CafeSearchListResponse; -import com.example.demo.dto.cafe.CafeSearchRequest; import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.mapper.BusinessHourMapper; @@ -47,7 +47,7 @@ public class CafeServiceImpl implements CafeService { private final StudyOnceMapper studyOnceMapper; @Override - public PagedResponse searchWithPagingByDynamicFilter(CafeSearchRequest request) { + public PagedResponse searchWithPagingByDynamicFilter(CafeSearchListRequest request) { Pageable pageable = PageRequestCustom.of(request.getPage(), request.getSizePerPage()); CafeSearchCondition cafeSearchCondition = cafeMapper.toCafeSearchCondition(request); From 444195faa609abf6d99709f28b86bf80b4f43e50 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 19:33:33 +0900 Subject: [PATCH 04/12] =?UTF-8?q?refactor:=20=EC=B9=B4=ED=8E=98=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20dto=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/cafe/CafeSearchBasicInfoResponse.java | 21 ++++++++ .../cafe/CafeSearchBusinessHourResponse.java | 12 +++++ .../demo/dto/cafe/CafeSearchResponse.java | 8 ++- .../dto/cafe/CafeSearchReviewResponse.java | 13 +++++ .../demo/dto/cafe/CafeSearchSnsResponse.java | 11 ++++ .../dto/cafe/CafeSearchStudyOnceResponse.java | 19 +++++++ .../dto/cafe/CafeSearchWriterResponse.java | 12 +++++ .../demo/mapper/BusinessHourMapper.java | 8 +++ .../com/example/demo/mapper/CafeMapper.java | 51 +++++++++++++------ .../com/example/demo/mapper/ReviewMapper.java | 34 +++++++++++++ .../example/demo/mapper/SnsDetailMapper.java | 7 +++ .../example/demo/mapper/StudyOnceMapper.java | 18 +++++++ .../demo/service/cafe/CafeServiceImpl.java | 14 ++--- 13 files changed, 201 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchBasicInfoResponse.java create mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchBusinessHourResponse.java create mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchReviewResponse.java create mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchSnsResponse.java create mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchStudyOnceResponse.java create mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchWriterResponse.java diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchBasicInfoResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchBasicInfoResponse.java new file mode 100644 index 0000000..595fe63 --- /dev/null +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchBasicInfoResponse.java @@ -0,0 +1,21 @@ +package com.example.demo.dto.cafe; + +import java.util.List; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class CafeSearchBasicInfoResponse { + private final long cafeId; + private final String name; + private final String address; + private final List businessHours; + private final Boolean isOpen; + private final List sns; + private final String phone; + private final int minBeveragePrice; + private final int maxTime; + private final double avgReviewRate; +} diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchBusinessHourResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchBusinessHourResponse.java new file mode 100644 index 0000000..a36e424 --- /dev/null +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchBusinessHourResponse.java @@ -0,0 +1,12 @@ +package com.example.demo.dto.cafe; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class CafeSearchBusinessHourResponse { + private final String day; + private final String startTime; + private final String endTime; +} diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java index 99ca1d6..bf75e4b 100644 --- a/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java @@ -2,9 +2,7 @@ import java.util.List; -import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.study.CanMakeStudyOnceResponse; -import com.example.demo.dto.study.StudyOnceForCafeResponse; import lombok.Builder; import lombok.Getter; @@ -13,8 +11,8 @@ @Builder public class CafeSearchResponse { - private final CafeBasicInfoResponse basicInfo; - private final List review; - private final List meetings; + private final CafeSearchBasicInfoResponse basicInfo; + private final List review; + private final List meetings; private final List canMakeMeeting; } diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchReviewResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchReviewResponse.java new file mode 100644 index 0000000..35538ab --- /dev/null +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchReviewResponse.java @@ -0,0 +1,13 @@ +package com.example.demo.dto.cafe; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CafeSearchReviewResponse { + private final long reviewId; + private final CafeSearchWriterResponse writer; + private final double rate; + private final String content; +} diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchSnsResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchSnsResponse.java new file mode 100644 index 0000000..94214e1 --- /dev/null +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchSnsResponse.java @@ -0,0 +1,11 @@ +package com.example.demo.dto.cafe; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class CafeSearchSnsResponse { + private final String name; + private final String url; +} diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchStudyOnceResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchStudyOnceResponse.java new file mode 100644 index 0000000..f62e61e --- /dev/null +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchStudyOnceResponse.java @@ -0,0 +1,19 @@ +package com.example.demo.dto.cafe; + +import java.time.LocalDateTime; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CafeSearchStudyOnceResponse { + private long cafeId; + private long studyOnceId; + private String name; + private LocalDateTime startDateTime; + private LocalDateTime endDateTime; + private int maxMemberCount; + private int nowMemberCount; + private boolean isEnd; +} diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchWriterResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchWriterResponse.java new file mode 100644 index 0000000..e4d5f45 --- /dev/null +++ b/src/main/java/com/example/demo/dto/cafe/CafeSearchWriterResponse.java @@ -0,0 +1,12 @@ +package com.example.demo.dto.cafe; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class CafeSearchWriterResponse { + private final long memberId; + private final String name; + private final String thumbnailImg; +} diff --git a/src/main/java/com/example/demo/mapper/BusinessHourMapper.java b/src/main/java/com/example/demo/mapper/BusinessHourMapper.java index 5580a23..26e969e 100644 --- a/src/main/java/com/example/demo/mapper/BusinessHourMapper.java +++ b/src/main/java/com/example/demo/mapper/BusinessHourMapper.java @@ -5,6 +5,7 @@ import com.example.demo.domain.cafe.BusinessHour; import com.example.demo.dto.cafe.BusinessHourResponse; +import com.example.demo.dto.cafe.CafeSearchBusinessHourResponse; public class BusinessHourMapper { @@ -15,4 +16,11 @@ public List toBusinessHourResponses(List bus .collect(Collectors.toList()); } + public List toCafeSearchBusinessHourResponses(List businessHours) { + return businessHours.stream() + .map(hour -> new CafeSearchBusinessHourResponse(hour.getDay(), hour.getStartTime().toString(), + hour.getEndTime().toString())) + .collect(Collectors.toList()); + } + } diff --git a/src/main/java/com/example/demo/mapper/CafeMapper.java b/src/main/java/com/example/demo/mapper/CafeMapper.java index 8fd758b..5b23afd 100644 --- a/src/main/java/com/example/demo/mapper/CafeMapper.java +++ b/src/main/java/com/example/demo/mapper/CafeMapper.java @@ -10,14 +10,17 @@ import com.example.demo.domain.cafe.OpenChecker; import com.example.demo.dto.cafe.BusinessHourResponse; import com.example.demo.dto.cafe.CafeBasicInfoResponse; +import com.example.demo.dto.cafe.CafeSearchBasicInfoResponse; +import com.example.demo.dto.cafe.CafeSearchBusinessHourResponse; import com.example.demo.dto.cafe.CafeSearchListRequest; import com.example.demo.dto.cafe.CafeSearchListResponse; import com.example.demo.dto.cafe.CafeSearchRequest; import com.example.demo.dto.cafe.CafeSearchResponse; +import com.example.demo.dto.cafe.CafeSearchReviewResponse; +import com.example.demo.dto.cafe.CafeSearchSnsResponse; +import com.example.demo.dto.cafe.CafeSearchStudyOnceResponse; import com.example.demo.dto.cafe.SnsResponse; -import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.study.CanMakeStudyOnceResponse; -import com.example.demo.dto.study.StudyOnceForCafeResponse; public class CafeMapper { @@ -73,6 +76,24 @@ public CafeBasicInfoResponse toCafeBasicInfoResponse(Cafe cafe, ); } + public CafeSearchBasicInfoResponse toCafeSearchBasicInfoResponse(Cafe cafe, + List cafeSearchBusinessHourResponses, + List cafeSearchSnsResponses, + OpenChecker openChecker) { + return new CafeSearchBasicInfoResponse( + cafe.getId(), + cafe.getName(), + cafe.showFullAddress(), + cafeSearchBusinessHourResponses, + cafe.isOpen(openChecker), + cafeSearchSnsResponses, + cafe.getPhone(), + cafe.getMinBeveragePrice(), + cafe.getMaxAllowableStay().getValue(), + cafe.getAvgReviewRate() + ); + } + public CafeSearchCondition toCafeSearchCondition(CafeSearchRequest request) { return new CafeSearchCondition.Builder(request.isCanStudy(), request.getArea()) @@ -95,24 +116,24 @@ public CafeSearchCondition toCafeSearchCondition(CafeSearchListRequest request) public CafeSearchResponse toCafeSearchResponse( Cafe findCafe, - List businessHourResponses, - List snsResponses, - List reviewResponses, - List studyOnceForCafeResponses, + List cafeSearchBusinessHourResponses, + List cafeSearchSnsResponses, + List cafeSearchReviewResponses, + List cafeSearchStudyOnceResponses, OpenChecker openChecker) { return CafeSearchResponse.builder() .basicInfo( - toCafeBasicInfoResponse( + toCafeSearchBasicInfoResponse( findCafe, - businessHourResponses, - snsResponses, + cafeSearchBusinessHourResponses, + cafeSearchSnsResponses, openChecker) ) .review( - reviewResponses + cafeSearchReviewResponses ) .meetings( - studyOnceForCafeResponses + cafeSearchStudyOnceResponses ) .canMakeMeeting( List.of(new CanMakeStudyOnceResponse(), new CanMakeStudyOnceResponse()) @@ -122,14 +143,14 @@ public CafeSearchResponse toCafeSearchResponse( public CafeSearchResponse toCafeSearchResponseWithEmptyInfo( Cafe findCafe, - List businessHourResponses, - List snsResponses, - List reviewResponses, + List businessHourResponses, + List snsResponses, + List reviewResponses, OpenChecker openChecker ) { return CafeSearchResponse.builder() .basicInfo( - toCafeBasicInfoResponse( + toCafeSearchBasicInfoResponse( findCafe, businessHourResponses, snsResponses, diff --git a/src/main/java/com/example/demo/mapper/ReviewMapper.java b/src/main/java/com/example/demo/mapper/ReviewMapper.java index b79cb19..fcae38e 100644 --- a/src/main/java/com/example/demo/mapper/ReviewMapper.java +++ b/src/main/java/com/example/demo/mapper/ReviewMapper.java @@ -6,6 +6,8 @@ import com.example.demo.domain.member.Member; import com.example.demo.domain.review.Review; import com.example.demo.dto.WriterResponse; +import com.example.demo.dto.cafe.CafeSearchReviewResponse; +import com.example.demo.dto.cafe.CafeSearchWriterResponse; import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.review.ReviewSearchResponse; @@ -57,6 +59,31 @@ public List toReviewResponses(List reviews) { .collect(Collectors.toList()); } + public List toCafeSearchReviewResponses(List reviews) { + return reviews.stream() + .map(review -> + makeCafeSearchReviewResponse( + review.getId(), + makeCafeSearchWriterResponse(review.getMember()), + review.getRate(), + review.getContent() + ) + ) + .collect(Collectors.toList()); + } + + private CafeSearchReviewResponse makeCafeSearchReviewResponse(Long reviewId, + CafeSearchWriterResponse writerResponse, + double rate, + String content) { + return CafeSearchReviewResponse.builder() + .reviewId(reviewId) + .writer(writerResponse) + .rate(rate) + .content(content) + .build(); + } + private ReviewResponse produceReviewResponse(Long reviewId, WriterResponse writerResponse, double rate, String content) { return ReviewResponse.builder() @@ -74,4 +101,11 @@ private WriterResponse productWriterResponse(Member member) { ); } + private CafeSearchWriterResponse makeCafeSearchWriterResponse(Member member) { + return new CafeSearchWriterResponse(member.getId(), + member.getName(), + member.getThumbnailImage().getThumbnailImage() + ); + } + } diff --git a/src/main/java/com/example/demo/mapper/SnsDetailMapper.java b/src/main/java/com/example/demo/mapper/SnsDetailMapper.java index 0e2aeed..69f4691 100644 --- a/src/main/java/com/example/demo/mapper/SnsDetailMapper.java +++ b/src/main/java/com/example/demo/mapper/SnsDetailMapper.java @@ -4,6 +4,7 @@ import java.util.stream.Collectors; import com.example.demo.domain.cafe.SnsDetail; +import com.example.demo.dto.cafe.CafeSearchSnsResponse; import com.example.demo.dto.cafe.SnsResponse; public class SnsDetailMapper { @@ -13,4 +14,10 @@ public List toSnsResponses(List snsDetails) { .map(snsDetail -> new SnsResponse(snsDetail.getName(), snsDetail.getUrl())) .collect(Collectors.toList()); } + + public List toCafeSearchSnsResponses(List snsDetails) { + return snsDetails.stream() + .map(snsDetail -> new CafeSearchSnsResponse(snsDetail.getName(), snsDetail.getUrl())) + .collect(Collectors.toList()); + } } diff --git a/src/main/java/com/example/demo/mapper/StudyOnceMapper.java b/src/main/java/com/example/demo/mapper/StudyOnceMapper.java index c50aa76..c0bb3a6 100644 --- a/src/main/java/com/example/demo/mapper/StudyOnceMapper.java +++ b/src/main/java/com/example/demo/mapper/StudyOnceMapper.java @@ -8,6 +8,7 @@ import com.example.demo.domain.study.StudyOnce; import com.example.demo.domain.study.StudyOnceComment; import com.example.demo.dto.WriterResponse; +import com.example.demo.dto.cafe.CafeSearchStudyOnceResponse; import com.example.demo.dto.study.StudyOnceCommentResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; @@ -35,6 +36,23 @@ public List toStudyOnceForCafeResponse(Cafe findCafe) .collect(Collectors.toList()); } + public List toCafeSearchStudyOnceResponse(Cafe findCafe) { + return findCafe.getStudyOnceGroup().stream() + .map(studyOnce -> + CafeSearchStudyOnceResponse.builder() + .cafeId(findCafe.getId()) + .studyOnceId(studyOnce.getId()) + .name(studyOnce.getName()) + .startDateTime(studyOnce.getStartDateTime()) + .endDateTime(studyOnce.getEndDateTime()) + .maxMemberCount(studyOnce.getMaxMemberCount()) + .nowMemberCount(studyOnce.getNowMemberCount()) + .isEnd(studyOnce.isAbleToTalk()) + .build() + ) + .collect(Collectors.toList()); + } + public StudyOnce toNewEntity(StudyOnceCreateRequest studyOnceCreateRequest, Cafe cafe, Member leader) { return StudyOnce.builder() diff --git a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java index 810db38..d72fba5 100644 --- a/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java +++ b/src/main/java/com/example/demo/service/cafe/CafeServiceImpl.java @@ -75,10 +75,10 @@ public CafeSearchResponse searchCafeForMemberByCafeId(Long cafeId, Long memberId } return cafeMapper.toCafeSearchResponse( findCafe, - businessHourMapper.toBusinessHourResponses(findCafe.getBusinessHours()), - snsDetailMapper.toSnsResponses(findCafe.getSnsDetails()), - reviewMapper.toReviewResponses(findCafe.getReviews()), - studyOnceMapper.toStudyOnceForCafeResponse(findCafe), + businessHourMapper.toCafeSearchBusinessHourResponses(findCafe.getBusinessHours()), + snsDetailMapper.toCafeSearchSnsResponses(findCafe.getSnsDetails()), + reviewMapper.toCafeSearchReviewResponses(findCafe.getReviews()), + studyOnceMapper.toCafeSearchStudyOnceResponse(findCafe), openChecker ); } @@ -88,9 +88,9 @@ public CafeSearchResponse searchCafeForNotMemberByCafeId(Long cafeId) { Cafe findCafe = findCafeById(cafeId); return cafeMapper.toCafeSearchResponseWithEmptyInfo( findCafe, - businessHourMapper.toBusinessHourResponses(findCafe.getBusinessHours()), - snsDetailMapper.toSnsResponses(findCafe.getSnsDetails()), - reviewMapper.toReviewResponses(findCafe.getReviews()), + businessHourMapper.toCafeSearchBusinessHourResponses(findCafe.getBusinessHours()), + snsDetailMapper.toCafeSearchSnsResponses(findCafe.getSnsDetails()), + reviewMapper.toCafeSearchReviewResponses(findCafe.getReviews()), openChecker ); } From dc23342a3c565cde4a60f638e8a89a2874abd489 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 19:41:49 +0900 Subject: [PATCH 05/12] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=A9=94=EC=9D=BC?= =?UTF-8?q?=20=EC=A0=84=EC=86=A1=20dto=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/controller/MailController.java | 11 ++++++----- .../dto/email/EmailSendCustomTemplateResponse.java | 11 +++++++++++ .../demo/dto/email/EmailSendTemplateResponse.java | 11 +++++++++++ .../com/example/demo/service/email/MailService.java | 7 ++++--- .../example/demo/service/email/MailServiceImpl.java | 11 ++++++----- 5 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/example/demo/dto/email/EmailSendCustomTemplateResponse.java create mode 100644 src/main/java/com/example/demo/dto/email/EmailSendTemplateResponse.java diff --git a/src/main/java/com/example/demo/controller/MailController.java b/src/main/java/com/example/demo/controller/MailController.java index c38c6a6..0885cf8 100644 --- a/src/main/java/com/example/demo/controller/MailController.java +++ b/src/main/java/com/example/demo/controller/MailController.java @@ -8,8 +8,9 @@ import com.example.demo.domain.auth.CafegoryTokenManager; import com.example.demo.dto.email.CustomEmailSendRequest; +import com.example.demo.dto.email.EmailSendCustomTemplateResponse; import com.example.demo.dto.email.EmailSendRequest; -import com.example.demo.dto.email.EmailTemplateResponse; +import com.example.demo.dto.email.EmailSendTemplateResponse; import com.example.demo.service.email.MailService; import lombok.RequiredArgsConstructor; @@ -22,18 +23,18 @@ public class MailController { private final MailService mailService; @PostMapping("/email") - public ResponseEntity sendEmail( + public ResponseEntity sendEmail( @RequestHeader("Authorization") String authorization, @RequestBody EmailSendRequest request) { cafegoryTokenManager.getIdentityId(authorization); - EmailTemplateResponse response = mailService.sendEmail(request); + EmailSendTemplateResponse response = mailService.sendEmail(request); return ResponseEntity.ok(response); } @PostMapping("/email/custom") - public ResponseEntity sendCustomEmail( + public ResponseEntity sendCustomEmail( @RequestHeader("Authorization") String authorization, @RequestBody CustomEmailSendRequest request) { cafegoryTokenManager.getIdentityId(authorization); - EmailTemplateResponse response = mailService.sendCustomEmail(request); + EmailSendCustomTemplateResponse response = mailService.sendCustomEmail(request); return ResponseEntity.ok(response); } } diff --git a/src/main/java/com/example/demo/dto/email/EmailSendCustomTemplateResponse.java b/src/main/java/com/example/demo/dto/email/EmailSendCustomTemplateResponse.java new file mode 100644 index 0000000..86ce351 --- /dev/null +++ b/src/main/java/com/example/demo/dto/email/EmailSendCustomTemplateResponse.java @@ -0,0 +1,11 @@ +package com.example.demo.dto.email; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class EmailSendCustomTemplateResponse { + private final String title; + private final String content; +} diff --git a/src/main/java/com/example/demo/dto/email/EmailSendTemplateResponse.java b/src/main/java/com/example/demo/dto/email/EmailSendTemplateResponse.java new file mode 100644 index 0000000..84651da --- /dev/null +++ b/src/main/java/com/example/demo/dto/email/EmailSendTemplateResponse.java @@ -0,0 +1,11 @@ +package com.example.demo.dto.email; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class EmailSendTemplateResponse { + private final String title; + private final String content; +} diff --git a/src/main/java/com/example/demo/service/email/MailService.java b/src/main/java/com/example/demo/service/email/MailService.java index adcfbfc..4af07bb 100644 --- a/src/main/java/com/example/demo/service/email/MailService.java +++ b/src/main/java/com/example/demo/service/email/MailService.java @@ -1,12 +1,13 @@ package com.example.demo.service.email; import com.example.demo.dto.email.CustomEmailSendRequest; +import com.example.demo.dto.email.EmailSendCustomTemplateResponse; import com.example.demo.dto.email.EmailSendRequest; -import com.example.demo.dto.email.EmailTemplateResponse; +import com.example.demo.dto.email.EmailSendTemplateResponse; public interface MailService { - EmailTemplateResponse sendEmail(EmailSendRequest request); + EmailSendTemplateResponse sendEmail(EmailSendRequest request); - EmailTemplateResponse sendCustomEmail(CustomEmailSendRequest request); + EmailSendCustomTemplateResponse sendCustomEmail(CustomEmailSendRequest request); } diff --git a/src/main/java/com/example/demo/service/email/MailServiceImpl.java b/src/main/java/com/example/demo/service/email/MailServiceImpl.java index b312308..9d5990d 100644 --- a/src/main/java/com/example/demo/service/email/MailServiceImpl.java +++ b/src/main/java/com/example/demo/service/email/MailServiceImpl.java @@ -8,8 +8,9 @@ import com.example.demo.domain.email.EmailTemplate; import com.example.demo.domain.member.Member; import com.example.demo.dto.email.CustomEmailSendRequest; +import com.example.demo.dto.email.EmailSendCustomTemplateResponse; import com.example.demo.dto.email.EmailSendRequest; -import com.example.demo.dto.email.EmailTemplateResponse; +import com.example.demo.dto.email.EmailSendTemplateResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.repository.member.MemberRepository; @@ -23,22 +24,22 @@ public class MailServiceImpl implements MailService { private final MemberRepository memberRepository; @Override - public EmailTemplateResponse sendEmail(EmailSendRequest request) { + public EmailSendTemplateResponse sendEmail(EmailSendRequest request) { EmailTemplate template = EmailTemplate.valueOf(request.getMessageType()); for (Long memberId : request.getMemberIds()) { emailSender.sendSimpleMessage(findMemberById(memberId).getEmail(), template.getSubject(), template.getContent()); } - return new EmailTemplateResponse(template.getSubject(), template.getContent()); + return new EmailSendTemplateResponse(template.getSubject(), template.getContent()); } @Override - public EmailTemplateResponse sendCustomEmail(CustomEmailSendRequest request) { + public EmailSendCustomTemplateResponse sendCustomEmail(CustomEmailSendRequest request) { for (Long memberId : request.getMemberIds()) { emailSender.sendSimpleMessage(findMemberById(memberId).getEmail(), request.getTitle(), request.getContent()); } - return new EmailTemplateResponse(request.getTitle(), request.getContent()); + return new EmailSendCustomTemplateResponse(request.getTitle(), request.getContent()); } private Member findMemberById(Long memberId) { From fa31658f4f2cf08b5a12c576b96857c44668e359 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 19:52:24 +0900 Subject: [PATCH 06/12] =?UTF-8?q?refactor:=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C,=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=20dto=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/ProfileController.java | 14 ++++++----- .../demo/dto/profile/ProfileGetResponse.java | 16 ++++++++++++ .../dto/profile/ProfileUpdateResponse.java | 16 ++++++++++++ .../demo/service/profile/ProfileService.java | 11 ++++---- .../service/profile/ProfileServiceImpl.java | 25 ++++++++++++------- .../profile/ProfileServiceImplTest.java | 6 ++--- 6 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 src/main/java/com/example/demo/dto/profile/ProfileGetResponse.java create mode 100644 src/main/java/com/example/demo/dto/profile/ProfileUpdateResponse.java diff --git a/src/main/java/com/example/demo/controller/ProfileController.java b/src/main/java/com/example/demo/controller/ProfileController.java index c626e58..97b5bf1 100644 --- a/src/main/java/com/example/demo/controller/ProfileController.java +++ b/src/main/java/com/example/demo/controller/ProfileController.java @@ -10,8 +10,9 @@ import org.springframework.web.bind.annotation.RestController; import com.example.demo.domain.auth.CafegoryTokenManager; -import com.example.demo.dto.profile.ProfileResponse; +import com.example.demo.dto.profile.ProfileGetResponse; import com.example.demo.dto.profile.ProfileUpdateRequest; +import com.example.demo.dto.profile.ProfileUpdateResponse; import com.example.demo.service.profile.ProfileService; import lombok.RequiredArgsConstructor; @@ -24,19 +25,20 @@ public class ProfileController { private final CafegoryTokenManager cafegoryTokenManager; @GetMapping("/{memberId:[0-9]+}") - public ResponseEntity get(@PathVariable("memberId") Long targetMemberId, + public ResponseEntity get(@PathVariable("memberId") Long targetMemberId, @RequestHeader("Authorization") String authorization) { long requestMemberId = cafegoryTokenManager.getIdentityId(authorization); - ProfileResponse profileResponse = profileService.get(requestMemberId, targetMemberId); - return ResponseEntity.ok(profileResponse); + ProfileGetResponse profileGetResponse = profileService.get(requestMemberId, targetMemberId); + return ResponseEntity.ok(profileGetResponse); } @PatchMapping("/{memberId:[0-9]+}") - public ResponseEntity update(@PathVariable("memberId") Long targetMemberId, + public ResponseEntity update(@PathVariable("memberId") Long targetMemberId, @RequestBody ProfileUpdateRequest profileUpdateRequest, @RequestHeader("Authorization") String authorization) { long requestMemberId = cafegoryTokenManager.getIdentityId(authorization); - ProfileResponse profileResponse = profileService.update(requestMemberId, targetMemberId, profileUpdateRequest); + ProfileUpdateResponse profileResponse = profileService.update(requestMemberId, targetMemberId, + profileUpdateRequest); return ResponseEntity.ok(profileResponse); } } diff --git a/src/main/java/com/example/demo/dto/profile/ProfileGetResponse.java b/src/main/java/com/example/demo/dto/profile/ProfileGetResponse.java new file mode 100644 index 0000000..03b58ee --- /dev/null +++ b/src/main/java/com/example/demo/dto/profile/ProfileGetResponse.java @@ -0,0 +1,16 @@ +package com.example.demo.dto.profile; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.ToString; + +@RequiredArgsConstructor +@Getter +@EqualsAndHashCode +@ToString +public class ProfileGetResponse { + private final String name; + private final String thumbnailImg; + private final String introduction; +} diff --git a/src/main/java/com/example/demo/dto/profile/ProfileUpdateResponse.java b/src/main/java/com/example/demo/dto/profile/ProfileUpdateResponse.java new file mode 100644 index 0000000..73169f1 --- /dev/null +++ b/src/main/java/com/example/demo/dto/profile/ProfileUpdateResponse.java @@ -0,0 +1,16 @@ +package com.example.demo.dto.profile; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.ToString; + +@RequiredArgsConstructor +@Getter +@EqualsAndHashCode +@ToString +public class ProfileUpdateResponse { + private final String name; + private final String thumbnailImg; + private final String introduction; +} diff --git a/src/main/java/com/example/demo/service/profile/ProfileService.java b/src/main/java/com/example/demo/service/profile/ProfileService.java index f9c7e76..cd1d095 100644 --- a/src/main/java/com/example/demo/service/profile/ProfileService.java +++ b/src/main/java/com/example/demo/service/profile/ProfileService.java @@ -2,15 +2,16 @@ import java.time.LocalDateTime; -import com.example.demo.dto.profile.ProfileResponse; +import com.example.demo.dto.profile.ProfileGetResponse; import com.example.demo.dto.profile.ProfileUpdateRequest; +import com.example.demo.dto.profile.ProfileUpdateResponse; public interface ProfileService { - default ProfileResponse get(Long requestMemberID, Long targetMemberID) { - return get(requestMemberID, targetMemberID, LocalDateTime.now()); + default ProfileGetResponse get(Long requestMemberId, Long targetMemberId) { + return get(requestMemberId, targetMemberId, LocalDateTime.now()); } - ProfileResponse get(Long requestMemberID, Long targetMemberID, LocalDateTime baseDateTime); + ProfileGetResponse get(Long requestMemberId, Long targetMemberId, LocalDateTime baseDateTime); - ProfileResponse update(Long requestMemberId, Long targetMemberId, ProfileUpdateRequest profileUpdateRequest); + ProfileUpdateResponse update(Long requestMemberId, Long targetMemberId, ProfileUpdateRequest profileUpdateRequest); } diff --git a/src/main/java/com/example/demo/service/profile/ProfileServiceImpl.java b/src/main/java/com/example/demo/service/profile/ProfileServiceImpl.java index 1b405f2..8331998 100644 --- a/src/main/java/com/example/demo/service/profile/ProfileServiceImpl.java +++ b/src/main/java/com/example/demo/service/profile/ProfileServiceImpl.java @@ -15,8 +15,9 @@ import com.example.demo.domain.member.Member; import com.example.demo.domain.study.StudyMember; import com.example.demo.domain.study.StudyOnce; -import com.example.demo.dto.profile.ProfileResponse; +import com.example.demo.dto.profile.ProfileGetResponse; import com.example.demo.dto.profile.ProfileUpdateRequest; +import com.example.demo.dto.profile.ProfileUpdateResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.repository.member.MemberRepository; import com.example.demo.repository.study.StudyMemberRepository; @@ -33,28 +34,28 @@ public class ProfileServiceImpl implements ProfileService { private final StudyMemberRepository studyMemberRepository; @Override - public ProfileResponse get(Long requestMemberID, Long targetMemberID, LocalDateTime baseDateTime) { + public ProfileGetResponse get(Long requestMemberID, Long targetMemberID, LocalDateTime baseDateTime) { if (isOwnerOfProfile(requestMemberID, targetMemberID)) { - return makeProfileResponse(targetMemberID); + return makeProfileGetResponse(targetMemberID); } if (isAllowedCauseStudyLeader(requestMemberID, targetMemberID)) { - return makeProfileResponse(targetMemberID); + return makeProfileGetResponse(targetMemberID); } if (isAllowedCauseSameStudyOnceMember(requestMemberID, targetMemberID, baseDateTime)) { - return makeProfileResponse(targetMemberID); + return makeProfileGetResponse(targetMemberID); } throw new CafegoryException(PROFILE_GET_PERMISSION_DENIED); } @Override - public ProfileResponse update(Long requestMemberId, Long targetMemberId, + public ProfileUpdateResponse update(Long requestMemberId, Long targetMemberId, ProfileUpdateRequest profileUpdateRequest) { validateProfileUpdatePermission(requestMemberId, targetMemberId); Member targetMember = findTargetMember(targetMemberId); String name = profileUpdateRequest.getName(); String introduction = profileUpdateRequest.getIntroduction(); targetMember.updateProfile(name, introduction); - return makeProfileResponse(targetMemberId); + return makeProfileUpdateResponse(targetMemberId); } private void validateProfileUpdatePermission(Long requestMemberId, Long targetMemberId) { @@ -71,9 +72,15 @@ private Member findTargetMember(Long targetMemberId) { return targetMember.get(); } - private ProfileResponse makeProfileResponse(Long targetMemberID) { + private ProfileGetResponse makeProfileGetResponse(Long targetMemberID) { Member member = memberRepository.findById(targetMemberID).orElseThrow(); - return new ProfileResponse(member.getName(), member.getThumbnailImage().getThumbnailImage(), + return new ProfileGetResponse(member.getName(), member.getThumbnailImage().getThumbnailImage(), + member.getIntroduction()); + } + + private ProfileUpdateResponse makeProfileUpdateResponse(Long targetMemberID) { + Member member = memberRepository.findById(targetMemberID).orElseThrow(); + return new ProfileUpdateResponse(member.getName(), member.getThumbnailImage().getThumbnailImage(), member.getIntroduction()); } diff --git a/src/test/java/com/example/demo/service/profile/ProfileServiceImplTest.java b/src/test/java/com/example/demo/service/profile/ProfileServiceImplTest.java index 7510b4c..dcbd572 100644 --- a/src/test/java/com/example/demo/service/profile/ProfileServiceImplTest.java +++ b/src/test/java/com/example/demo/service/profile/ProfileServiceImplTest.java @@ -15,8 +15,8 @@ import com.example.demo.domain.member.Member; import com.example.demo.domain.study.StudyMember; import com.example.demo.domain.study.StudyOnce; -import com.example.demo.dto.profile.ProfileResponse; import com.example.demo.dto.profile.ProfileUpdateRequest; +import com.example.demo.dto.profile.ProfileUpdateResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; import com.example.demo.exception.CafegoryException; @@ -111,8 +111,8 @@ void failWhenOtherCase() { void updateSuccessWhenSelf() { long requestMemberId = memberPersistHelper.persistDefaultMember(THUMBNAIL_IMAGE).getId(); ProfileUpdateRequest profileUpdateRequest = new ProfileUpdateRequest("name", "introduction"); - ProfileResponse update = profileService.update(requestMemberId, requestMemberId, profileUpdateRequest); - Assertions.assertEquals(update, new ProfileResponse("name", "testUrl", "introduction")); + ProfileUpdateResponse update = profileService.update(requestMemberId, requestMemberId, profileUpdateRequest); + Assertions.assertEquals(update, new ProfileUpdateResponse("name", "testUrl", "introduction")); } @Test From bfd32674221d0dc3e157733cb698213d8d0bf46b Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 20:24:49 +0900 Subject: [PATCH 07/12] =?UTF-8?q?refactor:=20=EC=B9=B4=ED=8E=98=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?dto=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/ReviewController.java | 8 ++++---- .../demo/dto/review/ReviewSearchListRequest.java | 12 ++++++++++++ .../dto/review/ReviewSearchListResponse.java | 15 +++++++++++++++ .../com/example/demo/mapper/ReviewMapper.java | 16 ++++++++++++++++ .../demo/service/review/ReviewQueryService.java | 6 +++--- .../service/review/ReviewQueryServiceImpl.java | 14 +++++++------- 6 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/example/demo/dto/review/ReviewSearchListRequest.java create mode 100644 src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java diff --git a/src/main/java/com/example/demo/controller/ReviewController.java b/src/main/java/com/example/demo/controller/ReviewController.java index e4345c0..f9d25bf 100644 --- a/src/main/java/com/example/demo/controller/ReviewController.java +++ b/src/main/java/com/example/demo/controller/ReviewController.java @@ -16,8 +16,8 @@ import com.example.demo.dto.PagedResponse; import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.review.ReviewSaveRequest; -import com.example.demo.dto.review.ReviewSearchRequest; -import com.example.demo.dto.review.ReviewSearchResponse; +import com.example.demo.dto.review.ReviewSearchListRequest; +import com.example.demo.dto.review.ReviewSearchListResponse; import com.example.demo.dto.review.ReviewUpdateRequest; import com.example.demo.service.review.ReviewQueryService; import com.example.demo.service.review.ReviewService; @@ -33,8 +33,8 @@ public class ReviewController { private final CafegoryTokenManager cafegoryTokenManager; @GetMapping("/cafe/{cafeId}/review/list") - public ResponseEntity> reviewList(ReviewSearchRequest request) { - PagedResponse response = reviewQueryService.searchWithPagingByCafeId( + public ResponseEntity> reviewList(ReviewSearchListRequest request) { + PagedResponse response = reviewQueryService.searchWithPagingByCafeId( request); return new ResponseEntity<>(response, HttpStatus.OK); } diff --git a/src/main/java/com/example/demo/dto/review/ReviewSearchListRequest.java b/src/main/java/com/example/demo/dto/review/ReviewSearchListRequest.java new file mode 100644 index 0000000..06a29ff --- /dev/null +++ b/src/main/java/com/example/demo/dto/review/ReviewSearchListRequest.java @@ -0,0 +1,12 @@ +package com.example.demo.dto.review; + +import com.example.demo.dto.PagedRequest; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class ReviewSearchListRequest extends PagedRequest { + private final Long cafeId; +} diff --git a/src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java b/src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java new file mode 100644 index 0000000..8eeee5b --- /dev/null +++ b/src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java @@ -0,0 +1,15 @@ +package com.example.demo.dto.review; + +import com.example.demo.dto.WriterResponse; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class ReviewSearchListResponse { + private final long reviewId; + private final WriterResponse writer; + private final double rate; + private final String content; +} diff --git a/src/main/java/com/example/demo/mapper/ReviewMapper.java b/src/main/java/com/example/demo/mapper/ReviewMapper.java index fcae38e..52aa98a 100644 --- a/src/main/java/com/example/demo/mapper/ReviewMapper.java +++ b/src/main/java/com/example/demo/mapper/ReviewMapper.java @@ -9,6 +9,7 @@ import com.example.demo.dto.cafe.CafeSearchReviewResponse; import com.example.demo.dto.cafe.CafeSearchWriterResponse; import com.example.demo.dto.review.ReviewResponse; +import com.example.demo.dto.review.ReviewSearchListResponse; import com.example.demo.dto.review.ReviewSearchResponse; public class ReviewMapper { @@ -28,6 +29,21 @@ public List toReviewSearchResponses(List reviews) .collect(Collectors.toList()); } + public List toReviewSearchListResponses(List reviews) { + return reviews.stream() + .map(review -> + new ReviewSearchListResponse( + review.getId(), + produceWriterResponse( + review.getMember().getId(), review.getMember().getName(), + review.getMember().getThumbnailImage().getThumbnailImage() + ), + review.getRate(), + review.getContent() + )) + .collect(Collectors.toList()); + } + private WriterResponse produceWriterResponse(Long memberId, String name, String thumbnailImg) { return new WriterResponse(memberId, name, thumbnailImg); } diff --git a/src/main/java/com/example/demo/service/review/ReviewQueryService.java b/src/main/java/com/example/demo/service/review/ReviewQueryService.java index d238377..3dff240 100644 --- a/src/main/java/com/example/demo/service/review/ReviewQueryService.java +++ b/src/main/java/com/example/demo/service/review/ReviewQueryService.java @@ -2,12 +2,12 @@ import com.example.demo.dto.PagedResponse; import com.example.demo.dto.review.ReviewResponse; -import com.example.demo.dto.review.ReviewSearchRequest; -import com.example.demo.dto.review.ReviewSearchResponse; +import com.example.demo.dto.review.ReviewSearchListRequest; +import com.example.demo.dto.review.ReviewSearchListResponse; public interface ReviewQueryService { - PagedResponse searchWithPagingByCafeId(ReviewSearchRequest request); + PagedResponse searchWithPagingByCafeId(ReviewSearchListRequest request); ReviewResponse searchOne(Long reviewId); } diff --git a/src/main/java/com/example/demo/service/review/ReviewQueryServiceImpl.java b/src/main/java/com/example/demo/service/review/ReviewQueryServiceImpl.java index 0a56ba1..dc7fefc 100644 --- a/src/main/java/com/example/demo/service/review/ReviewQueryServiceImpl.java +++ b/src/main/java/com/example/demo/service/review/ReviewQueryServiceImpl.java @@ -12,8 +12,8 @@ import com.example.demo.domain.review.Review; import com.example.demo.dto.PagedResponse; import com.example.demo.dto.review.ReviewResponse; -import com.example.demo.dto.review.ReviewSearchRequest; -import com.example.demo.dto.review.ReviewSearchResponse; +import com.example.demo.dto.review.ReviewSearchListRequest; +import com.example.demo.dto.review.ReviewSearchListResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.mapper.ReviewMapper; import com.example.demo.repository.cafe.CafeRepository; @@ -32,13 +32,13 @@ public class ReviewQueryServiceImpl implements ReviewQueryService { private final ReviewMapper reviewMapper; @Override - public PagedResponse searchWithPagingByCafeId(ReviewSearchRequest request) { + public PagedResponse searchWithPagingByCafeId(ReviewSearchListRequest request) { validateExistCafe(request.getCafeId()); Pageable pageable = PageRequestCustom.of(request.getPage(), request.getSizePerPage()); Page pagedReviews = reviewRepository.findAllWithPagingByCafeId(request.getCafeId(), pageable); return createPagedResponse(pagedReviews, - reviewMapper.toReviewSearchResponses(pagedReviews.getContent())); + reviewMapper.toReviewSearchListResponses(pagedReviews.getContent())); } @Override @@ -57,13 +57,13 @@ private void validateExistCafe(Long cafeId) { } } - private PagedResponse createPagedResponse(Page pagedReviews, - List reviewSearchResponse) { + private PagedResponse createPagedResponse(Page pagedReviews, + List reviewSearchListResponse) { return PagedResponse.createWithFirstPageAsOne( pagedReviews.getNumber(), pagedReviews.getTotalPages(), pagedReviews.getNumberOfElements(), - reviewSearchResponse + reviewSearchListResponse ); } From 19a73021c6cb83e75755ec86d975d41f1df43184 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 21:23:57 +0900 Subject: [PATCH 08/12] =?UTF-8?q?refactor:=20=EC=B9=B4=EA=B3=B5=20dto=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/StudyOnceController.java | 20 ++++++++++--------- ...onse.java => StudyMemberListResponse.java} | 2 +- .../dto/study/StudyOnceCommentResponse.java | 4 +--- .../study/StudyOnceCommentSaveRequest.java | 18 +++++++++++++++++ .../demo/dto/study/StudyOnceQuitResponse.java | 11 ++++++++++ ...foResponse.java => StudyOnceResponse.java} | 2 +- .../StudyOnceSearchCommentWriterResponse.java | 12 +++++++++++ .../com/example/demo/mapper/MemberMapper.java | 6 ++++++ .../demo/mapper/StudyOnceCommentMapper.java | 7 +++++++ .../example/demo/mapper/StudyOnceMapper.java | 17 +++++++--------- .../study/StudyOnceCommentService.java | 3 ++- .../study/StudyOnceCommentServiceImpl.java | 3 ++- .../study/StudyOnceQAndAQueryServiceImpl.java | 9 ++++++--- .../demo/service/study/StudyOnceService.java | 8 ++++---- .../service/study/StudyOnceServiceImpl.java | 12 +++++------ .../StudyOnceCommentQueryServiceImplTest.java | 3 ++- .../StudyOnceCommentServiceImplTest.java | 5 +++-- .../StudyOnceQAndAQueryServiceImplTest.java | 2 +- .../study/StudyOnceServiceImplTest.java | 4 ++-- 19 files changed, 103 insertions(+), 45 deletions(-) rename src/main/java/com/example/demo/dto/study/{StudyMembersResponse.java => StudyMemberListResponse.java} (87%) create mode 100644 src/main/java/com/example/demo/dto/study/StudyOnceCommentSaveRequest.java create mode 100644 src/main/java/com/example/demo/dto/study/StudyOnceQuitResponse.java rename src/main/java/com/example/demo/dto/study/{StudyOnceInfoResponse.java => StudyOnceResponse.java} (92%) create mode 100644 src/main/java/com/example/demo/dto/study/StudyOnceSearchCommentWriterResponse.java diff --git a/src/main/java/com/example/demo/controller/StudyOnceController.java b/src/main/java/com/example/demo/controller/StudyOnceController.java index eabf0bc..0621c20 100644 --- a/src/main/java/com/example/demo/controller/StudyOnceController.java +++ b/src/main/java/com/example/demo/controller/StudyOnceController.java @@ -22,15 +22,17 @@ import com.example.demo.domain.auth.CafegoryTokenManager; import com.example.demo.dto.PagedResponse; import com.example.demo.dto.cafe.CafeSearchListResponse; -import com.example.demo.dto.study.StudyMembersResponse; +import com.example.demo.dto.study.StudyMemberListResponse; import com.example.demo.dto.study.StudyOnceCommentRequest; import com.example.demo.dto.study.StudyOnceCommentResponse; +import com.example.demo.dto.study.StudyOnceCommentSaveRequest; import com.example.demo.dto.study.StudyOnceCommentUpdateRequest; import com.example.demo.dto.study.StudyOnceCommentsSearchResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; -import com.example.demo.dto.study.StudyOnceInfoResponse; import com.example.demo.dto.study.StudyOnceJoinResult; +import com.example.demo.dto.study.StudyOnceQuitResponse; +import com.example.demo.dto.study.StudyOnceResponse; import com.example.demo.dto.study.StudyOnceSearchListResponse; import com.example.demo.dto.study.StudyOnceSearchRequest; import com.example.demo.dto.study.StudyOnceSearchResponse; @@ -87,7 +89,7 @@ public ResponseEntity create( } @PatchMapping("/{studyOnceId:[0-9]+}") - public ResponseEntity update(@PathVariable Long studyOnceId, + public ResponseEntity update(@PathVariable Long studyOnceId, @RequestBody @Validated StudyOnceUpdateRequest request, @RequestHeader("Authorization") String authorization) { long leaderId = cafegoryTokenManager.getIdentityId(authorization); @@ -96,7 +98,7 @@ public ResponseEntity update(@PathVariable Long studyOnce } else { studyOnceService.updateStudyOncePartially(leaderId, studyOnceId, request, LocalDateTime.now()); } - StudyOnceInfoResponse response = studyOnceService.findStudyOnce(studyOnceId, LocalDateTime.now()); + StudyOnceResponse response = studyOnceService.findStudyOnce(studyOnceId, LocalDateTime.now()); return ResponseEntity.ok(response); } @@ -110,12 +112,12 @@ public ResponseEntity tryJoin(@PathVariable Long studyOnceI } @DeleteMapping("/{studyOnceId:[0-9]+}") - public ResponseEntity tryQuit(@PathVariable Long studyOnceId, + public ResponseEntity tryQuit(@PathVariable Long studyOnceId, @RequestHeader("Authorization") String authorization) { long memberId = cafegoryTokenManager.getIdentityId(authorization); LocalDateTime requestTime = LocalDateTime.now(); studyOnceService.tryQuit(memberId, studyOnceId); - return ResponseEntity.ok(new StudyOnceJoinResult(requestTime, true)); + return ResponseEntity.ok(new StudyOnceQuitResponse(requestTime, true)); } @PatchMapping("/{studyOnceId:[0-9]+}/attendance") @@ -139,20 +141,20 @@ public ResponseEntity changeCafe(@PathVariable Long stud } @GetMapping("/{studyOnceId:[0-9]+}/member/list") - public ResponseEntity findStudyMemberList(@PathVariable Long studyOnceId, + public ResponseEntity searchStudyMemberList(@PathVariable Long studyOnceId, @RequestHeader("Authorization") String authorization) { long leaderId = cafegoryTokenManager.getIdentityId(authorization); if (!studyOnceService.isStudyOnceLeader(leaderId, studyOnceId)) { throw new CafegoryException(STUDY_ONCE_LEADER_PERMISSION_DENIED); } - StudyMembersResponse response = studyOnceService.findStudyMembersById(studyOnceId); + StudyMemberListResponse response = studyOnceService.findStudyMembersById(studyOnceId); return ResponseEntity.ok(response); } @PostMapping("/{studyOnceId:[0-9]+}/question") public ResponseEntity saveQuestion(@PathVariable Long studyOnceId, @RequestHeader("Authorization") String authorization, - @RequestBody @Validated StudyOnceCommentRequest request) { + @RequestBody @Validated StudyOnceCommentSaveRequest request) { long memberId = cafegoryTokenManager.getIdentityId(authorization); Long savedCommentId = studyOnceCommentService.saveQuestion(memberId, studyOnceId, request); StudyOnceCommentResponse response = studyOnceQAndAQueryService.searchComment( diff --git a/src/main/java/com/example/demo/dto/study/StudyMembersResponse.java b/src/main/java/com/example/demo/dto/study/StudyMemberListResponse.java similarity index 87% rename from src/main/java/com/example/demo/dto/study/StudyMembersResponse.java rename to src/main/java/com/example/demo/dto/study/StudyMemberListResponse.java index e86b368..a67b2d7 100644 --- a/src/main/java/com/example/demo/dto/study/StudyMembersResponse.java +++ b/src/main/java/com/example/demo/dto/study/StudyMemberListResponse.java @@ -9,7 +9,7 @@ @Getter @RequiredArgsConstructor -public class StudyMembersResponse { +public class StudyMemberListResponse { private final List joinedMembers; diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceCommentResponse.java b/src/main/java/com/example/demo/dto/study/StudyOnceCommentResponse.java index 9e36180..41e98cc 100644 --- a/src/main/java/com/example/demo/dto/study/StudyOnceCommentResponse.java +++ b/src/main/java/com/example/demo/dto/study/StudyOnceCommentResponse.java @@ -1,7 +1,5 @@ package com.example.demo.dto.study; -import com.example.demo.dto.WriterResponse; - import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -11,5 +9,5 @@ public class StudyOnceCommentResponse { private final Long commentId; private final String content; - private final WriterResponse writer; + private final StudyOnceSearchCommentWriterResponse writer; } diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceCommentSaveRequest.java b/src/main/java/com/example/demo/dto/study/StudyOnceCommentSaveRequest.java new file mode 100644 index 0000000..8eda2c4 --- /dev/null +++ b/src/main/java/com/example/demo/dto/study/StudyOnceCommentSaveRequest.java @@ -0,0 +1,18 @@ +package com.example.demo.dto.study; + +import javax.validation.constraints.NotBlank; + +import lombok.Getter; + +@Getter +public class StudyOnceCommentSaveRequest { + @NotBlank + private String content; + + public StudyOnceCommentSaveRequest() { + } + + public StudyOnceCommentSaveRequest(String content) { + this.content = content; + } +} diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceQuitResponse.java b/src/main/java/com/example/demo/dto/study/StudyOnceQuitResponse.java new file mode 100644 index 0000000..ec5b9ec --- /dev/null +++ b/src/main/java/com/example/demo/dto/study/StudyOnceQuitResponse.java @@ -0,0 +1,11 @@ +package com.example.demo.dto.study; + +import java.time.LocalDateTime; + +import lombok.Data; + +@Data +public class StudyOnceQuitResponse { + private final LocalDateTime requestTime; + private final boolean result; +} diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceInfoResponse.java b/src/main/java/com/example/demo/dto/study/StudyOnceResponse.java similarity index 92% rename from src/main/java/com/example/demo/dto/study/StudyOnceInfoResponse.java rename to src/main/java/com/example/demo/dto/study/StudyOnceResponse.java index c3e63e5..0d88ff6 100644 --- a/src/main/java/com/example/demo/dto/study/StudyOnceInfoResponse.java +++ b/src/main/java/com/example/demo/dto/study/StudyOnceResponse.java @@ -7,7 +7,7 @@ @Builder @Data -public class StudyOnceInfoResponse { +public class StudyOnceResponse { private long cafeId; private String area; private long studyOnceId; diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceSearchCommentWriterResponse.java b/src/main/java/com/example/demo/dto/study/StudyOnceSearchCommentWriterResponse.java new file mode 100644 index 0000000..1bc2a0e --- /dev/null +++ b/src/main/java/com/example/demo/dto/study/StudyOnceSearchCommentWriterResponse.java @@ -0,0 +1,12 @@ +package com.example.demo.dto.study; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class StudyOnceSearchCommentWriterResponse { + private final long memberId; + private final String name; + private final String thumbnailImg; +} diff --git a/src/main/java/com/example/demo/mapper/MemberMapper.java b/src/main/java/com/example/demo/mapper/MemberMapper.java index e3dea55..2ef5aab 100644 --- a/src/main/java/com/example/demo/mapper/MemberMapper.java +++ b/src/main/java/com/example/demo/mapper/MemberMapper.java @@ -3,6 +3,7 @@ import com.example.demo.domain.member.Member; import com.example.demo.dto.WriterResponse; import com.example.demo.dto.member.MemberResponse; +import com.example.demo.dto.study.StudyOnceSearchCommentWriterResponse; public class MemberMapper { @@ -10,6 +11,11 @@ public WriterResponse toWriterResponse(Member member) { return new WriterResponse(member.getId(), member.getName(), member.getThumbnailImage().getThumbnailImage()); } + public StudyOnceSearchCommentWriterResponse toStudyOnceSearchCommentWriterResponse(Member member) { + return new StudyOnceSearchCommentWriterResponse(member.getId(), member.getName(), + member.getThumbnailImage().getThumbnailImage()); + } + public MemberResponse toMemberResponse(Member member) { return new MemberResponse(member.getId(), member.getName(), member.getThumbnailImage().getThumbnailImage()); } diff --git a/src/main/java/com/example/demo/mapper/StudyOnceCommentMapper.java b/src/main/java/com/example/demo/mapper/StudyOnceCommentMapper.java index 5b669fa..44a3394 100644 --- a/src/main/java/com/example/demo/mapper/StudyOnceCommentMapper.java +++ b/src/main/java/com/example/demo/mapper/StudyOnceCommentMapper.java @@ -2,7 +2,9 @@ import com.example.demo.domain.study.StudyOnceComment; import com.example.demo.dto.study.StudyOnceCommentInfo; +import com.example.demo.dto.study.StudyOnceCommentResponse; import com.example.demo.dto.study.StudyOnceReplyResponse; +import com.example.demo.dto.study.StudyOnceSearchCommentWriterResponse; public class StudyOnceCommentMapper { @@ -13,4 +15,9 @@ public StudyOnceCommentInfo toStudyOnceCommentInfo(StudyOnceComment comment) { public StudyOnceReplyResponse toStudyOnceReplyResponse(StudyOnceComment comment) { return new StudyOnceReplyResponse(comment.getId(), comment.getContent()); } + + public StudyOnceCommentResponse toStudyOnceCommentResponse(StudyOnceComment comment, + StudyOnceSearchCommentWriterResponse writerResponse) { + return new StudyOnceCommentResponse(comment.getId(), comment.getContent(), writerResponse); + } } diff --git a/src/main/java/com/example/demo/mapper/StudyOnceMapper.java b/src/main/java/com/example/demo/mapper/StudyOnceMapper.java index c0bb3a6..eb96fc1 100644 --- a/src/main/java/com/example/demo/mapper/StudyOnceMapper.java +++ b/src/main/java/com/example/demo/mapper/StudyOnceMapper.java @@ -6,14 +6,11 @@ import com.example.demo.domain.cafe.Cafe; import com.example.demo.domain.member.Member; import com.example.demo.domain.study.StudyOnce; -import com.example.demo.domain.study.StudyOnceComment; -import com.example.demo.dto.WriterResponse; import com.example.demo.dto.cafe.CafeSearchStudyOnceResponse; -import com.example.demo.dto.study.StudyOnceCommentResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; import com.example.demo.dto.study.StudyOnceForCafeResponse; -import com.example.demo.dto.study.StudyOnceInfoResponse; +import com.example.demo.dto.study.StudyOnceResponse; import com.example.demo.dto.study.StudyOnceSearchListResponse; import com.example.demo.dto.study.StudyOnceSearchResponse; @@ -69,8 +66,8 @@ public StudyOnce toNewEntity(StudyOnceCreateRequest studyOnceCreateRequest, Cafe .build(); } - public StudyOnceInfoResponse toStudyOnceInfoResponse(StudyOnce saved, boolean canJoin) { - return StudyOnceInfoResponse.builder() + public StudyOnceResponse toStudyOnceResponse(StudyOnce saved, boolean canJoin) { + return StudyOnceResponse.builder() .cafeId(saved.getCafe().getId()) .area(saved.getCafe().getRegion()) .studyOnceId(saved.getId()) @@ -138,9 +135,9 @@ public StudyOnceCreateResponse toStudyOnceCreateResponse(StudyOnce saved, boolea .build(); } - public StudyOnceCommentResponse toStudyOnceQuestionResponse(StudyOnceComment question, - WriterResponse writerResponse) { - return new StudyOnceCommentResponse(question.getId(), question.getContent(), writerResponse); - } + // public StudyOnceCommentResponse toStudyOnceQuestionResponse(StudyOnceComment question, + // WriterResponse writerResponse) { + // return new StudyOnceCommentResponse(question.getId(), question.getContent(), writerResponse); + // } } diff --git a/src/main/java/com/example/demo/service/study/StudyOnceCommentService.java b/src/main/java/com/example/demo/service/study/StudyOnceCommentService.java index dda2e12..e08d6a9 100644 --- a/src/main/java/com/example/demo/service/study/StudyOnceCommentService.java +++ b/src/main/java/com/example/demo/service/study/StudyOnceCommentService.java @@ -1,11 +1,12 @@ package com.example.demo.service.study; import com.example.demo.dto.study.StudyOnceCommentRequest; +import com.example.demo.dto.study.StudyOnceCommentSaveRequest; import com.example.demo.dto.study.StudyOnceCommentUpdateRequest; public interface StudyOnceCommentService { - Long saveQuestion(Long memberId, Long studyOnceId, StudyOnceCommentRequest request); + Long saveQuestion(Long memberId, Long studyOnceId, StudyOnceCommentSaveRequest request); void updateQuestion(Long memberId, Long studyOnceCommentId, StudyOnceCommentUpdateRequest request); diff --git a/src/main/java/com/example/demo/service/study/StudyOnceCommentServiceImpl.java b/src/main/java/com/example/demo/service/study/StudyOnceCommentServiceImpl.java index 5b90bf6..dae91da 100644 --- a/src/main/java/com/example/demo/service/study/StudyOnceCommentServiceImpl.java +++ b/src/main/java/com/example/demo/service/study/StudyOnceCommentServiceImpl.java @@ -9,6 +9,7 @@ import com.example.demo.domain.study.StudyOnce; import com.example.demo.domain.study.StudyOnceComment; import com.example.demo.dto.study.StudyOnceCommentRequest; +import com.example.demo.dto.study.StudyOnceCommentSaveRequest; import com.example.demo.dto.study.StudyOnceCommentUpdateRequest; import com.example.demo.exception.CafegoryException; import com.example.demo.repository.member.MemberRepository; @@ -27,7 +28,7 @@ public class StudyOnceCommentServiceImpl implements StudyOnceCommentService { private final StudyOnceRepository studyOnceRepository; @Override - public Long saveQuestion(Long memberId, Long studyOnceId, StudyOnceCommentRequest request) { + public Long saveQuestion(Long memberId, Long studyOnceId, StudyOnceCommentSaveRequest request) { StudyOnceComment question = StudyOnceComment.builder() .content(request.getContent()) .member(findMemberById(memberId)) diff --git a/src/main/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImpl.java b/src/main/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImpl.java index 1511823..f65c7cb 100644 --- a/src/main/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImpl.java +++ b/src/main/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImpl.java @@ -6,10 +6,11 @@ import org.springframework.transaction.annotation.Transactional; import com.example.demo.domain.study.StudyOnceComment; -import com.example.demo.dto.WriterResponse; import com.example.demo.dto.study.StudyOnceCommentResponse; +import com.example.demo.dto.study.StudyOnceSearchCommentWriterResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.mapper.MemberMapper; +import com.example.demo.mapper.StudyOnceCommentMapper; import com.example.demo.mapper.StudyOnceMapper; import com.example.demo.repository.study.StudyOnceCommentRepository; @@ -23,12 +24,14 @@ public class StudyOnceQAndAQueryServiceImpl implements StudyOnceQAndAQueryServic private final StudyOnceCommentRepository studyOnceCommentRepository; private final MemberMapper memberMapper; private final StudyOnceMapper studyOnceMapper; + private final StudyOnceCommentMapper studyOnceCommentMapper; @Override public StudyOnceCommentResponse searchComment(Long studyOnceCommentId) { StudyOnceComment question = findStudyOnceCommentById(studyOnceCommentId); - WriterResponse writerResponse = memberMapper.toWriterResponse(question.getMember()); - return studyOnceMapper.toStudyOnceQuestionResponse(question, writerResponse); + StudyOnceSearchCommentWriterResponse writerResponse = memberMapper.toStudyOnceSearchCommentWriterResponse( + question.getMember()); + return studyOnceCommentMapper.toStudyOnceCommentResponse(question, writerResponse); } private StudyOnceComment findStudyOnceCommentById(Long studyOnceCommentId) { diff --git a/src/main/java/com/example/demo/service/study/StudyOnceService.java b/src/main/java/com/example/demo/service/study/StudyOnceService.java index a765432..c530d9b 100644 --- a/src/main/java/com/example/demo/service/study/StudyOnceService.java +++ b/src/main/java/com/example/demo/service/study/StudyOnceService.java @@ -4,10 +4,10 @@ import com.example.demo.domain.study.Attendance; import com.example.demo.dto.PagedResponse; -import com.example.demo.dto.study.StudyMembersResponse; +import com.example.demo.dto.study.StudyMemberListResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; -import com.example.demo.dto.study.StudyOnceInfoResponse; +import com.example.demo.dto.study.StudyOnceResponse; import com.example.demo.dto.study.StudyOnceSearchListResponse; import com.example.demo.dto.study.StudyOnceSearchRequest; import com.example.demo.dto.study.StudyOnceSearchResponse; @@ -35,9 +35,9 @@ UpdateAttendanceResponse updateAttendances(long leaderId, long studyOnceId, Long changeCafe(Long requestMemberId, Long studyOnceId, Long changingCafeId); - StudyMembersResponse findStudyMembersById(Long studyOnceId); + StudyMemberListResponse findStudyMembersById(Long studyOnceId); - StudyOnceInfoResponse findStudyOnce(Long studyOnceId, LocalDateTime now); + StudyOnceResponse findStudyOnce(Long studyOnceId, LocalDateTime now); boolean doesOnlyStudyLeaderExist(Long studyOnceId); diff --git a/src/main/java/com/example/demo/service/study/StudyOnceServiceImpl.java b/src/main/java/com/example/demo/service/study/StudyOnceServiceImpl.java index 2cbb8ad..6a46afe 100644 --- a/src/main/java/com/example/demo/service/study/StudyOnceServiceImpl.java +++ b/src/main/java/com/example/demo/service/study/StudyOnceServiceImpl.java @@ -18,12 +18,12 @@ import com.example.demo.domain.study.StudyOnce; import com.example.demo.dto.PagedResponse; import com.example.demo.dto.member.MemberResponse; +import com.example.demo.dto.study.StudyMemberListResponse; import com.example.demo.dto.study.StudyMemberStateRequest; import com.example.demo.dto.study.StudyMemberStateResponse; -import com.example.demo.dto.study.StudyMembersResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; -import com.example.demo.dto.study.StudyOnceInfoResponse; +import com.example.demo.dto.study.StudyOnceResponse; import com.example.demo.dto.study.StudyOnceSearchListResponse; import com.example.demo.dto.study.StudyOnceSearchRequest; import com.example.demo.dto.study.StudyOnceSearchResponse; @@ -248,16 +248,16 @@ public Long changeCafe(Long requestMemberId, Long studyOnceId, final Long changi } @Override - public StudyMembersResponse findStudyMembersById(Long studyOnceId) { + public StudyMemberListResponse findStudyMembersById(Long studyOnceId) { StudyOnce studyOnce = findStudyOnceById(studyOnceId); List memberResponses = studyMemberMapper.toMemberResponses(studyOnce.getStudyMembers()); - return new StudyMembersResponse(memberResponses); + return new StudyMemberListResponse(memberResponses); } @Override - public StudyOnceInfoResponse findStudyOnce(Long studyOnceId, LocalDateTime now) { + public StudyOnceResponse findStudyOnce(Long studyOnceId, LocalDateTime now) { StudyOnce studyOnce = findStudyOnceById(studyOnceId); - return studyOnceMapper.toStudyOnceInfoResponse(studyOnce, studyOnce.canJoin(now)); + return studyOnceMapper.toStudyOnceResponse(studyOnce, studyOnce.canJoin(now)); } @Override diff --git a/src/test/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImplTest.java b/src/test/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImplTest.java index 93e7c85..35132f2 100644 --- a/src/test/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImplTest.java +++ b/src/test/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImplTest.java @@ -12,6 +12,7 @@ import com.example.demo.domain.member.Member; import com.example.demo.domain.study.StudyOnce; import com.example.demo.dto.study.StudyOnceCommentRequest; +import com.example.demo.dto.study.StudyOnceCommentSaveRequest; import com.example.demo.dto.study.StudyOnceCommentSearchResponse; import com.example.demo.dto.study.StudyOnceReplyResponse; import com.example.demo.repository.member.InMemoryMemberRepository; @@ -39,7 +40,7 @@ void searchCommentsSortedByStudyOnceId() { Member leader = memberPersistHelper.persistDefaultMember(THUMBNAIL_IMAGE); Cafe cafe = cafePersistHelper.persistDefaultCafe(); StudyOnce studyOnce = studyOncePersistHelper.persistDefaultStudyOnce(cafe, leader); - StudyOnceCommentRequest questionRequest = new StudyOnceCommentRequest("질문"); + StudyOnceCommentSaveRequest questionRequest = new StudyOnceCommentSaveRequest("질문"); Member member = memberPersistHelper.persistDefaultMember(THUMBNAIL_IMAGE); Long questionId = studyOnceCommentService.saveQuestion(member.getId(), studyOnce.getId(), questionRequest); StudyOnceCommentRequest replyRequest = new StudyOnceCommentRequest("답변"); diff --git a/src/test/java/com/example/demo/service/study/StudyOnceCommentServiceImplTest.java b/src/test/java/com/example/demo/service/study/StudyOnceCommentServiceImplTest.java index 4f42f47..e387986 100644 --- a/src/test/java/com/example/demo/service/study/StudyOnceCommentServiceImplTest.java +++ b/src/test/java/com/example/demo/service/study/StudyOnceCommentServiceImplTest.java @@ -13,6 +13,7 @@ import com.example.demo.domain.study.StudyOnce; import com.example.demo.domain.study.StudyOnceComment; import com.example.demo.dto.study.StudyOnceCommentRequest; +import com.example.demo.dto.study.StudyOnceCommentSaveRequest; import com.example.demo.dto.study.StudyOnceCommentUpdateRequest; import com.example.demo.exception.CafegoryException; import com.example.demo.exception.ExceptionType; @@ -41,7 +42,7 @@ void save_question() { StudyOnce studyOnce = studyOncePersistHelper.persistDefaultStudyOnce(cafe, leader); //when studyOnceCommentService.saveQuestion(otherPerson.getId(), studyOnce.getId(), - new StudyOnceCommentRequest("몇시까지 공부하시나요?")); + new StudyOnceCommentSaveRequest("몇시까지 공부하시나요?")); List questions = studyOnceCommentRepository.findAll(); //then assertThat(questions.size()).isEqualTo(1); @@ -56,7 +57,7 @@ void save_question_by_leader() { StudyOnce studyOnce = studyOncePersistHelper.persistDefaultStudyOnce(cafe, leader); //when studyOnceCommentService.saveQuestion(leader.getId(), studyOnce.getId(), - new StudyOnceCommentRequest("카페 끝날때까지 공부합니다.")); + new StudyOnceCommentSaveRequest("카페 끝날때까지 공부합니다.")); List questions = studyOnceCommentRepository.findAll(); //then assertThat(questions.size()).isEqualTo(1); diff --git a/src/test/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImplTest.java b/src/test/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImplTest.java index ba68b68..3ea51a8 100644 --- a/src/test/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImplTest.java +++ b/src/test/java/com/example/demo/service/study/StudyOnceQAndAQueryServiceImplTest.java @@ -16,7 +16,7 @@ class StudyOnceQAndAQueryServiceImplTest extends ServiceTest { private final InMemoryStudyOnceCommentRepository studyOnceCommentRepository = InMemoryStudyOnceCommentRepository.INSTANCE; private final StudyOnceQAndAQueryService studyOnceQAndAQueryService = new StudyOnceQAndAQueryServiceImpl( - studyOnceCommentRepository, memberMapper, studyOnceMapper); + studyOnceCommentRepository, memberMapper, studyOnceMapper, studyOnceCommentMapper); @Test @DisplayName("카공 질문을 찾는다") diff --git a/src/test/java/com/example/demo/service/study/StudyOnceServiceImplTest.java b/src/test/java/com/example/demo/service/study/StudyOnceServiceImplTest.java index c96208c..a17445a 100644 --- a/src/test/java/com/example/demo/service/study/StudyOnceServiceImplTest.java +++ b/src/test/java/com/example/demo/service/study/StudyOnceServiceImplTest.java @@ -24,8 +24,8 @@ import com.example.demo.domain.study.StudyOnce; import com.example.demo.dto.PagedResponse; import com.example.demo.dto.member.MemberResponse; +import com.example.demo.dto.study.StudyMemberListResponse; import com.example.demo.dto.study.StudyMemberStateRequest; -import com.example.demo.dto.study.StudyMembersResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; import com.example.demo.dto.study.StudyOnceSearchListResponse; @@ -619,7 +619,7 @@ void findStudyMembers() { studyOnceService.tryJoin(memberId, studyOnceId); syncStudyOnceRepositoryAndStudyMemberRepository(); - StudyMembersResponse studyMembersById = studyOnceService.findStudyMembersById(studyOnceId); + StudyMemberListResponse studyMembersById = studyOnceService.findStudyMembersById(studyOnceId); List actualStudyMemberIds = studyMembersById.getJoinedMembers().stream() .map(MemberResponse::getMemberId) .collect(Collectors.toList()); From 6c59ef6d8ea7726e81a28168ca131d1e46c33f8c Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 21:44:35 +0900 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20=EC=B9=B5=EC=98=A4=20?= =?UTF-8?q?=EC=A7=88=EB=AC=B8=EB=8B=B5=EB=B3=80=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20dto=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/demo/controller/StudyOnceController.java | 6 +++--- ...e.java => StudyOnceCommentSearchListResponse.java} | 10 ++++------ .../dto/study/StudyOnceCommentSearchResponse.java | 4 +--- .../service/study/StudyOnceCommentQueryService.java | 4 ++-- .../study/StudyOnceCommentQueryServiceImpl.java | 11 ++++++----- 5 files changed, 16 insertions(+), 19 deletions(-) rename src/main/java/com/example/demo/dto/study/{StudyOnceCommentsSearchResponse.java => StudyOnceCommentSearchListResponse.java} (59%) diff --git a/src/main/java/com/example/demo/controller/StudyOnceController.java b/src/main/java/com/example/demo/controller/StudyOnceController.java index 0621c20..01d8570 100644 --- a/src/main/java/com/example/demo/controller/StudyOnceController.java +++ b/src/main/java/com/example/demo/controller/StudyOnceController.java @@ -26,8 +26,8 @@ import com.example.demo.dto.study.StudyOnceCommentRequest; import com.example.demo.dto.study.StudyOnceCommentResponse; import com.example.demo.dto.study.StudyOnceCommentSaveRequest; +import com.example.demo.dto.study.StudyOnceCommentSearchListResponse; import com.example.demo.dto.study.StudyOnceCommentUpdateRequest; -import com.example.demo.dto.study.StudyOnceCommentsSearchResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; import com.example.demo.dto.study.StudyOnceJoinResult; @@ -219,10 +219,10 @@ public ResponseEntity deleteReply(@PathVariable final } @GetMapping("/{studyOnceId:[0-9]+}/comment/list") - public ResponseEntity searchComments(@PathVariable Long studyOnceId, + public ResponseEntity searchComments(@PathVariable Long studyOnceId, @RequestHeader("Authorization") String authorization) { cafegoryTokenManager.getIdentityId(authorization); - StudyOnceCommentsSearchResponse response = studyOnceCommentQueryService.searchSortedCommentsByStudyOnceId( + StudyOnceCommentSearchListResponse response = studyOnceCommentQueryService.searchSortedCommentsByStudyOnceId( studyOnceId); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceCommentsSearchResponse.java b/src/main/java/com/example/demo/dto/study/StudyOnceCommentSearchListResponse.java similarity index 59% rename from src/main/java/com/example/demo/dto/study/StudyOnceCommentsSearchResponse.java rename to src/main/java/com/example/demo/dto/study/StudyOnceCommentSearchListResponse.java index ae9b978..80a8925 100644 --- a/src/main/java/com/example/demo/dto/study/StudyOnceCommentsSearchResponse.java +++ b/src/main/java/com/example/demo/dto/study/StudyOnceCommentSearchListResponse.java @@ -3,18 +3,16 @@ import java.util.ArrayList; import java.util.List; -import com.example.demo.dto.member.MemberResponse; - import lombok.Getter; @Getter -public class StudyOnceCommentsSearchResponse { +public class StudyOnceCommentSearchListResponse { - private MemberResponse replyWriter; + private StudyOnceSearchCommentWriterResponse writerResponse; private List comments = new ArrayList<>(); - public StudyOnceCommentsSearchResponse(MemberResponse replyWriter) { - this.replyWriter = replyWriter; + public StudyOnceCommentSearchListResponse(StudyOnceSearchCommentWriterResponse writerResponse) { + this.writerResponse = writerResponse; } public void addStudyOnceCommentSearchResponse(StudyOnceCommentSearchResponse studyOnceCommentSearchResponse) { diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceCommentSearchResponse.java b/src/main/java/com/example/demo/dto/study/StudyOnceCommentSearchResponse.java index 9d50982..caee9c5 100644 --- a/src/main/java/com/example/demo/dto/study/StudyOnceCommentSearchResponse.java +++ b/src/main/java/com/example/demo/dto/study/StudyOnceCommentSearchResponse.java @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.List; -import com.example.demo.dto.member.MemberResponse; - import lombok.Getter; import lombok.Setter; @@ -12,7 +10,7 @@ @Setter public class StudyOnceCommentSearchResponse { - private MemberResponse questionWriter; + private StudyOnceSearchCommentWriterResponse questionWriter; private StudyOnceCommentInfo questionInfo; private List replies = new ArrayList<>(); diff --git a/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryService.java b/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryService.java index 4acc085..927e3c2 100644 --- a/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryService.java +++ b/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryService.java @@ -1,8 +1,8 @@ package com.example.demo.service.study; -import com.example.demo.dto.study.StudyOnceCommentsSearchResponse; +import com.example.demo.dto.study.StudyOnceCommentSearchListResponse; public interface StudyOnceCommentQueryService { - StudyOnceCommentsSearchResponse searchSortedCommentsByStudyOnceId(Long studyOnceId); + StudyOnceCommentSearchListResponse searchSortedCommentsByStudyOnceId(Long studyOnceId); } diff --git a/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImpl.java b/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImpl.java index 312938a..2204aa1 100644 --- a/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImpl.java +++ b/src/main/java/com/example/demo/service/study/StudyOnceCommentQueryServiceImpl.java @@ -11,8 +11,8 @@ import com.example.demo.domain.study.StudyOnce; import com.example.demo.domain.study.StudyOnceComment; +import com.example.demo.dto.study.StudyOnceCommentSearchListResponse; import com.example.demo.dto.study.StudyOnceCommentSearchResponse; -import com.example.demo.dto.study.StudyOnceCommentsSearchResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.mapper.MemberMapper; import com.example.demo.mapper.StudyOnceCommentMapper; @@ -32,18 +32,19 @@ public class StudyOnceCommentQueryServiceImpl implements StudyOnceCommentQuerySe private final StudyOnceCommentMapper studyOnceCommentMapper; @Override - public StudyOnceCommentsSearchResponse searchSortedCommentsByStudyOnceId(Long studyOnceId) { + public StudyOnceCommentSearchListResponse searchSortedCommentsByStudyOnceId(Long studyOnceId) { List comments = studyOnceCommentRepository.findAllByStudyOnceId(studyOnceId); Map commentMap = comments.stream() .collect(Collectors.toMap(StudyOnceComment::getId, comment -> comment)); - StudyOnceCommentsSearchResponse response = new StudyOnceCommentsSearchResponse( - memberMapper.toMemberResponse(findStudyOnceById(studyOnceId).getLeader())); + StudyOnceCommentSearchListResponse response = new StudyOnceCommentSearchListResponse( + memberMapper.toStudyOnceSearchCommentWriterResponse(findStudyOnceById(studyOnceId).getLeader())); for (StudyOnceComment comment : comments) { StudyOnceCommentSearchResponse commentSearchResponse = new StudyOnceCommentSearchResponse(); if (!comment.hasParentComment()) { - commentSearchResponse.setQuestionWriter(memberMapper.toMemberResponse(comment.getMember())); + commentSearchResponse.setQuestionWriter( + memberMapper.toStudyOnceSearchCommentWriterResponse(comment.getMember())); commentSearchResponse.setQuestionInfo(studyOnceCommentMapper.toStudyOnceCommentInfo(comment)); for (StudyOnceComment childComment : comment.getChildren()) { commentSearchResponse.addStudyOnceReplyResponse( From 8e80cf5f14ad9c62b7667f2b86d712fcf85d5584 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 22:06:25 +0900 Subject: [PATCH 10/12] =?UTF-8?q?chore:=20=EC=82=AC=EC=9A=A9=20=EC=95=88?= =?UTF-8?q?=ED=95=98=EB=8A=94=20mapper=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/mapper/BusinessHourMapper.java | 8 ---- .../com/example/demo/mapper/CafeMapper.java | 30 ------------ .../com/example/demo/mapper/MemberMapper.java | 9 ---- .../com/example/demo/mapper/ReviewMapper.java | 46 ------------------- .../example/demo/mapper/SnsDetailMapper.java | 7 --- .../example/demo/mapper/StudyOnceMapper.java | 23 ---------- 6 files changed, 123 deletions(-) diff --git a/src/main/java/com/example/demo/mapper/BusinessHourMapper.java b/src/main/java/com/example/demo/mapper/BusinessHourMapper.java index 26e969e..262defe 100644 --- a/src/main/java/com/example/demo/mapper/BusinessHourMapper.java +++ b/src/main/java/com/example/demo/mapper/BusinessHourMapper.java @@ -4,18 +4,10 @@ import java.util.stream.Collectors; import com.example.demo.domain.cafe.BusinessHour; -import com.example.demo.dto.cafe.BusinessHourResponse; import com.example.demo.dto.cafe.CafeSearchBusinessHourResponse; public class BusinessHourMapper { - public List toBusinessHourResponses(List businessHours) { - return businessHours.stream() - .map(hour -> new BusinessHourResponse(hour.getDay(), hour.getStartTime().toString(), - hour.getEndTime().toString())) - .collect(Collectors.toList()); - } - public List toCafeSearchBusinessHourResponses(List businessHours) { return businessHours.stream() .map(hour -> new CafeSearchBusinessHourResponse(hour.getDay(), hour.getStartTime().toString(), diff --git a/src/main/java/com/example/demo/mapper/CafeMapper.java b/src/main/java/com/example/demo/mapper/CafeMapper.java index 5b23afd..75e834a 100644 --- a/src/main/java/com/example/demo/mapper/CafeMapper.java +++ b/src/main/java/com/example/demo/mapper/CafeMapper.java @@ -9,12 +9,10 @@ import com.example.demo.domain.cafe.CafeSearchCondition; import com.example.demo.domain.cafe.OpenChecker; import com.example.demo.dto.cafe.BusinessHourResponse; -import com.example.demo.dto.cafe.CafeBasicInfoResponse; import com.example.demo.dto.cafe.CafeSearchBasicInfoResponse; import com.example.demo.dto.cafe.CafeSearchBusinessHourResponse; import com.example.demo.dto.cafe.CafeSearchListRequest; import com.example.demo.dto.cafe.CafeSearchListResponse; -import com.example.demo.dto.cafe.CafeSearchRequest; import com.example.demo.dto.cafe.CafeSearchResponse; import com.example.demo.dto.cafe.CafeSearchReviewResponse; import com.example.demo.dto.cafe.CafeSearchSnsResponse; @@ -58,24 +56,6 @@ public CafeSearchListResponse toCafeSearchResponse(Cafe cafe, OpenChecker businessHourResponses, - List snsResponses, - OpenChecker openChecker) { - return new CafeBasicInfoResponse( - cafe.getId(), - cafe.getName(), - cafe.showFullAddress(), - businessHourResponses, - cafe.isOpen(openChecker), - snsResponses, - cafe.getPhone(), - cafe.getMinBeveragePrice(), - cafe.getMaxAllowableStay().getValue(), - cafe.getAvgReviewRate() - ); - } - public CafeSearchBasicInfoResponse toCafeSearchBasicInfoResponse(Cafe cafe, List cafeSearchBusinessHourResponses, List cafeSearchSnsResponses, @@ -94,16 +74,6 @@ public CafeSearchBasicInfoResponse toCafeSearchBasicInfoResponse(Cafe cafe, ); } - public CafeSearchCondition toCafeSearchCondition(CafeSearchRequest request) { - return new CafeSearchCondition.Builder(request.isCanStudy(), - request.getArea()) - .maxTime(request.getMaxTime()) - .minMenuPrice(request.getMinBeveragePrice()) - .startTime(request.getStartTime()) - .endTime(request.getEndTime()) - .build(); - } - public CafeSearchCondition toCafeSearchCondition(CafeSearchListRequest request) { return new CafeSearchCondition.Builder(request.isCanStudy(), request.getArea()) diff --git a/src/main/java/com/example/demo/mapper/MemberMapper.java b/src/main/java/com/example/demo/mapper/MemberMapper.java index 2ef5aab..83ed341 100644 --- a/src/main/java/com/example/demo/mapper/MemberMapper.java +++ b/src/main/java/com/example/demo/mapper/MemberMapper.java @@ -1,22 +1,13 @@ package com.example.demo.mapper; import com.example.demo.domain.member.Member; -import com.example.demo.dto.WriterResponse; -import com.example.demo.dto.member.MemberResponse; import com.example.demo.dto.study.StudyOnceSearchCommentWriterResponse; public class MemberMapper { - public WriterResponse toWriterResponse(Member member) { - return new WriterResponse(member.getId(), member.getName(), member.getThumbnailImage().getThumbnailImage()); - } - public StudyOnceSearchCommentWriterResponse toStudyOnceSearchCommentWriterResponse(Member member) { return new StudyOnceSearchCommentWriterResponse(member.getId(), member.getName(), member.getThumbnailImage().getThumbnailImage()); } - public MemberResponse toMemberResponse(Member member) { - return new MemberResponse(member.getId(), member.getName(), member.getThumbnailImage().getThumbnailImage()); - } } diff --git a/src/main/java/com/example/demo/mapper/ReviewMapper.java b/src/main/java/com/example/demo/mapper/ReviewMapper.java index 52aa98a..0253f6d 100644 --- a/src/main/java/com/example/demo/mapper/ReviewMapper.java +++ b/src/main/java/com/example/demo/mapper/ReviewMapper.java @@ -10,25 +10,9 @@ import com.example.demo.dto.cafe.CafeSearchWriterResponse; import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.review.ReviewSearchListResponse; -import com.example.demo.dto.review.ReviewSearchResponse; public class ReviewMapper { - public List toReviewSearchResponses(List reviews) { - return reviews.stream() - .map(review -> - new ReviewSearchResponse( - review.getId(), - produceWriterResponse( - review.getMember().getId(), review.getMember().getName(), - review.getMember().getThumbnailImage().getThumbnailImage() - ), - review.getRate(), - review.getContent() - )) - .collect(Collectors.toList()); - } - public List toReviewSearchListResponses(List reviews) { return reviews.stream() .map(review -> @@ -62,19 +46,6 @@ public ReviewResponse toReviewResponse(Review findReview) { .build(); } - public List toReviewResponses(List reviews) { - return reviews.stream() - .map(review -> - produceReviewResponse( - review.getId(), - productWriterResponse(review.getMember()), - review.getRate(), - review.getContent() - ) - ) - .collect(Collectors.toList()); - } - public List toCafeSearchReviewResponses(List reviews) { return reviews.stream() .map(review -> @@ -100,23 +71,6 @@ private CafeSearchReviewResponse makeCafeSearchReviewResponse(Long reviewId, .build(); } - private ReviewResponse produceReviewResponse(Long reviewId, WriterResponse writerResponse, double rate, - String content) { - return ReviewResponse.builder() - .reviewId(reviewId) - .writer(writerResponse) - .rate(rate) - .content(content) - .build(); - } - - private WriterResponse productWriterResponse(Member member) { - return new WriterResponse(member.getId(), - member.getName(), - member.getThumbnailImage().getThumbnailImage() - ); - } - private CafeSearchWriterResponse makeCafeSearchWriterResponse(Member member) { return new CafeSearchWriterResponse(member.getId(), member.getName(), diff --git a/src/main/java/com/example/demo/mapper/SnsDetailMapper.java b/src/main/java/com/example/demo/mapper/SnsDetailMapper.java index 69f4691..a464db0 100644 --- a/src/main/java/com/example/demo/mapper/SnsDetailMapper.java +++ b/src/main/java/com/example/demo/mapper/SnsDetailMapper.java @@ -5,16 +5,9 @@ import com.example.demo.domain.cafe.SnsDetail; import com.example.demo.dto.cafe.CafeSearchSnsResponse; -import com.example.demo.dto.cafe.SnsResponse; public class SnsDetailMapper { - public List toSnsResponses(List snsDetails) { - return snsDetails.stream() - .map(snsDetail -> new SnsResponse(snsDetail.getName(), snsDetail.getUrl())) - .collect(Collectors.toList()); - } - public List toCafeSearchSnsResponses(List snsDetails) { return snsDetails.stream() .map(snsDetail -> new CafeSearchSnsResponse(snsDetail.getName(), snsDetail.getUrl())) diff --git a/src/main/java/com/example/demo/mapper/StudyOnceMapper.java b/src/main/java/com/example/demo/mapper/StudyOnceMapper.java index eb96fc1..b0c91dd 100644 --- a/src/main/java/com/example/demo/mapper/StudyOnceMapper.java +++ b/src/main/java/com/example/demo/mapper/StudyOnceMapper.java @@ -9,30 +9,12 @@ import com.example.demo.dto.cafe.CafeSearchStudyOnceResponse; import com.example.demo.dto.study.StudyOnceCreateRequest; import com.example.demo.dto.study.StudyOnceCreateResponse; -import com.example.demo.dto.study.StudyOnceForCafeResponse; import com.example.demo.dto.study.StudyOnceResponse; import com.example.demo.dto.study.StudyOnceSearchListResponse; import com.example.demo.dto.study.StudyOnceSearchResponse; public class StudyOnceMapper { - public List toStudyOnceForCafeResponse(Cafe findCafe) { - return findCafe.getStudyOnceGroup().stream() - .map(studyOnce -> - StudyOnceForCafeResponse.builder() - .cafeId(findCafe.getId()) - .studyOnceId(studyOnce.getId()) - .name(studyOnce.getName()) - .startDateTime(studyOnce.getStartDateTime()) - .endDateTime(studyOnce.getEndDateTime()) - .maxMemberCount(studyOnce.getMaxMemberCount()) - .nowMemberCount(studyOnce.getNowMemberCount()) - .isEnd(studyOnce.isAbleToTalk()) - .build() - ) - .collect(Collectors.toList()); - } - public List toCafeSearchStudyOnceResponse(Cafe findCafe) { return findCafe.getStudyOnceGroup().stream() .map(studyOnce -> @@ -135,9 +117,4 @@ public StudyOnceCreateResponse toStudyOnceCreateResponse(StudyOnce saved, boolea .build(); } - // public StudyOnceCommentResponse toStudyOnceQuestionResponse(StudyOnceComment question, - // WriterResponse writerResponse) { - // return new StudyOnceCommentResponse(question.getId(), question.getContent(), writerResponse); - // } - } From f1c0bf1451e3934457a9c95faa6e4e4f2a337023 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 22:25:16 +0900 Subject: [PATCH 11/12] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20dto=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=8F=20dto=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/dto/WriterResponse.java | 14 ------------ .../demo/dto/cafe/CafeBasicInfoResponse.java | 22 ------------------- .../demo/dto/cafe/CafeSearchRequest.java | 20 ----------------- .../demo/dto/email/EmailTemplateResponse.java | 12 ---------- .../demo/dto/profile/ProfileResponse.java | 16 -------------- .../demo/dto/review/ReviewResponse.java | 4 +--- .../dto/review/ReviewSearchListResponse.java | 4 +--- .../demo/dto/review/ReviewSearchRequest.java | 13 ----------- .../demo/dto/review/ReviewSearchResponse.java | 16 -------------- .../dto/study/StudyOnceForCafeResponse.java | 19 ---------------- .../com/example/demo/mapper/ReviewMapper.java | 16 +++++++++----- 11 files changed, 13 insertions(+), 143 deletions(-) delete mode 100644 src/main/java/com/example/demo/dto/WriterResponse.java delete mode 100644 src/main/java/com/example/demo/dto/cafe/CafeBasicInfoResponse.java delete mode 100644 src/main/java/com/example/demo/dto/cafe/CafeSearchRequest.java delete mode 100644 src/main/java/com/example/demo/dto/email/EmailTemplateResponse.java delete mode 100644 src/main/java/com/example/demo/dto/profile/ProfileResponse.java delete mode 100644 src/main/java/com/example/demo/dto/review/ReviewSearchRequest.java delete mode 100644 src/main/java/com/example/demo/dto/review/ReviewSearchResponse.java delete mode 100644 src/main/java/com/example/demo/dto/study/StudyOnceForCafeResponse.java diff --git a/src/main/java/com/example/demo/dto/WriterResponse.java b/src/main/java/com/example/demo/dto/WriterResponse.java deleted file mode 100644 index 11aeb54..0000000 --- a/src/main/java/com/example/demo/dto/WriterResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.demo.dto; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public class WriterResponse { - - private final long memberId; - private final String name; - private final String thumbnailImg; - -} diff --git a/src/main/java/com/example/demo/dto/cafe/CafeBasicInfoResponse.java b/src/main/java/com/example/demo/dto/cafe/CafeBasicInfoResponse.java deleted file mode 100644 index e69de45..0000000 --- a/src/main/java/com/example/demo/dto/cafe/CafeBasicInfoResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.demo.dto.cafe; - -import java.util.List; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public class CafeBasicInfoResponse { - - private final long cafeId; - private final String name; - private final String address; - private final List businessHours; - private final Boolean isOpen; - private final List sns; - private final String phone; - private final int minBeveragePrice; - private final int maxTime; - private final double avgReviewRate; -} diff --git a/src/main/java/com/example/demo/dto/cafe/CafeSearchRequest.java b/src/main/java/com/example/demo/dto/cafe/CafeSearchRequest.java deleted file mode 100644 index 6724ba1..0000000 --- a/src/main/java/com/example/demo/dto/cafe/CafeSearchRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.example.demo.dto.cafe; - -import com.example.demo.dto.PagedRequest; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@ToString -public class CafeSearchRequest extends PagedRequest { - private int startTime = 0; - private int endTime = 24; - private boolean canStudy; - private int minBeveragePrice = 0; - private int maxTime = 0; - private String area; - -} diff --git a/src/main/java/com/example/demo/dto/email/EmailTemplateResponse.java b/src/main/java/com/example/demo/dto/email/EmailTemplateResponse.java deleted file mode 100644 index 7685de5..0000000 --- a/src/main/java/com/example/demo/dto/email/EmailTemplateResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.demo.dto.email; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public class EmailTemplateResponse { - - private final String title; - private final String content; -} diff --git a/src/main/java/com/example/demo/dto/profile/ProfileResponse.java b/src/main/java/com/example/demo/dto/profile/ProfileResponse.java deleted file mode 100644 index 14d9be9..0000000 --- a/src/main/java/com/example/demo/dto/profile/ProfileResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.demo.dto.profile; - -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.ToString; - -@RequiredArgsConstructor -@Getter -@EqualsAndHashCode -@ToString -public class ProfileResponse { - private final String name; - private final String thumbnailImg; - private final String introduction; -} diff --git a/src/main/java/com/example/demo/dto/review/ReviewResponse.java b/src/main/java/com/example/demo/dto/review/ReviewResponse.java index 5b1c6df..7111224 100644 --- a/src/main/java/com/example/demo/dto/review/ReviewResponse.java +++ b/src/main/java/com/example/demo/dto/review/ReviewResponse.java @@ -1,7 +1,5 @@ package com.example.demo.dto.review; -import com.example.demo.dto.WriterResponse; - import lombok.Builder; import lombok.Getter; @@ -10,7 +8,7 @@ public class ReviewResponse { private final long reviewId; - private final WriterResponse writer; + private final ReviewWriterSearchResponse writer; private final double rate; private final String content; } diff --git a/src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java b/src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java index 8eeee5b..23b45cf 100644 --- a/src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java +++ b/src/main/java/com/example/demo/dto/review/ReviewSearchListResponse.java @@ -1,7 +1,5 @@ package com.example.demo.dto.review; -import com.example.demo.dto.WriterResponse; - import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -9,7 +7,7 @@ @RequiredArgsConstructor public class ReviewSearchListResponse { private final long reviewId; - private final WriterResponse writer; + private final ReviewWriterSearchListResponse writer; private final double rate; private final String content; } diff --git a/src/main/java/com/example/demo/dto/review/ReviewSearchRequest.java b/src/main/java/com/example/demo/dto/review/ReviewSearchRequest.java deleted file mode 100644 index ecbfc9e..0000000 --- a/src/main/java/com/example/demo/dto/review/ReviewSearchRequest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.demo.dto.review; - -import com.example.demo.dto.PagedRequest; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public class ReviewSearchRequest extends PagedRequest { - - private final Long cafeId; -} diff --git a/src/main/java/com/example/demo/dto/review/ReviewSearchResponse.java b/src/main/java/com/example/demo/dto/review/ReviewSearchResponse.java deleted file mode 100644 index e2c3d5f..0000000 --- a/src/main/java/com/example/demo/dto/review/ReviewSearchResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.demo.dto.review; - -import com.example.demo.dto.WriterResponse; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public class ReviewSearchResponse { - - private final long reviewId; - private final WriterResponse writer; - private final double rate; - private final String content; -} diff --git a/src/main/java/com/example/demo/dto/study/StudyOnceForCafeResponse.java b/src/main/java/com/example/demo/dto/study/StudyOnceForCafeResponse.java deleted file mode 100644 index c7ceb83..0000000 --- a/src/main/java/com/example/demo/dto/study/StudyOnceForCafeResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.demo.dto.study; - -import java.time.LocalDateTime; - -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -public class StudyOnceForCafeResponse { - private long cafeId; - private long studyOnceId; - private String name; - private LocalDateTime startDateTime; - private LocalDateTime endDateTime; - private int maxMemberCount; - private int nowMemberCount; - private boolean isEnd; -} diff --git a/src/main/java/com/example/demo/mapper/ReviewMapper.java b/src/main/java/com/example/demo/mapper/ReviewMapper.java index 0253f6d..f1a3d99 100644 --- a/src/main/java/com/example/demo/mapper/ReviewMapper.java +++ b/src/main/java/com/example/demo/mapper/ReviewMapper.java @@ -5,11 +5,12 @@ import com.example.demo.domain.member.Member; import com.example.demo.domain.review.Review; -import com.example.demo.dto.WriterResponse; import com.example.demo.dto.cafe.CafeSearchReviewResponse; import com.example.demo.dto.cafe.CafeSearchWriterResponse; import com.example.demo.dto.review.ReviewResponse; import com.example.demo.dto.review.ReviewSearchListResponse; +import com.example.demo.dto.review.ReviewWriterSearchListResponse; +import com.example.demo.dto.review.ReviewWriterSearchResponse; public class ReviewMapper { @@ -18,7 +19,7 @@ public List toReviewSearchListResponses(List r .map(review -> new ReviewSearchListResponse( review.getId(), - produceWriterResponse( + makeReviewWriterSearchListResponse( review.getMember().getId(), review.getMember().getName(), review.getMember().getThumbnailImage().getThumbnailImage() ), @@ -28,15 +29,20 @@ public List toReviewSearchListResponses(List r .collect(Collectors.toList()); } - private WriterResponse produceWriterResponse(Long memberId, String name, String thumbnailImg) { - return new WriterResponse(memberId, name, thumbnailImg); + private ReviewWriterSearchListResponse makeReviewWriterSearchListResponse(Long memberId, String name, + String thumbnailImg) { + return new ReviewWriterSearchListResponse(memberId, name, thumbnailImg); + } + + private ReviewWriterSearchResponse makeReviewWriterSearchResponse(Long memberId, String name, String thumbnailImg) { + return new ReviewWriterSearchResponse(memberId, name, thumbnailImg); } public ReviewResponse toReviewResponse(Review findReview) { return ReviewResponse.builder() .reviewId(findReview.getId()) .writer( - produceWriterResponse( + makeReviewWriterSearchResponse( findReview.getMember().getId(), findReview.getMember().getName(), findReview.getMember().getThumbnailImage().getThumbnailImage() From 126ccb0253d2130abbf9eb0a014da91825717101 Mon Sep 17 00:00:00 2001 From: donghyunkim Date: Mon, 29 Apr 2024 22:25:45 +0900 Subject: [PATCH 12/12] =?UTF-8?q?refactor:=20=EB=B6=84=EB=A6=AC=ED=95=9C?= =?UTF-8?q?=20dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/review/ReviewWriterSearchListResponse.java | 12 ++++++++++++ .../demo/dto/review/ReviewWriterSearchResponse.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/example/demo/dto/review/ReviewWriterSearchListResponse.java create mode 100644 src/main/java/com/example/demo/dto/review/ReviewWriterSearchResponse.java diff --git a/src/main/java/com/example/demo/dto/review/ReviewWriterSearchListResponse.java b/src/main/java/com/example/demo/dto/review/ReviewWriterSearchListResponse.java new file mode 100644 index 0000000..81b9929 --- /dev/null +++ b/src/main/java/com/example/demo/dto/review/ReviewWriterSearchListResponse.java @@ -0,0 +1,12 @@ +package com.example.demo.dto.review; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class ReviewWriterSearchListResponse { + private final long memberId; + private final String name; + private final String thumbnailImg; +} diff --git a/src/main/java/com/example/demo/dto/review/ReviewWriterSearchResponse.java b/src/main/java/com/example/demo/dto/review/ReviewWriterSearchResponse.java new file mode 100644 index 0000000..c442926 --- /dev/null +++ b/src/main/java/com/example/demo/dto/review/ReviewWriterSearchResponse.java @@ -0,0 +1,12 @@ +package com.example.demo.dto.review; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class ReviewWriterSearchResponse { + private final long memberId; + private final String name; + private final String thumbnailImg; +}