Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD SUCCESS] [BUILD SUCCESS] 공통으로 사용하는 dto 분리 리팩토링 #90

Merged
merged 12 commits into from
Apr 29, 2024
Merged
18 changes: 9 additions & 9 deletions src/main/java/com/example/demo/controller/CafeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,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.CafeSearchRequest;
import com.example.demo.dto.cafe.CafeSearchListRequest;
import com.example.demo.dto.cafe.CafeSearchListResponse;
import com.example.demo.dto.cafe.CafeSearchResponse;
import com.example.demo.service.cafe.CafeService;

Expand All @@ -26,22 +26,22 @@ public class CafeController {
private final CafegoryTokenManager cafegoryTokenManager;

@GetMapping("/cafe/list")
public ResponseEntity<PagedResponse<CafeSearchResponse>> searchCafeList(
@ModelAttribute CafeSearchRequest cafeSearchRequest) {
PagedResponse<CafeSearchResponse> response = cafeService.searchWithPagingByDynamicFilter(
cafeSearchRequest);
public ResponseEntity<PagedResponse<CafeSearchListResponse>> searchCafeList(
@ModelAttribute CafeSearchListRequest cafeSearchListRequest) {
PagedResponse<CafeSearchListResponse> response = cafeService.searchWithPagingByDynamicFilter(
cafeSearchListRequest);
return new ResponseEntity<>(response, HttpStatus.OK);
}

@GetMapping("/cafe/{cafeId}")
public ResponseEntity<CafeResponse> searchCafe(@PathVariable Long cafeId,
public ResponseEntity<CafeSearchResponse> 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);
}

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/example/demo/controller/MailController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,18 +23,18 @@ public class MailController {
private final MailService mailService;

@PostMapping("/email")
public ResponseEntity<EmailTemplateResponse> sendEmail(
public ResponseEntity<EmailSendTemplateResponse> 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<EmailTemplateResponse> sendCustomEmail(
public ResponseEntity<EmailSendCustomTemplateResponse> 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);
}
}
14 changes: 8 additions & 6 deletions src/main/java/com/example/demo/controller/ProfileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,19 +25,20 @@ public class ProfileController {
private final CafegoryTokenManager cafegoryTokenManager;

@GetMapping("/{memberId:[0-9]+}")
public ResponseEntity<ProfileResponse> get(@PathVariable("memberId") Long targetMemberId,
public ResponseEntity<ProfileGetResponse> 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<ProfileResponse> update(@PathVariable("memberId") Long targetMemberId,
public ResponseEntity<ProfileUpdateResponse> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,8 +33,8 @@ public class ReviewController {
private final CafegoryTokenManager cafegoryTokenManager;

@GetMapping("/cafe/{cafeId}/review/list")
public ResponseEntity<PagedResponse<ReviewSearchResponse>> reviewList(ReviewSearchRequest request) {
PagedResponse<ReviewSearchResponse> response = reviewQueryService.searchWithPagingByCafeId(
public ResponseEntity<PagedResponse<ReviewSearchListResponse>> reviewList(ReviewSearchListRequest request) {
PagedResponse<ReviewSearchListResponse> response = reviewQueryService.searchWithPagingByCafeId(
request);
return new ResponseEntity<>(response, HttpStatus.OK);
}
Expand Down
32 changes: 17 additions & 15 deletions src/main/java/com/example/demo/controller/StudyOnceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@

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.study.StudyMembersResponse;
import com.example.demo.dto.cafe.CafeSearchListResponse;
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.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.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;
Expand Down Expand Up @@ -87,7 +89,7 @@ public ResponseEntity<StudyOnceCreateResponse> create(
}

@PatchMapping("/{studyOnceId:[0-9]+}")
public ResponseEntity<StudyOnceInfoResponse> update(@PathVariable Long studyOnceId,
public ResponseEntity<StudyOnceResponse> update(@PathVariable Long studyOnceId,
@RequestBody @Validated StudyOnceUpdateRequest request,
@RequestHeader("Authorization") String authorization) {
long leaderId = cafegoryTokenManager.getIdentityId(authorization);
Expand All @@ -96,7 +98,7 @@ public ResponseEntity<StudyOnceInfoResponse> 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);
}

Expand All @@ -110,12 +112,12 @@ public ResponseEntity<StudyOnceJoinResult> tryJoin(@PathVariable Long studyOnceI
}

@DeleteMapping("/{studyOnceId:[0-9]+}")
public ResponseEntity<StudyOnceJoinResult> tryQuit(@PathVariable Long studyOnceId,
public ResponseEntity<StudyOnceQuitResponse> 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")
Expand All @@ -129,30 +131,30 @@ public ResponseEntity<UpdateAttendanceResponse> takeAttendance(@PathVariable Lon
}

@PatchMapping("/{studyOnceId:[0-9]+}/location")
public ResponseEntity<CafeSearchResponse> changeCafe(@PathVariable Long studyOnceId,
public ResponseEntity<CafeSearchListResponse> 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);
}

@GetMapping("/{studyOnceId:[0-9]+}/member/list")
public ResponseEntity<StudyMembersResponse> findStudyMemberList(@PathVariable Long studyOnceId,
public ResponseEntity<StudyMemberListResponse> 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<StudyOnceCommentResponse> 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(
Expand Down Expand Up @@ -217,10 +219,10 @@ public ResponseEntity<StudyOnceCommentResponse> deleteReply(@PathVariable final
}

@GetMapping("/{studyOnceId:[0-9]+}/comment/list")
public ResponseEntity<StudyOnceCommentsSearchResponse> searchComments(@PathVariable Long studyOnceId,
public ResponseEntity<StudyOnceCommentSearchListResponse> searchComments(@PathVariable Long studyOnceId,
@RequestHeader("Authorization") String authorization) {
cafegoryTokenManager.getIdentityId(authorization);
StudyOnceCommentsSearchResponse response = studyOnceCommentQueryService.searchSortedCommentsByStudyOnceId(
StudyOnceCommentSearchListResponse response = studyOnceCommentQueryService.searchSortedCommentsByStudyOnceId(
studyOnceId);
return ResponseEntity.ok(response);
}
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/com/example/demo/dto/cafe/CafeResponse.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<CafeSearchBusinessHourResponse> businessHours;
private final Boolean isOpen;
private final List<CafeSearchSnsResponse> sns;
private final String phone;
private final int minBeveragePrice;
private final int maxTime;
private final double avgReviewRate;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
@Getter
@Setter
@ToString
public class CafeSearchRequest extends PagedRequest {
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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

@Getter
@RequiredArgsConstructor
public class CafeBasicInfoResponse {
public class CafeSearchListResponse {

private final long cafeId;
private final String name;
private final String address;
private final String area;
private final List<BusinessHourResponse> businessHours;
private final Boolean isOpen;
private final List<SnsResponse> sns;
private final String phone;
private final int minBeveragePrice;
private final int maxTime;
private final double avgReviewRate;

}
22 changes: 8 additions & 14 deletions src/main/java/com/example/demo/dto/cafe/CafeSearchResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@

import java.util.List;

import com.example.demo.dto.study.CanMakeStudyOnceResponse;

import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
@Builder
public class CafeSearchResponse {

private final long cafeId;
private final String name;
private final String address;
private final String area;
private final List<BusinessHourResponse> businessHours;
private final Boolean isOpen;
private final List<SnsResponse> sns;
private final String phone;
private final int minBeveragePrice;
private final int maxTime;
private final double avgReviewRate;

private final CafeSearchBasicInfoResponse basicInfo;
private final List<CafeSearchReviewResponse> review;
private final List<CafeSearchStudyOnceResponse> meetings;
private final List<CanMakeStudyOnceResponse> canMakeMeeting;
}
Original file line number Diff line number Diff line change
@@ -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;
}
11 changes: 11 additions & 0 deletions src/main/java/com/example/demo/dto/cafe/CafeSearchSnsResponse.java
Original file line number Diff line number Diff line change
@@ -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;
}
Loading
Loading