Skip to content

Commit

Permalink
Merge pull request #89 from SWM-Flash/integration
Browse files Browse the repository at this point in the history
Integration
  • Loading branch information
ChoiWonYu authored Oct 16, 2024
2 parents a6b492f + 257a635 commit 3495ccf
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public MemberReportResponse reportMember(final Long reportedContentId,
UUID reporterId = AuthUtil.getId();
Member reporter = memberService.findById(reporterId);
MemberReport memberReport = MemberReport.reportContent(request.reason(), reporter,
reportedContentId);
reportRepository.save(memberReport);
return MemberReportResponse.toDto(reportedContentId, request.reason());
reportedContentId, request.contentType());
MemberReport savedReport = reportRepository.save(memberReport);
return MemberReportResponse.toDto(savedReport.getReportedContentId(),
savedReport.getContentType(), savedReport.getReason());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.first.flash.account.member.application.dto;

import com.first.flash.account.member.domain.ContentType;
import com.first.flash.global.annotation.ValidEnum;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason) {
public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason,
@NotNull(message = "콘텐츠 타입은 필수입니다.") @ValidEnum(enumClass = ContentType.class) ContentType contentType) {

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.first.flash.account.member.application.dto;

public record MemberReportResponse(Long reportedContentId, String reason) {
import com.first.flash.account.member.domain.ContentType;

public static MemberReportResponse toDto(final Long reportedContentId, final String reason) {
return new MemberReportResponse(reportedContentId, reason);
public record MemberReportResponse(Long reportedContentId, String contentType, String reason) {

public static MemberReportResponse toDto(final Long reportedContentId,
final ContentType contentType, final String reason) {
return new MemberReportResponse(reportedContentId, contentType.name(), reason);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.first.flash.account.member.domain;

import lombok.ToString;

@ToString
public enum ContentType {
SOLUTION, COMMENT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.first.flash.global.domain.BaseEntity;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -27,15 +29,19 @@ public class MemberReport extends BaseEntity {
@JoinColumn(name = "reporterId")
private Member reporter;
private Long reportedContentId;
@Enumerated(EnumType.STRING)
private ContentType contentType;

private MemberReport(final String reason, final Member reporter, final Long reportedContentId) {
private MemberReport(final String reason, final Member reporter, final Long reportedContentId,
final ContentType contentType) {
this.reason = reason;
this.reporter = reporter;
this.reportedContentId = reportedContentId;
this.contentType = contentType;
}

public static MemberReport reportContent(final String reason, final Member reporter,
final Long reportedContentId) {
return new MemberReport(reason, reporter, reportedContentId);
final Long reportedContentId, final ContentType contentType) {
return new MemberReport(reason, reporter, reportedContentId, contentType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
import com.first.flash.climbing.solution.domain.Solution;
import com.first.flash.climbing.solution.domain.SolutionDeletedEvent;
import com.first.flash.climbing.solution.domain.SolutionRepository;
import com.first.flash.climbing.solution.domain.SolutionSavedEvent;
import com.first.flash.climbing.solution.domain.dto.SolutionResponseDto;
import com.first.flash.climbing.solution.exception.exceptions.SolutionAccessDeniedException;
import com.first.flash.climbing.solution.exception.exceptions.SolutionNotFoundException;
import com.first.flash.climbing.solution.infrastructure.dto.DetailSolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.MySolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionResponseDto;
import com.first.flash.climbing.solution.infrastructure.paging.SolutionCursor;
import com.first.flash.global.event.Events;
import com.first.flash.global.util.AuthUtil;
Expand Down Expand Up @@ -49,8 +48,9 @@ public SolutionsResponseDto findAllSolutionsByProblemId(final UUID problemId) {
Events.raise(ProblemIdConfirmRequestedEvent.of(problemId));
List<UUID> blockedMembers = blockService.findBlockedMembers();
List<SolutionResponseDto> solutions = solutionRepository.findAllByProblemId(problemId,
AuthUtil.getId(), blockedMembers);

blockedMembers).stream()
.map(SolutionResponseDto::from)
.toList();
return SolutionsResponseDto.of(solutions);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.first.flash.climbing.solution.application.dto;

import com.first.flash.climbing.solution.infrastructure.dto.SolutionResponseDto;
import com.first.flash.climbing.solution.domain.dto.SolutionResponseDto;
import java.util.List;

public record SolutionsResponseDto(List<SolutionResponseDto> solutions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.first.flash.climbing.solution.infrastructure.dto.DetailSolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.MySolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionResponseDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionRepositoryResponseDto;
import com.first.flash.climbing.solution.infrastructure.paging.SolutionCursor;
import java.util.List;
import java.util.Optional;
Expand All @@ -14,7 +14,7 @@ public interface SolutionRepository {

Optional<Solution> findById(final Long id);

List<SolutionResponseDto> findAllByProblemId(final UUID problemId, final UUID memberId,
List<SolutionRepositoryResponseDto> findAllByProblemId(final UUID problemId,
final List<UUID> blockedMembers);

void deleteById(final Long id);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.first.flash.climbing.solution.domain.dto;

import com.first.flash.climbing.solution.infrastructure.dto.SolutionRepositoryResponseDto;
import com.first.flash.global.util.AuthUtil;
import java.util.UUID;

public record SolutionResponseDto(Long id, String uploader, String review, String instagramId,
String videoUrl, UUID uploaderId, Boolean isUploader,
String profileImageUrl, Long commentCount) {

public static SolutionResponseDto from(
final SolutionRepositoryResponseDto repositoryResponseDto) {
return new SolutionResponseDto(repositoryResponseDto.id(), repositoryResponseDto.uploader(),
repositoryResponseDto.review(), repositoryResponseDto.instagramId(),
repositoryResponseDto.videoUrl(), repositoryResponseDto.uploaderId(),
AuthUtil.isSameId(repositoryResponseDto.uploaderId()),
repositoryResponseDto.profileImageUrl(), repositoryResponseDto.commentCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import com.first.flash.climbing.solution.infrastructure.dto.DetailSolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.MySolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionResponseDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionRepositoryResponseDto;
import com.first.flash.climbing.solution.infrastructure.paging.SolutionCursor;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
Expand All @@ -24,13 +24,13 @@ public class SolutionQueryDslRepository {

private final JPAQueryFactory jpaQueryFactory;

public List<SolutionResponseDto> findAllExcludedBlockedMembers(final UUID problemId,
final UUID memberId, final List<UUID> memberIds) {
return jpaQueryFactory.select(Projections.constructor(SolutionResponseDto.class,
public List<SolutionRepositoryResponseDto> findAllExcludedBlockedMembers(final UUID problemId,
final List<UUID> memberIds) {
return jpaQueryFactory.select(Projections.constructor(SolutionRepositoryResponseDto.class,
solution.id, solution.uploaderDetail.uploader, solution.solutionDetail.review,
solution.uploaderDetail.instagramId, solution.solutionDetail.videoUrl,
solution.uploaderDetail.uploaderId, solution.uploaderDetail.uploaderId.eq(memberId),
solution.uploaderDetail.profileImageUrl, solutionComment.count()
solution.uploaderDetail.uploaderId, solution.uploaderDetail.profileImageUrl,
solutionComment.count()
))
.from(solution)
.leftJoin(solutionComment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.first.flash.climbing.solution.domain.SolutionRepository;
import com.first.flash.climbing.solution.infrastructure.dto.DetailSolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.MySolutionDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionResponseDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionRepositoryResponseDto;
import com.first.flash.climbing.solution.infrastructure.paging.SolutionCursor;
import java.util.List;
import java.util.Optional;
Expand All @@ -30,10 +30,10 @@ public Optional<Solution> findById(final Long id) {
}

@Override
public List<SolutionResponseDto> findAllByProblemId(final UUID problemId,
final UUID memberId, final List<UUID> blockedMembers) {
public List<SolutionRepositoryResponseDto> findAllByProblemId(final UUID problemId,
final List<UUID> blockedMembers) {
return solutionQueryDslRepository.findAllExcludedBlockedMembers(
problemId, memberId, blockedMembers);
problemId, blockedMembers);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.first.flash.climbing.solution.infrastructure.dto;

import java.util.UUID;

public record SolutionRepositoryResponseDto(Long id, String uploader, String review,
String instagramId, String videoUrl, UUID uploaderId,
String profileImageUrl, Long commentCount) {

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.first.flash.climbing.solution.application.dto.SolutionCommentResponseDto;
import com.first.flash.climbing.solution.application.dto.SolutionCommentUpdateRequestDto;
import com.first.flash.climbing.solution.application.dto.SolutionCommentsResponseDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionResponseDto;
import com.first.flash.climbing.solution.infrastructure.dto.SolutionRepositoryResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
Expand Down Expand Up @@ -76,7 +76,7 @@ public ResponseEntity<SolutionCommentsResponseDto> getSolutionComments(
@Operation(summary = "댓글 수정", description = "내 댓글 수정")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적으로 댓글을 수정함",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = SolutionResponseDto.class))),
content = @Content(mediaType = "application/json", schema = @Schema(implementation = SolutionRepositoryResponseDto.class))),
@ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(name = "요청값 누락", value = "{\"error\": \"content는 필수입니다.\"}"),
Expand Down

0 comments on commit 3495ccf

Please sign in to comment.