Skip to content

Commit

Permalink
Merge pull request #99 from SWM-Flash/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ChoiWonYu authored Oct 29, 2024
2 parents 2ed55af + a3aaac3 commit e1f459e
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public MemberCompleteRegistrationResponse completeMemberRegistration(
request.gender(), request.reach(), request.profileImageUrl());

Events.raise(MemberInfoUpdatedEvent.of(member.getId(), member.getNickName(),
member.getInstagramId(), member.getProfileImageUrl()));
member.getInstagramId(), member.getProfileImageUrl(), member.getHeight(),
member.getReach(), member.getGender()));

return MemberCompleteRegistrationResponse.toDto(member);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ public class MemberInfoUpdatedEvent extends Event {
private final String nickName;
private final String instagramId;
private final String profileImageUrl;
private final Double height;
private final Double reach;
private final Gender gender;

public static MemberInfoUpdatedEvent of(final UUID memberId, final String nickName,
final String instagramId, final String profileImageUrl) {
return new MemberInfoUpdatedEvent(memberId, nickName, instagramId, profileImageUrl);
final String instagramId, final String profileImageUrl, final Double height,
final Double reach, final Gender gender) {
return new MemberInfoUpdatedEvent(memberId, nickName, instagramId, profileImageUrl, height,
reach, gender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ClimbingGymDetailResponseDto findClimbingGymDetail(final Long id) {
List<String> sectorNames = findSectorNamesById(id);
List<String> difficultyNames = getDifficultyNames(climbingGym);
return new ClimbingGymDetailResponseDto(climbingGym.getGymName(),
climbingGym.getMapImageUrl(),
climbingGym.getMapImageUrl(), climbingGym.getCalendarImageUrl(),
difficultyNames, sectorNames);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
public record ClimbingGymCreateRequestDto(
@NotEmpty(message = "클라이밍장 이름은 필수입니다.") String gymName,
@NotEmpty(message = "썸네일 URL은 필수입니다.") String thumbnailUrl,
@NotEmpty(message = "지도 이미지 URL은 필수입니다.") String mapImageUrl,
String mapImageUrl,
@NotEmpty(message = "일정 이미지 URL은 필수입니다.") String calendarImageUrl,
@NotEmpty(message = "난이도 정보는 최소 하나 이상이어야 합니다.")
List<@Valid @NotNull(message = "난이도 정보는 비어있을 수 없습니다.") Difficulty> difficulties) {

public ClimbingGym toEntity() {
return new ClimbingGym(gymName, thumbnailUrl, mapImageUrl, difficulties);
return new ClimbingGym(gymName, thumbnailUrl, mapImageUrl, calendarImageUrl, difficulties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import java.util.List;

public record ClimbingGymCreateResponseDto(Long id, String gymName, String thumbnailUrl,
String mapImageUrl, List<Difficulty> difficulties) {
String mapImageUrl, String calendarImageUrl, List<Difficulty> difficulties) {

public static ClimbingGymCreateResponseDto toDto(final ClimbingGym gym) {
return new ClimbingGymCreateResponseDto(gym.getId(), gym.getGymName(),
gym.getThumbnailUrl(), gym.getMapImageUrl(), gym.getDifficulties());
gym.getThumbnailUrl(), gym.getMapImageUrl(), gym.getCalendarImageUrl(), gym.getDifficulties());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

public record ClimbingGymDetailResponseDto(String gymName, String mapImageUrl,
String calendarImageUrl,
List<String> difficulties,
List<String> sectors) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ClimbingGym {
private String gymName;
private String thumbnailUrl;
private String mapImageUrl;
private String calendarImageUrl;

@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "DIFFICULTY",
Expand All @@ -39,17 +40,18 @@ public class ClimbingGym {
private List<Difficulty> difficulties;

public ClimbingGym(final String gymName, final String thumbnailUrl, final String mapImageUrl,
final List<Difficulty> difficulties) {
final String calendarImageUrl, final List<Difficulty> difficulties) {
this.gymName = gymName;
this.thumbnailUrl = thumbnailUrl;
this.mapImageUrl = mapImageUrl;
this.difficulties = difficulties;
this.calendarImageUrl = calendarImageUrl;
}

public Difficulty getDifficultyByName(final String difficultyName) {
return difficulties.stream()
.filter(difficulty -> difficulty.hasSameName(difficultyName))
.findAny()
.orElseThrow(() -> new DifficultyNotFoundException(difficultyName));
.filter(difficulty -> difficulty.hasSameName(difficultyName))
.findAny()
.orElseThrow(() -> new DifficultyNotFoundException(difficultyName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import java.util.UUID;

public record ProblemResponseDto(UUID id, String sector, String difficulty, LocalDate settingDate,
LocalDate removalDate, boolean hasSolution, String imageUrl, Boolean isHoney) {
LocalDate removalDate, boolean hasSolution, String imageUrl,
Boolean isHoney, Integer solutionCount) {

public static ProblemResponseDto toDto(QueryProblem queryProblem) {
return new ProblemResponseDto(queryProblem.getId(), queryProblem.getSectorName(),
queryProblem.getDifficultyName(), queryProblem.getSettingDate(),
queryProblem.getRemovalDate(), queryProblem.getHasSolution(),
queryProblem.getImageUrl(), queryProblem.isHoney());
queryProblem.getImageUrl(), queryProblem.isHoney(), queryProblem.getSolutionCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class SolutionEventHandler {
@Transactional
public void updateSolutionInfo(final MemberInfoUpdatedEvent event) {
solutionSaveService.updateUploaderInfo(event.getMemberId(), event.getNickName(),
event.getInstagramId(), event.getProfileImageUrl());
event.getInstagramId(), event.getProfileImageUrl(), event.getHeight(), event.getReach(),
event.getGender());

solutionCommentService.updateCommenterInfo(event.getMemberId(), event.getNickName(),
event.getProfileImageUrl());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.first.flash.climbing.solution.application;

import com.first.flash.account.member.application.MemberService;
import com.first.flash.account.member.domain.Gender;
import com.first.flash.account.member.domain.Member;
import com.first.flash.climbing.solution.application.dto.SolutionWriteResponseDto;
import com.first.flash.climbing.solution.application.dto.UnregisteredMemberSolutionCreateRequest;
Expand Down Expand Up @@ -34,8 +35,10 @@ public SolutionWriteResponseDto saveSolution(final UUID problemId,
PerceivedDifficulty perceivedDifficulty = createRequestDto.perceivedDifficulty();
Solution solution = Solution.of(member.getNickName(), createRequestDto.review(),
member.getInstagramId(), createRequestDto.videoUrl(), problemId, member.getId(),
member.getProfileImageUrl(), perceivedDifficulty);
Events.raise(PerceivedDifficultySetEvent.of(solution.getProblemId(), perceivedDifficulty.getValue()));
member.getProfileImageUrl(), perceivedDifficulty, member.getHeight(), member.getReach(),
member.getGender());
Events.raise(PerceivedDifficultySetEvent.of(solution.getProblemId(),
perceivedDifficulty.getValue()));

Solution savedSolution = solutionRepository.save(solution);
Events.raise(SolutionSavedEvent.of(savedSolution.getProblemId()));
Expand All @@ -44,8 +47,10 @@ public SolutionWriteResponseDto saveSolution(final UUID problemId,

@Transactional
public void updateUploaderInfo(final UUID uploaderId, final String nickName,
final String instagramId, final String profileImageUrl) {
solutionRepository.updateUploaderInfo(uploaderId, nickName, instagramId, profileImageUrl);
final String instagramId, final String profileImageUrl, final Double uploaderHeight,
final Double uploaderReach, final Gender uploaderGender) {
solutionRepository.updateUploaderInfo(uploaderId, nickName, instagramId, profileImageUrl,
uploaderHeight, uploaderReach, uploaderGender);
}

@Transactional
Expand All @@ -57,10 +62,12 @@ public SolutionWriteResponseDto saveUnregisteredMemberSolution(final UUID proble
PerceivedDifficulty perceivedDifficulty = requestDto.perceivedDifficulty();
Solution solution = Solution.of(requestDto.nickName(), requestDto.review(),
requestDto.instagramId(), requestDto.videoUrl(), problemId, member.getId(),
requestDto.profileImageUrl(), perceivedDifficulty);
requestDto.profileImageUrl(), perceivedDifficulty, member.getHeight(),
member.getReach(), member.getGender());

Solution savedSolution = solutionRepository.save(solution);
Events.raise(PerceivedDifficultySetEvent.of(solution.getProblemId(), perceivedDifficulty.getValue()));
Events.raise(PerceivedDifficultySetEvent.of(solution.getProblemId(),
perceivedDifficulty.getValue()));
Events.raise(SolutionSavedEvent.of(savedSolution.getProblemId()));
return SolutionWriteResponseDto.toDto(savedSolution);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.first.flash.climbing.solution.domain;

import com.first.flash.account.member.domain.Gender;
import com.first.flash.climbing.solution.domain.vo.SolutionDetail;
import com.first.flash.climbing.solution.domain.vo.UploaderDetail;
import com.first.flash.global.domain.BaseEntity;
Expand Down Expand Up @@ -41,30 +42,28 @@ public class Solution extends BaseEntity {

protected Solution(final String uploader, final String review, final String instagramId,
final String videoUrl, final UUID problemId, final UUID uploaderId,
final String profileImageUrl, final PerceivedDifficulty perceivedDifficulty) {
final String profileImageUrl, final PerceivedDifficulty perceivedDifficulty,
final Double uploaderHeight,
final Double uploaderReach, final Gender uploaderGender) {

this.solutionDetail = SolutionDetail.of(review, videoUrl, perceivedDifficulty);
this.uploaderDetail = UploaderDetail.of(uploaderId, uploader, instagramId, profileImageUrl);
this.uploaderDetail = UploaderDetail.of(uploaderId, uploader, instagramId, profileImageUrl,
uploaderHeight, uploaderReach, uploaderGender);
this.optionalWeight = DEFAULT_OPTIONAL_WEIGHT;
this.problemId = problemId;
}

public static Solution of(final String uploader, final String review, final String instagramId,
final String videoUrl, final UUID problemId, final UUID uploaderId,
final String profileImageUrl, final PerceivedDifficulty perceivedDifficulty) {
final String profileImageUrl, final PerceivedDifficulty perceivedDifficulty,
final Double uploaderHeight, final Double uploaderReach, final Gender uploaderGender) {

return new Solution(uploader, review, instagramId, videoUrl, problemId, uploaderId,
profileImageUrl, perceivedDifficulty);
profileImageUrl, perceivedDifficulty, uploaderHeight, uploaderReach, uploaderGender);
}

public void updateUploaderInfo(final String uploader, final String instagramId,
final String profileImageUrl) {
UUID uploaderId = this.uploaderDetail.getUploaderId();

this.uploaderDetail = UploaderDetail.of(uploaderId, uploader, instagramId, profileImageUrl);
}

public void updateContentInfo(final String review, final String videoUrl, final PerceivedDifficulty perceivedDifficulty) {
public void updateContentInfo(final String review, final String videoUrl,
final PerceivedDifficulty perceivedDifficulty) {
this.solutionDetail = SolutionDetail.of(review, videoUrl, perceivedDifficulty);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.first.flash.climbing.solution.domain;

import com.first.flash.account.member.domain.Gender;
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.SolutionRepositoryResponseDto;
Expand All @@ -20,7 +21,8 @@ List<SolutionRepositoryResponseDto> findAllByProblemId(final UUID problemId,
void deleteById(final Long id);

void updateUploaderInfo(final UUID uploaderId, final String nickName, final String instagramId,
final String profileImageUrl);
final String profileImageUrl, final Double uploaderHeight,
final Double uploaderReach, final Gender uploaderGender);

DetailSolutionDto findDetailSolutionById(final Long solutionId);

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

import com.first.flash.account.member.domain.Gender;
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 videoUrl, UUID uploaderId, Double uploaderHeight,
Double uploaderReach, Gender uploaderGender, 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(),
repositoryResponseDto.uploaderHeight(), repositoryResponseDto.uploaderReach(),
repositoryResponseDto.uploaderGender(),
AuthUtil.isSameId(repositoryResponseDto.uploaderId()),
repositoryResponseDto.profileImageUrl(), repositoryResponseDto.commentCount());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.first.flash.climbing.solution.domain.vo;

import com.first.flash.account.member.domain.Gender;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import java.util.UUID;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -20,17 +23,28 @@ public class UploaderDetail {
private String uploader;
private String instagramId;
private String profileImageUrl;
private Double uploaderHeight;
private Double uploaderReach;
@Enumerated(EnumType.STRING)
private Gender uploaderGender;

protected UploaderDetail(final UUID uploaderId, final String uploader,
final String instagramId, final String profileImageUrl) {
final String instagramId, final String profileImageUrl, final Double uploaderHeight,
final Double uploaderReach,
final Gender uploaderGender) {
this.uploaderId = uploaderId;
this.uploader = uploader;
this.instagramId = instagramId;
this.profileImageUrl = profileImageUrl;
this.uploaderHeight = uploaderHeight;
this.uploaderReach = uploaderReach;
this.uploaderGender = uploaderGender;
}

public static UploaderDetail of(final UUID uploaderId, final String uploader,
final String instagramId, final String profileImageUrl) {
return new UploaderDetail(uploaderId, uploader, instagramId, profileImageUrl);
final String instagramId, final String profileImageUrl, final Double height,
final Double reach, final Gender gender) {
return new UploaderDetail(uploaderId, uploader, instagramId, profileImageUrl, height, reach,
gender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.first.flash.climbing.solution.domain.QSolution.solution;
import static com.first.flash.climbing.solution.domain.QSolutionComment.solutionComment;

import com.first.flash.account.member.domain.Gender;
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.SolutionRepositoryResponseDto;
Expand All @@ -29,8 +30,9 @@ public List<SolutionRepositoryResponseDto> findAllExcludedBlockedMembers(final U
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.profileImageUrl,
solutionComment.count()
solution.uploaderDetail.uploaderId, solution.uploaderDetail.uploaderHeight,
solution.uploaderDetail.uploaderReach, solution.uploaderDetail.uploaderGender,
solution.uploaderDetail.profileImageUrl, solutionComment.count()
))
.from(solution)
.leftJoin(solutionComment)
Expand Down Expand Up @@ -64,11 +66,15 @@ public List<MySolutionDto> findByUploaderId(final UUID uploaderId,
}

public void updateUploaderInfo(final UUID uploaderId, final String nickName,
final String instagramId, final String profileImageUrl) {
final String instagramId, final String profileImageUrl, final Double uploaderHeight,
final Double uploaderReach, final Gender uploaderGender) {
jpaQueryFactory.update(solution)
.set(solution.uploaderDetail.uploader, nickName)
.set(solution.uploaderDetail.instagramId, instagramId)
.set(solution.uploaderDetail.profileImageUrl, profileImageUrl)
.set(solution.uploaderDetail.uploaderHeight, uploaderHeight)
.set(solution.uploaderDetail.uploaderReach, uploaderReach)
.set(solution.uploaderDetail.uploaderGender, uploaderGender)
.where(solution.uploaderDetail.uploaderId.eq(uploaderId))
.execute();
}
Expand All @@ -77,7 +83,8 @@ public DetailSolutionDto findDetailSolutionById(final Long solutionId) {
return jpaQueryFactory.select(Projections.constructor(DetailSolutionDto.class,
solution.id, solution.solutionDetail.videoUrl, queryProblem.gymName,
queryProblem.sectorName, solution.solutionDetail.review,
queryProblem.difficultyName, solutionComment.count(), solution.solutionDetail.perceivedDifficulty,
queryProblem.difficultyName, solutionComment.count(),
solution.solutionDetail.perceivedDifficulty,
queryProblem.removalDate, queryProblem.settingDate, solution.createdAt
))
.from(solution)
Expand Down
Loading

0 comments on commit e1f459e

Please sign in to comment.