From c7d9451e744dc98ed26bdfaae079d7c55a7b2540 Mon Sep 17 00:00:00 2001 From: SaeJoon Date: Thu, 15 Feb 2024 17:02:47 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C,=20=EB=82=B4=EA=B0=80=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=ED=95=9C=20=EA=BF=80=ED=8C=81,=20=EC=A7=88=EB=AC=B8,=20?= =?UTF-8?q?=EC=86=8C=ED=86=B5=ED=95=B4=EC=9A=94=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=95=20=EC=B2=98=EB=A6=AC=20=EA=B5=AC=ED=98=84=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=ED=96=88=EC=8A=B5=EB=8B=88=EB=8B=A4=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ttoklip/domain/member/domain/Member.java | 5 +- .../mypage/main/constant/MyPageConstant.java | 289 +++++++++++++++--- .../main/controller/MyPageController.java | 116 ++++++- .../main/domain/MyCommunityRepostiory.java | 51 ++++ .../main/domain/MyHoneyTipRepository.java | 49 +++ .../main/domain/MyQuestionRepository.java | 49 +++ .../main/dto/request/BlockedRequest.java | 2 + .../main/dto/request/ProfileEditRequest.java | 44 +++ .../dto/response/BlockedListResponse.java | 14 - .../main/dto/response/BlockedResponse.java | 14 - .../main/dto/response/MyPageResponse.java | 35 ++- .../main/dto/response/MyPostsResponse.java | 5 - .../dto/response/ParticipateListResponse.java | 14 - .../dto/response/ParticipateResponse.java | 4 - .../main/dto/response/RestricetdResponse.java | 15 - .../main/dto/response/ScrapPostResponse.java | 12 - .../dto/response/ScrapPostsListResponse.java | 13 - ...tResponse.java => UserSingleResponse.java} | 4 +- .../mypage/main/service/MyPageService.java | 159 +++++++++- .../post/controller/NoticeController.java | 2 +- .../term/controller/TermController.java | 2 +- .../domain/privacy/domain/Profile.java | 2 + .../api/ttoklip/global/success/Message.java | 11 + 23 files changed, 739 insertions(+), 172 deletions(-) create mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java create mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java create mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java create mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/ProfileEditRequest.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedListResponse.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedResponse.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPostsResponse.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateListResponse.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateResponse.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/RestricetdResponse.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostResponse.java delete mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostsListResponse.java rename src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/{MyPostsListResponse.java => UserSingleResponse.java} (61%) diff --git a/src/main/java/com/api/ttoklip/domain/member/domain/Member.java b/src/main/java/com/api/ttoklip/domain/member/domain/Member.java index d8939b57..0b233743 100644 --- a/src/main/java/com/api/ttoklip/domain/member/domain/Member.java +++ b/src/main/java/com/api/ttoklip/domain/member/domain/Member.java @@ -46,7 +46,7 @@ public class Member extends BaseEntity { private String email; // private Long kakaoId; - + private String street;//02.14 세준-주소 private String provider; private String nickname; @@ -88,13 +88,14 @@ public MemberEditorBuilder toEditor() { return MemberEditor.builder() .independentYear(independentYear) .independentMonth(independentMonth) -// .street() + .street(street) .nickname(nickname); } public void insertPrivacy(MemberEditor memberEditor) { independentYear = memberEditor.getIndependentYear(); independentMonth = memberEditor.getIndependentMonth(); + street=memberEditor.getStreet(); nickname = memberEditor.getNickname(); } } \ No newline at end of file diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/constant/MyPageConstant.java b/src/main/java/com/api/ttoklip/domain/mypage/main/constant/MyPageConstant.java index ff4d4738..d84aaaa7 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/constant/MyPageConstant.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/constant/MyPageConstant.java @@ -69,55 +69,127 @@ public class MyPageConstant { } """; - public static final String scrapedPostsResponse = """ + public static final String scrapHoneyTipsResponse = """ { "time": "2024-01-11T16:06:30.852Z", "status": 200, "code": "200", "message": "요청에 성공하였습니다.", "result": { - "scrapedPosts": [ - { - "postId": 1, - "type": "honeytip", - "title": "스크랩한 허니팁 제목 예시 1", - "content": "스크랩한 허니팁 내용 예시 1", - "author": "글쓴이1", - "category": "카테고리1", - "scrapedTime": "2024-01-11T16:06:30.852Z", - "likes": 10, - "comments": 3, - "scrapCount": 20 - }, - { - "postId": 2, - "type": "newsletter", - "title": "스크랩한 뉴스레터 제목 예시 2", - "content": "스크랩한 뉴스레터 내용 예시 2", - "author": "글쓴이2", - "category": "카테고리2", - "scrapedTime": "2024-01-10T10:30:00.000Z", - "likes": 15, - "comments": 5, - "scrapCount": 30 - }, - { - "postId": 3, - "type": "cart", - "title": "스크랩한 카트 제목 예시 3", - "content": "스크랩한 카트 내용 예시 3", - "author": "글쓴이3", - "category": "카테고리3", - "scrapedTime": "2024-01-09T12:00:00.000Z", - "likes": 8, - "comments": 2, - "scrapCount": 25 - } - ] + "honeyTips": [ + { + "honeyTipId": 5, + "title": "first", + "content": "first" + }, + { + "honeyTipId": 4, + "title": "first", + "content": "fff" + }, + { + "honeyTipId": 3, + "title": "first", + "content": "fff" + }, + { + "honeyTipId": 2, + "title": "first", + "content": "fff" + }, + { + "honeyTipId": 1, + "title": "first", + "content": "fff" + } + ], + "totalPage": 1, + "totalElements": 5, + "isFirst": true, + "isLast": true + } + } + """; + public static final String scrapNewsLetterResponse = """ + { + "time": "2024-01-11T16:06:30.852Z", + "status": 200, + "code": "200", + "message": "요청에 성공하였습니다.", + "result": { + "newsletters": [ + { + "newsLetterId"first", + "content": "first" + }, + { + "newsLetterId": 4, + "title": "first", + "content": "fff" + }, + { + "newsLetterId": 3, + "title": "first", + "content": "fff" + }, + { + "newsLetterId": 2, + "title": "first", + "content": "fff" + }, + { + "newsLetterId": 1, + "title": "first", + "content": "fff" + } + ], + "totalPage": 1, + "totalElements": 5, + "isFirst": true, + "isLast": true + } + } + """; + public static final String scrapCommunityResponse = """ + { + "time": "2024-01-11T16:06:30.852Z", + "status": 200, + "code": "200", + "message": "요청에 성공하였습니다.", + "result": { + "communities": [ + { + "communityId"first", + "content": "first" + }, + { + "communityId": 4, + "title": "first", + "content": "fff" + }, + { + "communityId": 3, + "title": "first", + "content": "fff" + }, + { + "communityId": 2, + "title": "first", + "content": "fff" + }, + { + "communityId": 1, + "title": "first", + "content": "fff" + } + ], + "totalPage": 1, + "totalElements": 5, + "isFirst": true, + "isLast": true } } """; - public static final String myPostsResponse = """ { "time": "2024-01-11T16:06:30.852Z", @@ -163,7 +235,129 @@ public class MyPageConstant { } } """; - + public static final String myHoneyTipsResponse = """ + { + "time": "2024-01-11T16:06:30.852Z", + "status": 200, + "code": "200", + "message": "요청에 성공하였습니다.", + "result": { + "honeyTips": [ + { + "honeyTipId": 5, + "title": "first", + "content": "first" + }, + { + "honeyTipId": 4, + "title": "first", + "content": "fff" + }, + { + "honeyTipId": 3, + "title": "first", + "content": "fff" + }, + { + "honeyTipId": 2, + "title": "first", + "content": "fff" + }, + { + "honeyTipId": 1, + "title": "first", + "content": "fff" + } + ], + "totalPage": 1, + "totalElements": 5, + "isFirst": true, + "isLast": true + } + } + """; + public static final String myCommunityResponse = """ + { + "time": "2024-01-11T16:06:30.852Z", + "status": 200, + "code": "200", + "message": "요청에 성공하였습니다.", + "result": { + "communities": [ + { + "communityId":5, + "title": "first", + "content": "first" + }, + { + "communityId": 4, + "title": "first", + "content": "fff" + }, + { + "communityId": 3, + "title": "first", + "content": "fff" + }, + { + "communityId": 2, + "title": "first", + "content": "fff" + }, + { + "communityId": 1, + "title": "first", + "content": "fff" + } + ], + "totalPage": 1, + "totalElements": 5, + "isFirst": true, + "isLast": true + } + } + """; + public static final String myQuestionResponse = """ + { + "time": "2024-01-11T16:06:30.852Z", + "status": 200, + "code": "200", + "message": "요청에 성공하였습니다.", + "result": { + "communities": [ + { + "questionId": 5, + "title": "first", + "content": "first" + }, + { + "questionId": 4, + "title": "first", + "content": "fff" + }, + { + "questionId": 3, + "title": "first", + "content": "fff" + }, + { + "questionId": 2, + "title": "first", + "content": "fff" + }, + { + "questionId": 1, + "title": "first", + "content": "fff" + } + ], + "totalPage": 1, + "totalElements": 5, + "isFirst": true, + "isLast": true + } + } + """; public static final String participatedDealsResponse = """ { "time": "2024-01-11T16:06:30.852Z", @@ -198,7 +392,18 @@ public class MyPageConstant { } } """; - + public static final String editMyProfile = """ + { + "time": "2024-01-11T16:06:30.852Z", + "status": 200, + "code": "200", + "message": "요청에 성공하였습니다.", + "result": { + "message": "개인정보를 수정했습니다." + } + } + } + """; diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java index 003260a3..7e6560df 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java @@ -1,10 +1,17 @@ package com.api.ttoklip.domain.mypage.main.controller; +import com.api.ttoklip.domain.common.search.response.CommunityPaging; +import com.api.ttoklip.domain.common.search.response.HoneyTipPaging; +import com.api.ttoklip.domain.common.search.response.NewsletterPaging; import com.api.ttoklip.domain.mypage.main.constant.MyPageConstant; import com.api.ttoklip.domain.mypage.main.dto.request.BlockedRequest; import com.api.ttoklip.domain.mypage.main.dto.request.MyPageRequest; +import com.api.ttoklip.domain.mypage.main.dto.request.ProfileEditRequest; import com.api.ttoklip.domain.mypage.main.dto.response.*; import com.api.ttoklip.domain.mypage.main.service.MyPageService; +import com.api.ttoklip.domain.privacy.constant.PrivacyConstant; +import com.api.ttoklip.domain.privacy.dto.PrivacyCreateRequest; +import com.api.ttoklip.domain.privacy.service.ProfileService; import com.api.ttoklip.global.success.Message; import com.api.ttoklip.global.success.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; @@ -15,15 +22,19 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @Tag(name = "My Page", description = "마이페이지 api입니다") @RequiredArgsConstructor @RestController -@RequestMapping("/api/v1/mypage") +@RequestMapping("/api/v1/my-page") public class MyPageController { private final MyPageService myPageService; + private final ProfileService profileService; @Operation(summary = "마이페이지 정보 불러오기", description = "마이페이지의 기본 정보인 닉네임,동네,레벨,충족도를 가져옵니다") @ApiResponses(value = { @@ -41,6 +52,23 @@ public SuccessResponse getMyProfile() { return new SuccessResponse<>(myPageService.getMyProfile()); } + @Operation(summary = "개인정보 수정", description = "프로필 사진, 똑립 전용 닉네임, 자취 경력 수정") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "개인정보 수정", + content = @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = SuccessResponse.class), + examples = @ExampleObject( + name = "SuccessResponse", + value = MyPageConstant.editMyProfile, + description = "개인정보를 수정했습니다." + )))}) + @PatchMapping("/edit") + public SuccessResponse edit(@ModelAttribute @Validated final PrivacyCreateRequest request) { + Message message = profileService.insert(request); + return new SuccessResponse<>(message); + } + @Operation(summary = "계정의 사용 제한 정보", description = "계정의 제한 기간과 사유를 불러옵니다.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "계정의 제한 사유 조회 성공", @@ -53,7 +81,7 @@ public SuccessResponse getMyProfile() { description = "제한 기간과 사유를 조회했습니다" )))}) @GetMapping("/restricted") - public SuccessResponse restricted() { + public SuccessResponse restricted() { return new SuccessResponse<>(myPageService.restricted()); } @Operation(summary = "내가 차단한 계정", description = "내가 차단한 계정들을 불러옵니다") @@ -68,7 +96,7 @@ public SuccessResponse restricted() { description = "차단한 계정들을 조회했습니다" )))}) @GetMapping("/blocked") - public SuccessResponse blockedUser() { + public SuccessResponse blockedUser() { return new SuccessResponse<>(myPageService.blockedUser()); } @Operation(summary = "차단을 해제 합니다", description = "차단을 해제 합니다") @@ -83,9 +111,24 @@ public SuccessResponse blockedUser() { description = "제한 기간과 사유를 조회했습니다" )))}) @DeleteMapping("/unblock/{targetId}") - public SuccessResponse unblock(@RequestParam String targetId) { + public SuccessResponse unblock(@PathVariable Long targetId) { return new SuccessResponse<>(myPageService.unblock(targetId));//수정 필요 } + @Operation(summary = "스크랩한 허니팁 목록", description = "스크랩한 글 목록 불러오기") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "스크랩 조회 성공", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = SuccessResponse.class), + examples = @ExampleObject( + name = "SuccessResponse", + value = MyPageConstant.scrapHoneyTipsResponse, + description = "스크랩한 허니팁들을 불러왔습니다" + )))}) + @GetMapping("/scraped-posts/honeytip") + public SuccessResponse scrapHoneyTips() { + return new SuccessResponse<>(myPageService.scrapHoneyTips()); + } @Operation(summary = "스크랩한 글 목록", description = "스크랩한 글 목록 불러오기") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "스크랩 조회 성공", @@ -94,12 +137,57 @@ public SuccessResponse unblock(@RequestParam String targetId) { schema = @Schema(implementation = SuccessResponse.class), examples = @ExampleObject( name = "SuccessResponse", - value = MyPageConstant.scrapedPostsResponse, - description = "스크랩한 글을 불러왔습니다" + value = MyPageConstant.scrapNewsLetterResponse, + description = "스크랩한 뉴스레터들을 불러왔습니다" + )))}) + @GetMapping("/scraped-posts/newsletter") + public SuccessResponse scrapNewsletters() { + return new SuccessResponse<>(myPageService.scrapNewsletters()); + } + @Operation(summary = "스크랩한 글 목록", description = "스크랩한 글 목록 불러오기") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "스크랩 조회 성공", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = SuccessResponse.class), + examples = @ExampleObject( + name = "SuccessResponse", + value = MyPageConstant.scrapCommunityResponse, + description = "스크랩한 소통해요들을 불러왔습니다" + )))}) + @GetMapping("/scraped-posts/community") + public SuccessResponse scrapCommunity() { + return new SuccessResponse<>(myPageService.scrapCommunity()); + } + @Operation(summary = "내가 작성한 글 목록", description = "내가 작성한 글 목록 불러오기") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "작성한 글 목록 조회 성공", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = SuccessResponse.class), + examples = @ExampleObject( + name = "SuccessResponse", + value = MyPageConstant.myHoneyTipsResponse, + description = "내가 작성한 글들을 불러왔습니다" + )))}) + @GetMapping("/honeytip") + public SuccessResponse myHoneyTip(final Pageable pageable) { + return new SuccessResponse<>(myPageService.myHoneyTips(pageable)); + } + @Operation(summary = "내가 작성한 글 목록", description = "내가 작성한 글 목록 불러오기") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "작성한 글 목록 조회 성공", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = SuccessResponse.class), + examples = @ExampleObject( + name = "SuccessResponse", + value = MyPageConstant.myQuestionResponse, + description = "내가 작성한 글들을 불러왔습니다" )))}) - @GetMapping("/scraped-posts") - public SuccessResponse scrapPosts() { - return new SuccessResponse<>(myPageService.scrapPosts()); + @GetMapping("/question") + public SuccessResponse myQuestion(final Pageable pageable) { + return new SuccessResponse<>(myPageService.myQuestions(pageable)); } @Operation(summary = "내가 작성한 글 목록", description = "내가 작성한 글 목록 불러오기") @ApiResponses(value = { @@ -109,12 +197,12 @@ public SuccessResponse scrapPosts() { schema = @Schema(implementation = SuccessResponse.class), examples = @ExampleObject( name = "SuccessResponse", - value = MyPageConstant.myPostsResponse, + value = MyPageConstant.myCommunityResponse, description = "내가 작성한 글들을 불러왔습니다" )))}) - @GetMapping("/my-posts") - public SuccessResponse myPosts() { - return new SuccessResponse<>(myPageService.myPosts()); + @GetMapping("/community") + public SuccessResponse myCommunity() { + return new SuccessResponse<>(myPageService.myCommunities()); } @Operation(summary = "내가 참여한 거래 목록", description = "내가 참여한 거래 목록 불러오기") @ApiResponses(value = { @@ -128,7 +216,7 @@ public SuccessResponse myPosts() { description = "참여한 거래를 조회했습니다" )))}) @GetMapping("/participate-deals") - public SuccessResponse participateDeals() { + public SuccessResponse participateDeals() { return new SuccessResponse<>(myPageService.participateDeals()); } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java new file mode 100644 index 00000000..64c02757 --- /dev/null +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java @@ -0,0 +1,51 @@ +package com.api.ttoklip.domain.mypage.main.domain; + +import com.api.ttoklip.domain.town.community.comment.QCommunityComment; +import com.api.ttoklip.domain.town.community.post.entity.Community; +import com.api.ttoklip.domain.town.community.post.entity.QCommunity; +import com.querydsl.core.types.dsl.Wildcard; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class MyCommunityRepostiory { + private final JPAQueryFactory jpaQueryFactory; + private final QCommunity community = QCommunity.community; + private final QCommunityComment communityComment = QCommunityComment.communityComment; + + public Page getContain(final Long userId, final Pageable pageable) { + List content = getSearchPageId(userId ,pageable); + Long count = countQuery(); + return new PageImpl<>(content, pageable, count); + } + + private List getSearchPageId(final Long userId, final Pageable pageable) { + return jpaQueryFactory + .select(community) + .from(community) + .where(community.member.id.eq(userId)) + .distinct() + .leftJoin(community.communityComments, communityComment) + .fetchJoin() + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) + .orderBy(community.id.desc()) + .fetch(); + } + + + private Long countQuery() { + return jpaQueryFactory + .select(Wildcard.count) + .from(community) + .distinct() + .fetchOne(); + } +} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java new file mode 100644 index 00000000..ae3ace07 --- /dev/null +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java @@ -0,0 +1,49 @@ +package com.api.ttoklip.domain.mypage.main.domain; + +import com.api.ttoklip.domain.honeytip.comment.domain.QHoneyTipComment; +import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip; +import com.api.ttoklip.domain.honeytip.post.domain.QHoneyTip; + +import com.querydsl.core.types.dsl.Wildcard; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class MyHoneyTipRepository { + private final JPAQueryFactory jpaQueryFactory; + private final QHoneyTip honeyTip = QHoneyTip.honeyTip; + private final QHoneyTipComment honeyTipComment = QHoneyTipComment.honeyTipComment; + + public Page getContain(final Long userId, final Pageable pageable){ + List content = getSearchPageId(userId,pageable); + Long count = countQuery(); + return new PageImpl<>(content, pageable, count); + } + private List getSearchPageId(final Long userId, final Pageable pageable) { + return jpaQueryFactory + .select(honeyTip) + .from(honeyTip) + .where(honeyTip.member.id.eq(userId)) + .distinct() + .leftJoin(honeyTip.honeyTipComments, honeyTipComment) + .fetchJoin() + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) + .orderBy(honeyTip.id.desc()) + .fetch(); + } + private Long countQuery() { + return jpaQueryFactory + .select(Wildcard.count) + .from(honeyTip) + .distinct() + .fetchOne(); + } +} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java new file mode 100644 index 00000000..8b53d9f4 --- /dev/null +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java @@ -0,0 +1,49 @@ +package com.api.ttoklip.domain.mypage.main.domain; + + +import com.api.ttoklip.domain.question.comment.domain.QQuestionComment; +import com.api.ttoklip.domain.question.post.domain.QQuestion; +import com.api.ttoklip.domain.question.post.domain.Question; +import com.querydsl.core.types.dsl.Wildcard; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class MyQuestionRepository { + private final JPAQueryFactory jpaQueryFactory; + private final QQuestion question = QQuestion.question; + private final QQuestionComment questionComment = QQuestionComment.questionComment; + + public Page getContain(final Long userId,final Pageable pageable){ + List content = getSearchPageId(userId,pageable); + Long count = countQuery(); + return new PageImpl<>(content, pageable, count); + } + private List getSearchPageId(final Long userId, final Pageable pageable) { + return jpaQueryFactory + .select(question) + .from(question) + .where(question.member.id.eq(userId)) + .distinct() + .leftJoin(question.questionComments, questionComment) + .fetchJoin() + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) + .orderBy(question.id.desc()) + .fetch(); + } + private Long countQuery() { + return jpaQueryFactory + .select(Wildcard.count) + .from(question) + .distinct() + .fetchOne(); + } +} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/BlockedRequest.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/BlockedRequest.java index fd8b535c..3445e8ad 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/BlockedRequest.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/BlockedRequest.java @@ -1,12 +1,14 @@ package com.api.ttoklip.domain.mypage.main.dto.request; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.extern.jackson.Jacksonized; @Getter @AllArgsConstructor @Jacksonized +@Builder public class BlockedRequest { private Long userId; } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/ProfileEditRequest.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/ProfileEditRequest.java new file mode 100644 index 00000000..81fdc967 --- /dev/null +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/request/ProfileEditRequest.java @@ -0,0 +1,44 @@ +package com.api.ttoklip.domain.mypage.main.dto.request; + +import com.api.ttoklip.domain.common.Category; +import com.api.ttoklip.global.exception.ApiException; +import com.api.ttoklip.global.exception.ErrorType; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +@Getter +@AllArgsConstructor +public class ProfileEditRequest { + private String street; + private String nickname; + private List categories; + + @NotNull(message = "프로필 이미지는 필수입니다.") + private MultipartFile profileImage; + + @Min(0) + @Max(99) + private int independentYear; + + @Min(0) + @Max(11) + private int independentMonth; + + public List getCategories() { + validCategorySize(); + return categories.stream() + .map(Category::findCategoryByValue) + .toList(); + } + + private void validCategorySize() { + if (categories.size() > 3) { + throw new ApiException(ErrorType.INVALID_CATEGORIES_SIZE); + } + } +} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedListResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedListResponse.java deleted file mode 100644 index d718b9c2..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedListResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.util.List; - -@Getter -@Builder -@AllArgsConstructor -public class BlockedListResponse { - private List blockedResponses; -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedResponse.java deleted file mode 100644 index 3a52767b..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/BlockedResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -@AllArgsConstructor -public class BlockedResponse { - private Long userId; - private String userNickname; - private String reason; -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java index f42cdcf8..e656258f 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java @@ -1,22 +1,39 @@ package com.api.ttoklip.domain.mypage.main.dto.response; +import com.api.ttoklip.domain.member.domain.Member; +import com.api.ttoklip.domain.question.image.dto.response.ImageResponse; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; @Getter @Builder @AllArgsConstructor public class MyPageResponse { - @Schema(description = "유저의 닉네임") - private String userNickname; @Schema(description = "유저의 동네") - private String userArea; - /* @Schema(description = "유저의 레벨 이미지") - private List imageUrls;*/ - @Schema(description = "유저의 경험치 충족도") - private Long levelExp; - @Schema(description = "유저의 레벨(ex:새싹)") - private String userLevel; + private String street; + @Schema(description = "유저의 닉네임") + private String nickname; + + @Schema(description = "유저의 레벨 이미지") + private String profileImage; + + private final int independentYear; + private final int independentMonth; + + public static MyPageResponse of(final Member member) { + System.out.println("member.getProfile() = " + member.getProfile()); + + return MyPageResponse.builder() + .nickname(member.getNickname()) + .street(member.getStreet()) + .profileImage(member.getProfile().getProfileImgUrl()) + .independentMonth(member.getIndependentMonth()) + .independentYear(member.getIndependentYear()) + .build(); + } } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPostsResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPostsResponse.java deleted file mode 100644 index 970ed847..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPostsResponse.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -public class MyPostsResponse { - //추후 개발 -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateListResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateListResponse.java deleted file mode 100644 index cd839b3a..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateListResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.util.List; - -@Getter -@Builder -@AllArgsConstructor -public class ParticipateListResponse { - private List participateResponses; -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateResponse.java deleted file mode 100644 index e0894cf4..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ParticipateResponse.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -public class ParticipateResponse { -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/RestricetdResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/RestricetdResponse.java deleted file mode 100644 index b09c4398..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/RestricetdResponse.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -@AllArgsConstructor -public class RestricetdResponse { - @Schema(description = "제재기간") - private String time; - private String reason; -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostResponse.java deleted file mode 100644 index b34bc5d7..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -public class ScrapPostResponse { -//추후에 작업 - private String title; - private String contents; - private String userNickname; - private Long likes; - private int countScraps; - private int countComments; - -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostsListResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostsListResponse.java deleted file mode 100644 index 1cf9da38..00000000 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/ScrapPostsListResponse.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.api.ttoklip.domain.mypage.main.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.util.List; -@Getter -@Builder -@AllArgsConstructor -public class ScrapPostsListResponse { - public List scrapPostResponses; -} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPostsListResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/UserSingleResponse.java similarity index 61% rename from src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPostsListResponse.java rename to src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/UserSingleResponse.java index aefdfa96..3b33fd3f 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPostsListResponse.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/UserSingleResponse.java @@ -4,10 +4,8 @@ import lombok.Builder; import lombok.Getter; -import java.util.List; @Getter @Builder @AllArgsConstructor -public class MyPostsListResponse { - private List myPostsResponses; +public class UserSingleResponse { } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java b/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java index ee53ca08..77d12049 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java @@ -1,33 +1,174 @@ package com.api.ttoklip.domain.mypage.main.service; -import com.api.ttoklip.domain.mypage.main.dto.request.BlockedRequest; -import com.api.ttoklip.domain.mypage.main.dto.request.MyPageRequest; +import com.api.ttoklip.domain.common.search.response.*; +import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip; +import com.api.ttoklip.domain.member.domain.Member; +import com.api.ttoklip.domain.member.service.MemberService; +import com.api.ttoklip.domain.mypage.main.domain.MyCommunityRepostiory; +import com.api.ttoklip.domain.mypage.main.domain.MyHoneyTipRepository; +import com.api.ttoklip.domain.mypage.main.domain.MyQuestionRepository; import com.api.ttoklip.domain.mypage.main.dto.response.*; +import com.api.ttoklip.domain.newsletter.post.domain.Newsletter; +import com.api.ttoklip.domain.question.post.domain.Question; +import com.api.ttoklip.domain.town.community.post.entity.Community; import com.api.ttoklip.global.success.Message; import lombok.RequiredArgsConstructor; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.List; + +import static com.api.ttoklip.global.util.SecurityUtil.getCurrentMember; + + @Service @RequiredArgsConstructor public class MyPageService { - public MyPageResponse getMyProfile(){return null;} - public BlockedListResponse blockedUser(){ + + private final MemberService memberService; + private final MyQuestionRepository myQuestionRepository; + private final MyCommunityRepostiory myCommunityRepostiory; + private final MyHoneyTipRepository myHoneyTipRepository; + + + public MyPageResponse getMyProfile() { + Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + MyPageResponse myPageResponse = MyPageResponse.of(currentMember); + return myPageResponse; + } + + public Message blockedUser() { return null; } - public RestricetdResponse restricted(){ + + public Message restricted() { return null; } - public Message unblock(String blockedUserId){ + + public Message unblock(Long targetId) { + /*Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + List blockedUsers = currentMember.getBlockedUsers(); + + for (Iterator iterator = blockedUsers.iterator(); iterator.hasNext(); ) { + Member blockedUser = iterator.next(); + if (blockedUser.getId().equals(targetId)) { + iterator.remove(); + } + }*/ + return Message.activateUser(); + } + + public HoneyTipPaging scrapHoneyTips() { + + /*Page contentPaging = honeyTipSearchRepository.getContain(keyword, pageable); + + // List + List contents = contentPaging.getContent(); + + // Entity -> SingleResponse 반복 + List honeyTipSingleData = contents.stream() + .map(SingleResponse::honeyTipFrom) + .toList(); + + return HoneyTipPaging.builder() + .honeyTips(honeyTipSingleData) + .isFirst(contentPaging.isFirst()) + .isLast(contentPaging.isLast()) + .totalElements(contentPaging.getTotalElements()) + .totalPage(contentPaging.getTotalPages()) + .build(); + + */ return null; } - public ScrapPostsListResponse scrapPosts(){ + public NewsletterPaging scrapNewsletters(final Pageable pageable) { return null; } - public MyPostsListResponse myPosts(){ + public CommunityPaging scrapCommunity() { + + /*Page contentPaging = communitySearchRepository.getContain(keyword, pageable); + + // List + List contents = contentPaging.getContent(); + + // Entity -> SingleResponse 반복 + List communitySingleData = contents.stream() + .map(CommunitySingleResponse::from) + .toList(); + + return CommunityPaging.builder() + .communities(communitySingleData) + .isFirst(contentPaging.isFirst()) + .isLast(contentPaging.isLast()) + .totalElements(contentPaging.getTotalElements()) + .totalPage(contentPaging.getTotalPages()) + .build();*/ return null; } - public ParticipateListResponse participateDeals(){ + + public QuestionPaging myQuestions(final Pageable pageable) { + Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + Page contentPaging = myQuestionRepository.getContain(currentMember.getId(),pageable); + // List + List contents = contentPaging.getContent(); + + // Entity -> SingleResponse 반복 + List<> questionSingleData = contents.stream() + .map() + .toList(); + + return QuestionPaging.builder() + .newsletters(questionSingleData) + .isFirst(contentPaging.isFirst()) + .isLast(contentPaging.isLast()) + .totalElements(contentPaging.getTotalElements()) + .totalPage(contentPaging.getTotalPages()) + .build(); + + } + public CommunityPaging myCommunities(final Pageable pageable) { + Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + Page contentPaging = myCommunityRepostiory.getContain(currentMember.getId(),pageable); + // List + List contents = contentPaging.getContent(); + + // Entity -> SingleResponse 반복 + List communitySingleData = contents.stream() + .map(CommunitySingleResponse :: from) + .toList(); + + return CommunityPaging.builder() + .communities(communitySingleData) + .isFirst(contentPaging.isFirst()) + .isLast(contentPaging.isLast()) + .totalElements(contentPaging.getTotalElements()) + .totalPage(contentPaging.getTotalPages()) + .build(); + } + public HoneyTipPaging myHoneyTips(final Pageable pageable) { + Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + Page contentPaging = myHoneyTipRepository.getContain(currentMember.getId(),pageable); + // List + List contents = contentPaging.getContent(); + + // Entity -> SingleResponse 반복 + List honeyTipSingleData = contents.stream() + .map(SingleResponse :: honeyTipFrom) + .toList(); + + return HoneyTipPaging.builder() + .honeyTips(honeyTipSingleData) + .isFirst(contentPaging.isFirst()) + .isLast(contentPaging.isLast()) + .totalElements(contentPaging.getTotalElements()) + .totalPage(contentPaging.getTotalPages()) + .build(); + } + + public Message participateDeals() { return null; } } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/noti/post/controller/NoticeController.java b/src/main/java/com/api/ttoklip/domain/mypage/noti/post/controller/NoticeController.java index 327e8a89..383a2fe8 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/noti/post/controller/NoticeController.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/noti/post/controller/NoticeController.java @@ -23,7 +23,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -@Tag(name = "공지사항", description = "공지사항 api입니다") +@Tag(name = "Notice", description = "공지사항 api입니다") @RequiredArgsConstructor @RestController @RequestMapping("/api/v1/notice") diff --git a/src/main/java/com/api/ttoklip/domain/mypage/term/controller/TermController.java b/src/main/java/com/api/ttoklip/domain/mypage/term/controller/TermController.java index a0f520a4..00c5e90a 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/term/controller/TermController.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/term/controller/TermController.java @@ -27,7 +27,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -@Tag(name = "이용약관", description = "이용약관 api입니다") +@Tag(name = "Term", description = "이용약관 api입니다") @RequiredArgsConstructor @RestController @RequestMapping("/api/v1/term") diff --git a/src/main/java/com/api/ttoklip/domain/privacy/domain/Profile.java b/src/main/java/com/api/ttoklip/domain/privacy/domain/Profile.java index 1cfcec85..c4f0c70e 100644 --- a/src/main/java/com/api/ttoklip/domain/privacy/domain/Profile.java +++ b/src/main/java/com/api/ttoklip/domain/privacy/domain/Profile.java @@ -44,4 +44,6 @@ public static Profile of(final Member member, final String profileImgUrl) { public void changeProfile(String profileImgUrl) { this.profileImgUrl = profileImgUrl; } + + } \ No newline at end of file diff --git a/src/main/java/com/api/ttoklip/global/success/Message.java b/src/main/java/com/api/ttoklip/global/success/Message.java index 104cc2a5..5ca86238 100644 --- a/src/main/java/com/api/ttoklip/global/success/Message.java +++ b/src/main/java/com/api/ttoklip/global/success/Message.java @@ -79,9 +79,20 @@ public static Message insertPrivacy() { .build(); } + public static Message editProfile() { + return Message.builder() + .message("개인정보를 수정했습니다.") + .build(); + } + public static Message validNickname() { return Message.builder() .message("닉네임 중복 확인에 통과하였습니다.") .build(); } + public static Message activateUser(){ + return Message.builder() + .message("차단해제 하였습니다.") + .build(); + } } From 3bfd298b31aabbdce3789dc7ba5ffc2f3853b07f Mon Sep 17 00:00:00 2001 From: SaeJoon Date: Thu, 15 Feb 2024 17:05:10 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=ED=95=84=EC=9A=94=EC=97=86=EB=8A=94?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/api/ttoklip/domain/member/domain/Member.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/api/ttoklip/domain/member/domain/Member.java b/src/main/java/com/api/ttoklip/domain/member/domain/Member.java index 0b233743..ef87b574 100644 --- a/src/main/java/com/api/ttoklip/domain/member/domain/Member.java +++ b/src/main/java/com/api/ttoklip/domain/member/domain/Member.java @@ -46,7 +46,7 @@ public class Member extends BaseEntity { private String email; // private Long kakaoId; - private String street;//02.14 세준-주소 + //private String street;//02.14 세준-주소 private String provider; private String nickname; @@ -88,14 +88,12 @@ public MemberEditorBuilder toEditor() { return MemberEditor.builder() .independentYear(independentYear) .independentMonth(independentMonth) - .street(street) .nickname(nickname); } public void insertPrivacy(MemberEditor memberEditor) { independentYear = memberEditor.getIndependentYear(); independentMonth = memberEditor.getIndependentMonth(); - street=memberEditor.getStreet(); nickname = memberEditor.getNickname(); } } \ No newline at end of file From 6616695aa85fd0cddf6306e30a38ea88879efdea Mon Sep 17 00:00:00 2001 From: SaeJoon Date: Thu, 15 Feb 2024 18:34:49 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EC=8A=A4=ED=81=AC=EB=9E=A9?= =?UTF-8?q?=ED=95=9C=20=EA=B8=80=20=EB=AA=A9=EB=A1=9D=20=EB=B6=88=EB=9F=AC?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= =?UTF-8?q?=ED=96=88=EC=8A=B5=EB=8B=88=EB=8B=A4=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/controller/MyPageController.java | 18 +++---- .../main/domain/MyCommunityRepostiory.java | 24 ++++++++- .../main/domain/MyHoneyTipRepository.java | 22 ++++++++ .../main/domain/MyNewsLetterRepository.java | 53 +++++++++++++++++++ .../main/dto/response/MyPageResponse.java | 2 +- .../mypage/main/service/MyPageService.java | 50 ++++++++++++----- src/main/resources/application.yml | 2 +- 7 files changed, 145 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java index 7e6560df..cab0fdb9 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java @@ -126,8 +126,8 @@ public SuccessResponse unblock(@PathVariable Long targetId) { description = "스크랩한 허니팁들을 불러왔습니다" )))}) @GetMapping("/scraped-posts/honeytip") - public SuccessResponse scrapHoneyTips() { - return new SuccessResponse<>(myPageService.scrapHoneyTips()); + public SuccessResponse scrapHoneyTips(final Pageable pageable) { + return new SuccessResponse<>(myPageService.scrapHoneyTips(pageable)); } @Operation(summary = "스크랩한 글 목록", description = "스크랩한 글 목록 불러오기") @ApiResponses(value = { @@ -141,8 +141,8 @@ public SuccessResponse scrapHoneyTips() { description = "스크랩한 뉴스레터들을 불러왔습니다" )))}) @GetMapping("/scraped-posts/newsletter") - public SuccessResponse scrapNewsletters() { - return new SuccessResponse<>(myPageService.scrapNewsletters()); + public SuccessResponse scrapNewsletters(final Pageable pageable) { + return new SuccessResponse<>(myPageService.scrapNewsletters(pageable)); } @Operation(summary = "스크랩한 글 목록", description = "스크랩한 글 목록 불러오기") @ApiResponses(value = { @@ -156,8 +156,8 @@ public SuccessResponse scrapNewsletters() { description = "스크랩한 소통해요들을 불러왔습니다" )))}) @GetMapping("/scraped-posts/community") - public SuccessResponse scrapCommunity() { - return new SuccessResponse<>(myPageService.scrapCommunity()); + public SuccessResponse scrapCommunity(final Pageable pageable) { + return new SuccessResponse<>(myPageService.scrapCommunity(pageable)); } @Operation(summary = "내가 작성한 글 목록", description = "내가 작성한 글 목록 불러오기") @ApiResponses(value = { @@ -171,7 +171,7 @@ public SuccessResponse scrapCommunity() { description = "내가 작성한 글들을 불러왔습니다" )))}) @GetMapping("/honeytip") - public SuccessResponse myHoneyTip(final Pageable pageable) { + public SuccessResponse myHoneyTip(final Pageable pageable) { return new SuccessResponse<>(myPageService.myHoneyTips(pageable)); } @Operation(summary = "내가 작성한 글 목록", description = "내가 작성한 글 목록 불러오기") @@ -201,8 +201,8 @@ public SuccessResponse myQuestion(final Pageable pageable) { description = "내가 작성한 글들을 불러왔습니다" )))}) @GetMapping("/community") - public SuccessResponse myCommunity() { - return new SuccessResponse<>(myPageService.myCommunities()); + public SuccessResponse myCommunity(final Pageable pageable) { + return new SuccessResponse<>(myPageService.myCommunities(pageable)); } @Operation(summary = "내가 참여한 거래 목록", description = "내가 참여한 거래 목록 불러오기") @ApiResponses(value = { diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java index 64c02757..87005b22 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java @@ -1,8 +1,10 @@ package com.api.ttoklip.domain.mypage.main.domain; +import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip; import com.api.ttoklip.domain.town.community.comment.QCommunityComment; import com.api.ttoklip.domain.town.community.post.entity.Community; import com.api.ttoklip.domain.town.community.post.entity.QCommunity; +import com.api.ttoklip.domain.town.community.scrap.entity.QCommunityScrap; import com.querydsl.core.types.dsl.Wildcard; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; @@ -19,7 +21,7 @@ public class MyCommunityRepostiory { private final JPAQueryFactory jpaQueryFactory; private final QCommunity community = QCommunity.community; private final QCommunityComment communityComment = QCommunityComment.communityComment; - + private final QCommunityScrap communityScrap = QCommunityScrap.communityScrap; public Page getContain(final Long userId, final Pageable pageable) { List content = getSearchPageId(userId ,pageable); Long count = countQuery(); @@ -48,4 +50,24 @@ private Long countQuery() { .distinct() .fetchOne(); } + + public Page getScrapContain(final Long userId, final Pageable pageable){ + List content = getSearchScrapPageId(userId,pageable); + Long count = countQuery(); + return new PageImpl<>(content, pageable, count); + } + private List getSearchScrapPageId(final Long userId, final Pageable pageable) { + return jpaQueryFactory + .select(community) + .from(community) + .innerJoin(communityScrap).on(community.id.eq(communityScrap.community.id)) + .where(communityScrap.member.id.eq(userId)) + .distinct() + .leftJoin(community.communityComments, communityComment) + .fetchJoin() + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) + .orderBy(community.id.desc()) + .fetch(); + } } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java index ae3ace07..0069a666 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java @@ -1,5 +1,6 @@ package com.api.ttoklip.domain.mypage.main.domain; +import com.api.ttoklip.domain.honeytip.Scrap.domain.QHoneyTipScrap; import com.api.ttoklip.domain.honeytip.comment.domain.QHoneyTipComment; import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip; import com.api.ttoklip.domain.honeytip.post.domain.QHoneyTip; @@ -20,6 +21,7 @@ public class MyHoneyTipRepository { private final JPAQueryFactory jpaQueryFactory; private final QHoneyTip honeyTip = QHoneyTip.honeyTip; private final QHoneyTipComment honeyTipComment = QHoneyTipComment.honeyTipComment; + private final QHoneyTipScrap honeyTipScrap = QHoneyTipScrap.honeyTipScrap; public Page getContain(final Long userId, final Pageable pageable){ List content = getSearchPageId(userId,pageable); @@ -46,4 +48,24 @@ private Long countQuery() { .distinct() .fetchOne(); } + + public Page getScrapContain(final Long userId, final Pageable pageable){ + List content = getSearchScrapPageId(userId,pageable); + Long count = countQuery(); + return new PageImpl<>(content, pageable, count); + } + private List getSearchScrapPageId(final Long userId, final Pageable pageable) { + return jpaQueryFactory + .select(honeyTip) + .from(honeyTip) + .innerJoin(honeyTipScrap).on(honeyTip.id.eq(honeyTipScrap.honeyTip.id)) + .where(honeyTipScrap.member.id.eq(userId)) + .distinct() + .leftJoin(honeyTip.honeyTipComments, honeyTipComment) + .fetchJoin() + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) + .orderBy(honeyTip.id.desc()) + .fetch(); + } } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java new file mode 100644 index 00000000..eec5741e --- /dev/null +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java @@ -0,0 +1,53 @@ +package com.api.ttoklip.domain.mypage.main.domain; + +import com.api.ttoklip.domain.newsletter.comment.domain.QNewsletterComment; +import com.api.ttoklip.domain.newsletter.post.domain.Newsletter; +import com.api.ttoklip.domain.newsletter.post.domain.QNewsletter; +import com.api.ttoklip.domain.newsletter.scarp.entity.QNewsletterScrap; +import com.api.ttoklip.domain.town.community.post.entity.Community; +import com.querydsl.core.types.dsl.Wildcard; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class MyNewsLetterRepository { + private final JPAQueryFactory jpaQueryFactory; + private final QNewsletter newsletter = QNewsletter.newsletter; + private final QNewsletterComment newsletterComment = QNewsletterComment.newsletterComment; + private final QNewsletterScrap newsletterScrap = QNewsletterScrap.newsletterScrap; + public Page getScrapContain(final Long userId, final Pageable pageable){ + List content = getSearchScrapPageId(userId,pageable); + Long count = countQuery(); + return new PageImpl<>(content, pageable, count); + } + private List getSearchScrapPageId(final Long userId, final Pageable pageable) { + return jpaQueryFactory + .select(newsletter) + .from(newsletter) + .innerJoin(newsletterScrap).on(newsletter.id.eq(newsletterScrap.newsletter.id)) + .where(newsletterScrap.member.id.eq(userId)) + .distinct() + .leftJoin(newsletter.newsletterComments, newsletterComment) + .fetchJoin() + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) + .orderBy(newsletter.id.desc()) + .fetch(); + } + + private Long countQuery() { + return jpaQueryFactory + .select(Wildcard.count) + .from(newsletter) + .distinct() + .fetchOne(); + } + +} diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java index e656258f..16366de2 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/dto/response/MyPageResponse.java @@ -30,7 +30,7 @@ public static MyPageResponse of(final Member member) { return MyPageResponse.builder() .nickname(member.getNickname()) - .street(member.getStreet()) + //.street(member.getStreet()) .profileImage(member.getProfile().getProfileImgUrl()) .independentMonth(member.getIndependentMonth()) .independentYear(member.getIndependentYear()) diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java b/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java index 77d12049..2c455cd6 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java @@ -7,6 +7,7 @@ import com.api.ttoklip.domain.member.service.MemberService; import com.api.ttoklip.domain.mypage.main.domain.MyCommunityRepostiory; import com.api.ttoklip.domain.mypage.main.domain.MyHoneyTipRepository; +import com.api.ttoklip.domain.mypage.main.domain.MyNewsLetterRepository; import com.api.ttoklip.domain.mypage.main.domain.MyQuestionRepository; import com.api.ttoklip.domain.mypage.main.dto.response.*; import com.api.ttoklip.domain.newsletter.post.domain.Newsletter; @@ -32,6 +33,7 @@ public class MyPageService { private final MyQuestionRepository myQuestionRepository; private final MyCommunityRepostiory myCommunityRepostiory; private final MyHoneyTipRepository myHoneyTipRepository; + private final MyNewsLetterRepository myNewsLetterRepository; public MyPageResponse getMyProfile() { @@ -61,9 +63,10 @@ public Message unblock(Long targetId) { return Message.activateUser(); } - public HoneyTipPaging scrapHoneyTips() { + public HoneyTipPaging scrapHoneyTips(final Pageable pageable) { - /*Page contentPaging = honeyTipSearchRepository.getContain(keyword, pageable); + Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + Page contentPaging = myHoneyTipRepository.getScrapContain(currentMember.getId(), pageable); // List List contents = contentPaging.getContent(); @@ -81,16 +84,31 @@ public HoneyTipPaging scrapHoneyTips() { .totalPage(contentPaging.getTotalPages()) .build(); - */ - return null; } + public NewsletterPaging scrapNewsletters(final Pageable pageable) { - return null; + Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + Page contentPaging = myNewsLetterRepository.getScrapContain(currentMember.getId(), pageable); + // List + List contents = contentPaging.getContent(); + + // Entity -> SingleResponse 반복 + List newsletterSingleData = contents.stream() + .map(SingleResponse::newsletterFrom) + .toList(); + return NewsletterPaging.builder() + .newsletters(newsletterSingleData) + .isFirst(contentPaging.isFirst()) + .isLast(contentPaging.isLast()) + .totalElements(contentPaging.getTotalElements()) + .totalPage(contentPaging.getTotalPages()) + .build(); } - public CommunityPaging scrapCommunity() { - /*Page contentPaging = communitySearchRepository.getContain(keyword, pageable); + public CommunityPaging scrapCommunity(final Pageable pageable) { + Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); + Page contentPaging = myCommunityRepostiory.getScrapContain(currentMember.getId(), pageable); // List List contents = contentPaging.getContent(); @@ -105,11 +123,10 @@ public CommunityPaging scrapCommunity() { .isLast(contentPaging.isLast()) .totalElements(contentPaging.getTotalElements()) .totalPage(contentPaging.getTotalPages()) - .build();*/ - return null; + .build(); } - public QuestionPaging myQuestions(final Pageable pageable) { + /*public QuestionPaging myQuestions(final Pageable pageable) { Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); Page contentPaging = myQuestionRepository.getContain(currentMember.getId(),pageable); // List @@ -128,16 +145,20 @@ public QuestionPaging myQuestions(final Pageable pageable) { .totalPage(contentPaging.getTotalPages()) .build(); + }*/ + public Message myQuestions(final Pageable pageable) { + return null; } + public CommunityPaging myCommunities(final Pageable pageable) { Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); - Page contentPaging = myCommunityRepostiory.getContain(currentMember.getId(),pageable); + Page contentPaging = myCommunityRepostiory.getContain(currentMember.getId(), pageable); // List List contents = contentPaging.getContent(); // Entity -> SingleResponse 반복 List communitySingleData = contents.stream() - .map(CommunitySingleResponse :: from) + .map(CommunitySingleResponse::from) .toList(); return CommunityPaging.builder() @@ -148,15 +169,16 @@ public CommunityPaging myCommunities(final Pageable pageable) { .totalPage(contentPaging.getTotalPages()) .build(); } + public HoneyTipPaging myHoneyTips(final Pageable pageable) { Member currentMember = memberService.findByIdWithProfile(getCurrentMember().getId()); - Page contentPaging = myHoneyTipRepository.getContain(currentMember.getId(),pageable); + Page contentPaging = myHoneyTipRepository.getContain(currentMember.getId(), pageable); // List List contents = contentPaging.getContent(); // Entity -> SingleResponse 반복 List honeyTipSingleData = contents.stream() - .map(SingleResponse :: honeyTipFrom) + .map(SingleResponse::honeyTipFrom) .toList(); return HoneyTipPaging.builder() diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6d36bf1d..8c5a2a7d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -22,7 +22,7 @@ spring: jpa: hibernate: - ddl-auto: validate # 바꾸지 말아주세요! + ddl-auto: update # 바꾸지 말아주세요! properties: hibernate: dialect: org.hibernate.dialect.MySQL8Dialect From 416d6c8517fea68926b34a02ab45c2d29fb38bbd Mon Sep 17 00:00:00 2001 From: SaeJoon Date: Thu, 15 Feb 2024 18:35:58 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20uri?= =?UTF-8?q?=EB=A7=8C=20=EB=B3=80=EA=B2=BD=ED=95=98=EC=98=80=EC=8A=B5?= =?UTF-8?q?=EB=8B=88=EB=8B=A4=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mypage/main/controller/MyPageController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java index cab0fdb9..649d9c22 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java @@ -125,7 +125,7 @@ public SuccessResponse unblock(@PathVariable Long targetId) { value = MyPageConstant.scrapHoneyTipsResponse, description = "스크랩한 허니팁들을 불러왔습니다" )))}) - @GetMapping("/scraped-posts/honeytip") + @GetMapping("/scrap-post/honeytip") public SuccessResponse scrapHoneyTips(final Pageable pageable) { return new SuccessResponse<>(myPageService.scrapHoneyTips(pageable)); } @@ -140,7 +140,7 @@ public SuccessResponse scrapHoneyTips(final Pageable pageable) { value = MyPageConstant.scrapNewsLetterResponse, description = "스크랩한 뉴스레터들을 불러왔습니다" )))}) - @GetMapping("/scraped-posts/newsletter") + @GetMapping("/scrap-post/newsletter") public SuccessResponse scrapNewsletters(final Pageable pageable) { return new SuccessResponse<>(myPageService.scrapNewsletters(pageable)); } @@ -155,7 +155,7 @@ public SuccessResponse scrapNewsletters(final Pageable pageabl value = MyPageConstant.scrapCommunityResponse, description = "스크랩한 소통해요들을 불러왔습니다" )))}) - @GetMapping("/scraped-posts/community") + @GetMapping("/scrap-post/community") public SuccessResponse scrapCommunity(final Pageable pageable) { return new SuccessResponse<>(myPageService.scrapCommunity(pageable)); } From dd66729466abcaf5bd16e745152489de2ea0797b Mon Sep 17 00:00:00 2001 From: SaeJoon Date: Thu, 15 Feb 2024 20:39:36 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=ED=95=9C=EA=B8=80=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=EC=9D=B4=EB=A6=84=EC=9D=84=20=EC=98=81=EC=96=B4?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=98=EC=98=80=EC=8A=B5?= =?UTF-8?q?=EB=8B=88=EB=8B=A4.=20static=20import=EB=A5=BC=20=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=EA=B5=AC=ED=98=84=ED=96=88=EC=8A=B5=EB=8B=88?= =?UTF-8?q?=EB=8B=A4=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/controller/MyPageController.java | 10 +++------ .../main/domain/MyCommunityRepostiory.java | 16 +++++++------- .../main/domain/MyHoneyTipRepository.java | 21 ++++++++++--------- .../main/domain/MyNewsLetterRepository.java | 18 +++++++--------- .../main/domain/MyQuestionRepository.java | 10 ++++----- .../mypage/main/service/MyPageService.java | 3 +-- 6 files changed, 34 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java index 649d9c22..0e025a29 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/controller/MyPageController.java @@ -1,15 +1,11 @@ package com.api.ttoklip.domain.mypage.main.controller; -import com.api.ttoklip.domain.common.search.response.CommunityPaging; -import com.api.ttoklip.domain.common.search.response.HoneyTipPaging; -import com.api.ttoklip.domain.common.search.response.NewsletterPaging; +import com.api.ttoklip.domain.search.response.CommunityPaging; +import com.api.ttoklip.domain.search.response.HoneyTipPaging; +import com.api.ttoklip.domain.search.response.NewsletterPaging; import com.api.ttoklip.domain.mypage.main.constant.MyPageConstant; -import com.api.ttoklip.domain.mypage.main.dto.request.BlockedRequest; -import com.api.ttoklip.domain.mypage.main.dto.request.MyPageRequest; -import com.api.ttoklip.domain.mypage.main.dto.request.ProfileEditRequest; import com.api.ttoklip.domain.mypage.main.dto.response.*; import com.api.ttoklip.domain.mypage.main.service.MyPageService; -import com.api.ttoklip.domain.privacy.constant.PrivacyConstant; import com.api.ttoklip.domain.privacy.dto.PrivacyCreateRequest; import com.api.ttoklip.domain.privacy.service.ProfileService; import com.api.ttoklip.global.success.Message; diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java index 87005b22..64dfe402 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyCommunityRepostiory.java @@ -1,10 +1,7 @@ package com.api.ttoklip.domain.mypage.main.domain; import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip; -import com.api.ttoklip.domain.town.community.comment.QCommunityComment; import com.api.ttoklip.domain.town.community.post.entity.Community; -import com.api.ttoklip.domain.town.community.post.entity.QCommunity; -import com.api.ttoklip.domain.town.community.scrap.entity.QCommunityScrap; import com.querydsl.core.types.dsl.Wildcard; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; @@ -15,13 +12,15 @@ import java.util.List; +import static com.api.ttoklip.domain.town.community.comment.QCommunityComment.communityComment; +import static com.api.ttoklip.domain.town.community.post.entity.QCommunity.*; +import static com.api.ttoklip.domain.town.community.scrap.entity.QCommunityScrap.communityScrap; + @Repository @RequiredArgsConstructor public class MyCommunityRepostiory { private final JPAQueryFactory jpaQueryFactory; - private final QCommunity community = QCommunity.community; - private final QCommunityComment communityComment = QCommunityComment.communityComment; - private final QCommunityScrap communityScrap = QCommunityScrap.communityScrap; + public Page getContain(final Long userId, final Pageable pageable) { List content = getSearchPageId(userId ,pageable); Long count = countQuery(); @@ -58,9 +57,8 @@ public Page getScrapContain(final Long userId, final Pageable pageabl } private List getSearchScrapPageId(final Long userId, final Pageable pageable) { return jpaQueryFactory - .select(community) - .from(community) - .innerJoin(communityScrap).on(community.id.eq(communityScrap.community.id)) + .selectFrom(community) + .leftJoin(community.communityScraps, communityScrap) .where(communityScrap.member.id.eq(userId)) .distinct() .leftJoin(community.communityComments, communityComment) diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java index 0069a666..4d5bab2b 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyHoneyTipRepository.java @@ -1,9 +1,7 @@ package com.api.ttoklip.domain.mypage.main.domain; -import com.api.ttoklip.domain.honeytip.Scrap.domain.QHoneyTipScrap; -import com.api.ttoklip.domain.honeytip.comment.domain.QHoneyTipComment; + import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip; -import com.api.ttoklip.domain.honeytip.post.domain.QHoneyTip; import com.querydsl.core.types.dsl.Wildcard; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -15,13 +13,15 @@ import java.util.List; +import static com.api.ttoklip.domain.honeytip.comment.domain.QHoneyTipComment.honeyTipComment; +import static com.api.ttoklip.domain.honeytip.post.domain.QHoneyTip.*; +import static com.api.ttoklip.domain.honeytip.scrap.domain.QHoneyTipScrap.honeyTipScrap; + + @Repository @RequiredArgsConstructor public class MyHoneyTipRepository { private final JPAQueryFactory jpaQueryFactory; - private final QHoneyTip honeyTip = QHoneyTip.honeyTip; - private final QHoneyTipComment honeyTipComment = QHoneyTipComment.honeyTipComment; - private final QHoneyTipScrap honeyTipScrap = QHoneyTipScrap.honeyTipScrap; public Page getContain(final Long userId, final Pageable pageable){ List content = getSearchPageId(userId,pageable); @@ -55,10 +55,10 @@ public Page getScrapContain(final Long userId, final Pageable pageable return new PageImpl<>(content, pageable, count); } private List getSearchScrapPageId(final Long userId, final Pageable pageable) { - return jpaQueryFactory - .select(honeyTip) - .from(honeyTip) - .innerJoin(honeyTipScrap).on(honeyTip.id.eq(honeyTipScrap.honeyTip.id)) + return jpaQueryFactory + .selectFrom(honeyTip) + .leftJoin(honeyTip.honeyTipScraps, honeyTipScrap) +//// .leftJoin(honeyTip.honeyTipScraps, QHoneyTipScrap.honeyTipScrap) .where(honeyTipScrap.member.id.eq(userId)) .distinct() .leftJoin(honeyTip.honeyTipComments, honeyTipComment) @@ -67,5 +67,6 @@ private List getSearchScrapPageId(final Long userId, final Pageable pa .offset(pageable.getOffset()) .orderBy(honeyTip.id.desc()) .fetch(); + } } diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java index eec5741e..f42d36c0 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyNewsLetterRepository.java @@ -1,10 +1,8 @@ package com.api.ttoklip.domain.mypage.main.domain; -import com.api.ttoklip.domain.newsletter.comment.domain.QNewsletterComment; + import com.api.ttoklip.domain.newsletter.post.domain.Newsletter; -import com.api.ttoklip.domain.newsletter.post.domain.QNewsletter; -import com.api.ttoklip.domain.newsletter.scarp.entity.QNewsletterScrap; -import com.api.ttoklip.domain.town.community.post.entity.Community; + import com.querydsl.core.types.dsl.Wildcard; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; @@ -15,13 +13,14 @@ import java.util.List; +import static com.api.ttoklip.domain.newsletter.comment.domain.QNewsletterComment.newsletterComment; +import static com.api.ttoklip.domain.newsletter.post.domain.QNewsletter.newsletter; +import static com.api.ttoklip.domain.newsletter.scarp.entity.QNewsletterScrap.newsletterScrap; + @Repository @RequiredArgsConstructor public class MyNewsLetterRepository { private final JPAQueryFactory jpaQueryFactory; - private final QNewsletter newsletter = QNewsletter.newsletter; - private final QNewsletterComment newsletterComment = QNewsletterComment.newsletterComment; - private final QNewsletterScrap newsletterScrap = QNewsletterScrap.newsletterScrap; public Page getScrapContain(final Long userId, final Pageable pageable){ List content = getSearchScrapPageId(userId,pageable); Long count = countQuery(); @@ -29,9 +28,8 @@ public Page getScrapContain(final Long userId, final Pageable pageab } private List getSearchScrapPageId(final Long userId, final Pageable pageable) { return jpaQueryFactory - .select(newsletter) - .from(newsletter) - .innerJoin(newsletterScrap).on(newsletter.id.eq(newsletterScrap.newsletter.id)) + .selectFrom(newsletter) + .leftJoin(newsletter.newsletterScraps, newsletterScrap) .where(newsletterScrap.member.id.eq(userId)) .distinct() .leftJoin(newsletter.newsletterComments, newsletterComment) diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java index 8b53d9f4..bcdab1c4 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/domain/MyQuestionRepository.java @@ -1,8 +1,6 @@ package com.api.ttoklip.domain.mypage.main.domain; -import com.api.ttoklip.domain.question.comment.domain.QQuestionComment; -import com.api.ttoklip.domain.question.post.domain.QQuestion; import com.api.ttoklip.domain.question.post.domain.Question; import com.querydsl.core.types.dsl.Wildcard; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -14,12 +12,13 @@ import java.util.List; +import static com.api.ttoklip.domain.question.comment.domain.QQuestionComment.questionComment; +import static com.api.ttoklip.domain.question.post.domain.QQuestion.question; + @Repository @RequiredArgsConstructor public class MyQuestionRepository { private final JPAQueryFactory jpaQueryFactory; - private final QQuestion question = QQuestion.question; - private final QQuestionComment questionComment = QQuestionComment.questionComment; public Page getContain(final Long userId,final Pageable pageable){ List content = getSearchPageId(userId,pageable); @@ -28,8 +27,7 @@ public Page getContain(final Long userId,final Pageable pageable){ } private List getSearchPageId(final Long userId, final Pageable pageable) { return jpaQueryFactory - .select(question) - .from(question) + .selectFrom(question) .where(question.member.id.eq(userId)) .distinct() .leftJoin(question.questionComments, questionComment) diff --git a/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java b/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java index 2c455cd6..9678b028 100644 --- a/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java +++ b/src/main/java/com/api/ttoklip/domain/mypage/main/service/MyPageService.java @@ -1,7 +1,7 @@ package com.api.ttoklip.domain.mypage.main.service; -import com.api.ttoklip.domain.common.search.response.*; +import com.api.ttoklip.domain.search.response.*; import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip; import com.api.ttoklip.domain.member.domain.Member; import com.api.ttoklip.domain.member.service.MemberService; @@ -11,7 +11,6 @@ import com.api.ttoklip.domain.mypage.main.domain.MyQuestionRepository; import com.api.ttoklip.domain.mypage.main.dto.response.*; import com.api.ttoklip.domain.newsletter.post.domain.Newsletter; -import com.api.ttoklip.domain.question.post.domain.Question; import com.api.ttoklip.domain.town.community.post.entity.Community; import com.api.ttoklip.global.success.Message; import lombok.RequiredArgsConstructor; From 17754a1cd6bb1c605e79cd651666308bfdc54820 Mon Sep 17 00:00:00 2001 From: SaeJoon Date: Thu, 15 Feb 2024 20:41:20 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix:yml=EB=B3=80=EA=B2=BD(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8c5a2a7d..6d36bf1d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -22,7 +22,7 @@ spring: jpa: hibernate: - ddl-auto: update # 바꾸지 말아주세요! + ddl-auto: validate # 바꾸지 말아주세요! properties: hibernate: dialect: org.hibernate.dialect.MySQL8Dialect