Skip to content

Commit

Permalink
[#83] Refactor : MyPage를 User로 리팩토링 한다
Browse files Browse the repository at this point in the history
  • Loading branch information
packdev937 committed Jan 16, 2024
1 parent 70b8c31 commit db420ce
Show file tree
Hide file tree
Showing 21 changed files with 187 additions and 405 deletions.

This file was deleted.

78 changes: 0 additions & 78 deletions src/main/java/ssu/eatssu/domain/page/service/MyPageService.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import ssu.eatssu.domain.report.entity.ReviewReportType;
import ssu.eatssu.domain.report.entity.ReportType;

@Schema(title = "리뷰 신고하기")
@NoArgsConstructor
@Getter
public class ReviewReportCreate {
public class CreateReportRequest {

@Schema(description = "신고할 리뷰 id", example = "4")
private Long reviewId;

@Schema(description = "신고 타입", example = "BAD_WORD")
private ReviewReportType reportType;
private ReportType reportType;

@Schema(description = "신고 내용", example = "음란성, 욕설 등 부적절한 내용")
private String content;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ssu.eatssu.domain.slack.entity;

import org.springframework.stereotype.Component;
import ssu.eatssu.domain.inquiry.entity.Inquiry;
import ssu.eatssu.domain.review.entity.Review;
import ssu.eatssu.domain.review.entity.ReviewReport;
import ssu.eatssu.domain.review.entity.Report;
import ssu.eatssu.domain.user.entity.User;
import ssu.eatssu.domain.user.entity.UserInquiry;

import java.text.MessageFormat;

Expand All @@ -13,7 +13,7 @@ public class SlackMessageFormat {

private SlackMessageFormat(){}

public static String sendReport(ReviewReport report) {
public static String sendReport(Report report) {
User reporter = report.getUser();
Review review = report.getReview();
MessageFormat messageFormat = new MessageFormat(
Expand Down Expand Up @@ -41,7 +41,7 @@ public static String sendReport(ReviewReport report) {
return messageFormat.format(args);
}

public static String sendUserInquiry(UserInquiry inquiry) {
public static String sendUserInquiry(Inquiry inquiry) {
MessageFormat messageFormat = new MessageFormat(
"""
===================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ssu.eatssu.domain.slack.entity;
package ssu.eatssu.domain.slack.service;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
Expand All @@ -9,6 +9,7 @@
import org.springframework.stereotype.Service;

import java.io.IOException;
import ssu.eatssu.domain.slack.entity.SlackChannel;

@Slf4j
@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@AllArgsConstructor
@Builder
@Getter
public class SliceDto<D> {
public class SliceResponse<D> {
@Schema(description = "현재 넘겨준 페이지에 넘어간 개수(마지막 페이지일시, size 보다 작을 수 있음)", example = "20")
private int numberOfElements;

Expand Down
53 changes: 53 additions & 0 deletions src/main/java/ssu/eatssu/domain/slice/service/SliceService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package ssu.eatssu.domain.slice.service;

import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_USER;

import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Service;
import ssu.eatssu.domain.auth.entity.CustomUserDetails;
import ssu.eatssu.domain.user.dto.MyReviewDetail;
import ssu.eatssu.domain.review.entity.Review;
import ssu.eatssu.domain.review.repository.ReviewRepository;
import ssu.eatssu.domain.slice.dto.SliceResponse;
import ssu.eatssu.domain.user.entity.User;
import ssu.eatssu.domain.user.repository.UserRepository;
import ssu.eatssu.global.handler.response.BaseException;

@Service
@RequiredArgsConstructor
public class SliceService {

private final UserRepository userRepository;
private final ReviewRepository reviewRepository;

public SliceResponse<MyReviewDetail> findMyReviews(
CustomUserDetails userDetails,
Pageable pageable,
Long lastReviewId) {

User user = userRepository.findById(userDetails.getId())
.orElseThrow(() -> new BaseException(NOT_FOUND_USER));

Slice<Review> sliceReviews = reviewRepository.findByUserOrderByIdDesc(user, lastReviewId,
pageable);

return convertToMyReviewDetail(sliceReviews);
}

private SliceResponse<MyReviewDetail> convertToMyReviewDetail(Slice<Review> sliceReviews) {
List<MyReviewDetail> myReviewDetails = sliceReviews.getContent().stream()
.map(MyReviewDetail::from)
.collect(Collectors.toList());

return SliceResponse.<MyReviewDetail>builder()
.numberOfElements(sliceReviews.getNumberOfElements())
.hasNext(sliceReviews.hasNext())
.dataList(myReviewDetails)
.build();
}
}

25 changes: 0 additions & 25 deletions src/main/java/ssu/eatssu/domain/user/dto/Join.java

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/java/ssu/eatssu/domain/user/dto/Login.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package ssu.eatssu.domain.page.dto;
package ssu.eatssu.domain.user.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import ssu.eatssu.domain.user.entity.OauthProvider;
import ssu.eatssu.domain.auth.entity.OauthProvider;

@AllArgsConstructor
@Builder
@Schema(title = "마이페이지 정보")
@Getter
public class MypageInfo {
public class MyPageResponse {
@Schema(description = "닉네임", example = "피치푸치")
private String nickname;

@Schema(description = "연결 계정 정보", example = "피치푸치")
private OauthProvider accountFrom;
private OauthProvider provider;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ssu.eatssu.domain.page.dto;
package ssu.eatssu.domain.user.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/ssu/eatssu/domain/user/dto/NicknameEdit.java

This file was deleted.

Loading

0 comments on commit db420ce

Please sign in to comment.