Skip to content

Commit

Permalink
Merge pull request #88 from SWM-Flash/hotfix/FLASH-295-is-my-solution
Browse files Browse the repository at this point in the history
내 해설 영상인지 여부 판단 로직을 인프라스트럭처 계층에서 응용 계층으로 이동
  • Loading branch information
ChoiWonYu authored Oct 16, 2024
2 parents 01edda5 + 7c44e50 commit be66345
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 28 deletions.
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 be66345

Please sign in to comment.