Skip to content

Commit

Permalink
Merge pull request #121 from AndLetgo/develop
Browse files Browse the repository at this point in the history
🚀 [DEPLOY]: 추가 수정사항 반영 - 유저레벨, 정지, 신고
  • Loading branch information
phonil authored May 4, 2024
2 parents ffdc10c + 34f4e95 commit bc3cfec
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static List<ReplyResponseDto.ReplyRes> toReplyResList(List<Reply> replies
.userId(user.getId())
.nickname(user.getNickname())
.profileImgUrl(user.getProfileImg())
.userLevel(user.getUserLevel())
.build();

ReplyResponseDto.ReplyRes replyRes = ReplyResponseDto.ReplyRes.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ public static class ReplyRes {
private String contents;

// 수정 없으므로 생성 시간
@Schema(type = "LocalDateTime", example = "2023-12-22 23:51:45.848882", description = "알림이 생성된 DateTime을 출력합니다.")
private LocalDateTime createdDate;

// 필요한 User의 요소가 여기 다 있음
@Schema(type = "SearchUsersRes", example = "user 정보", description = "필요한 user의 정보가 들어있습니다.")
private UserResponseDto.SearchUsersRes user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ResponseEntity<?> report(UserPrincipal userPrincipal, ReportRequestDto.Re
User user = userService.validateUserByToken(userPrincipal);
Long id = reportReq.getReportedId();
ReportType reportType = reportReq.getReportType();

validateReportOnce(user.getId(), reportReq);
validate(reportType, id);
Report report = ReportConverter.toReport(user, id, reportType);
reportRepository.save(report);
Expand Down Expand Up @@ -157,4 +157,9 @@ public Report validateReportById(Long reportId) {
return report.get();
}

// TODO: 같은 사용자가 같은 신고 여러 번 하면 한 번으로 처리
public void validateReportOnce(Long userId, ReportRequestDto.ReportReq dto) {
Optional<Report> report = reportRepository.findByUserIdAndReportTypeAndReportedId(userId, dto.getReportType(), dto.getReportedId());
DefaultAssert.isTrue(report.isEmpty(), "이미 신고하였습니다.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface ReportRepository extends JpaRepository<Report, Long>, ReportQuerydslRepository {
Expand All @@ -18,4 +19,6 @@ public interface ReportRepository extends JpaRepository<Report, Long>, ReportQue
Slice<Report> findSliceBy(Pageable pageable);

List<Report> findByReportedIdAndReportType(Long reportedId, ReportType reportType);

Optional<Report> findByUserIdAndReportTypeAndReportedId(Long userId, ReportType reportType, Long reportedId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ReportController {
private final ReportService reportService;

// Description : 신고
@Operation(summary = "감상평, 댓글 혹은 포스터 등록 알림 신고", description = "감상평, 댓글 혹은 포스터 등록 알림 신고입니다.")
@Operation(summary = "감상평, 댓글 혹은 전시회 신고", description = "감상평, 댓글 혹은 포스터 등록 알림 신고입니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "신고 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = Message.class))}),
@ApiResponse(responseCode = "400", description = "신고 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static List<ReviewResponseDto.ReviewListRes> toReviewListRes(List<Review>
.contents(review.getContents())
.numReply(review.getNumReply())
.createdDate(review.getCreatedDate())
.userLevel(user.getUserLevel())
.build();
reviewListRes.add(reviewRes);
}
Expand Down Expand Up @@ -87,6 +88,7 @@ public static ReviewResponseDto.ReviewListRes toReviewListRes(Review review, Use
.rate(rate)
.numReply(review.getNumReply())
.createdDate(review.getCreatedDate())
.userLevel(userRes.getUserLevel())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package depth.jeonsilog.domain.review.dto;

import depth.jeonsilog.domain.exhibition.dto.ExhibitionResponseDto;
import depth.jeonsilog.domain.user.domain.UserLevel;
import depth.jeonsilog.domain.user.dto.UserResponseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
Expand Down Expand Up @@ -38,6 +39,9 @@ public static class ReviewListRes {

@Schema(type = "LocalDateTime", example = "2023-12-22 23:51:45.848882", description = " 감상평이 작성된 날짜/시간을 출력합니다.")
private LocalDateTime createdDate;

@Schema(type = "UserLevel", example = "BEGINNER", description = "유저의 레벨을 출력합니다. NON(0), DONE(1 ~ 2), BEGINNER(3 ~ 9), INTERMEDIATE(10 ~ 19), ADVANCED(20 ~ 29), MASTER(30 ~)")
private UserLevel userLevel;
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public ResponseEntity<?> findUserIsStop(final UserPrincipal userPrincipal) {
StopResponseDto.StopUserRes dto = StopResponseDto.StopUserRes.builder()
.reason(stop.get().getReason())
.remainingDays(between)
.isFirstAccess(stop.get().getIsFirstAccess())
.build();

ApiResponse apiResponse = ApiResponse.toApiResponse(dto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ public static class StopUserRes {

@Schema(type = "Integer", example = "6", description = "남은 정지 일수를 출력합니다..")
private Integer remainingDays;

@Schema(type = "Boolean", example = "true", description = "최초 접속 여부를 출력합니다.")
private Boolean isFirstAccess;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static UserResponseDto.UserRes toUserRes(User user, FollowRepository foll
.profileImgUrl(user.getProfileImg())
.numFollowing(followRepository.countByUser(user))
.numFollower(followRepository.countByFollow(user))
.reviewCount(user.getReviews().size())
.userLevel(user.getUserLevel())
.build();
}

Expand All @@ -36,6 +38,7 @@ public static List<UserResponseDto.SearchUsersRes> toSearchUsersRes(List<User> u
.userId(user.getId())
.nickname(user.getNickname())
.profileImgUrl(user.getProfileImg())
.userLevel(user.getUserLevel())
.build();

usersResList.add(usersRes);
Expand Down Expand Up @@ -94,6 +97,7 @@ public static UserResponseDto.SearchUsersRes toSearchUserRes (User user) {
.userId(user.getId())
.nickname(user.getNickname())
.profileImgUrl(user.getProfileImg())
.userLevel(user.getUserLevel())
.build();
}
}
10 changes: 10 additions & 0 deletions src/main/java/depth/jeonsilog/domain/user/dto/UserResponseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import depth.jeonsilog.domain.user.domain.Role;
import depth.jeonsilog.domain.user.domain.UserLevel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -31,6 +32,12 @@ public static class UserRes {

@Schema(type = "int", example = "20", description = "유저의 팔로워 숫자를 출력합니다.")
private Integer numFollower;

@Schema(type = "int", example = "5", description = "유저의 감상평 개수를 출력합니다.")
private Integer reviewCount;

@Schema(type = "UserLevel", example = "BEGINNER", description = "유저의 레벨을 출력합니다. NON(0), DONE(1 ~ 2), BEGINNER(3 ~ 9), INTERMEDIATE(10 ~ 19), ADVANCED(20 ~ 29), MASTER(30 ~)")
private UserLevel userLevel;
}

@Data
Expand All @@ -45,6 +52,9 @@ public static class SearchUsersRes {

@Schema(type = "string", example = "http://k.kakaocdn.net/dn/dpk9l1/btqmGhA2lKL/Oz0wDuJn1YV2DIn92f6DVK/img_640x640.jpg", description = "프로필 이미지 url을 출력합니다.")
private String profileImgUrl;

@Schema(type = "UserLevel", example = "BEGINNER", description = "유저의 레벨을 출력합니다. NON(0), DONE(1 ~ 2), BEGINNER(3 ~ 9), INTERMEDIATE(10 ~ 19), ADVANCED(20 ~ 29), MASTER(30 ~)")
private UserLevel userLevel;
}

@Data
Expand Down

0 comments on commit bc3cfec

Please sign in to comment.