-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from SWM-Flash/integration
Integration
- Loading branch information
Showing
22 changed files
with
317 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/first/flash/account/member/domain/MemberInfoUpdatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.first.flash.account.member.domain; | ||
|
||
import com.first.flash.global.event.Event; | ||
import java.util.UUID; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class MemberInfoUpdatedEvent extends Event { | ||
|
||
private final UUID memberId; | ||
private final String nickName; | ||
private final String instagramId; | ||
|
||
public static MemberInfoUpdatedEvent of(final UUID memberId, final String nickName, | ||
final String instagramId) { | ||
return new MemberInfoUpdatedEvent(memberId, nickName, instagramId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/first/flash/climbing/solution/application/SolutionEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.first.flash.climbing.solution.application; | ||
|
||
import com.first.flash.account.member.domain.MemberInfoUpdatedEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class SolutionEventHandler { | ||
|
||
private final SolutionSaveService solutionSaveService; | ||
|
||
@EventListener | ||
@Transactional | ||
public void updateSolutionInfo(final MemberInfoUpdatedEvent event) { | ||
solutionSaveService.updateUploaderInfo(event.getMemberId(), event.getNickName(), | ||
event.getInstagramId()); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.first.flash.climbing.solution.application; | ||
|
||
import com.first.flash.account.member.application.MemberService; | ||
import com.first.flash.account.member.domain.Member; | ||
import com.first.flash.climbing.solution.application.dto.SolutionResponseDto; | ||
import com.first.flash.climbing.solution.domain.Solution; | ||
import com.first.flash.climbing.solution.domain.SolutionRepository; | ||
import com.first.flash.climbing.solution.domain.SolutionSavedEvent; | ||
import com.first.flash.climbing.solution.domain.dto.SolutionCreateRequestDto; | ||
import com.first.flash.global.event.Events; | ||
import com.first.flash.global.util.AuthUtil; | ||
import java.util.UUID; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class SolutionSaveService { | ||
|
||
private final MemberService memberService; | ||
private final SolutionRepository solutionRepository; | ||
|
||
@Transactional | ||
public SolutionResponseDto saveSolution(final UUID problemId, | ||
final SolutionCreateRequestDto createRequestDto) { | ||
UUID id = AuthUtil.getId(); | ||
Member member = memberService.findById(id); | ||
|
||
Solution solution = Solution.of(member.getNickName(), createRequestDto.review(), | ||
member.getInstagramId(), | ||
createRequestDto.videoUrl(), problemId, member.getId()); | ||
Solution savedSolution = solutionRepository.save(solution); | ||
Events.raise(SolutionSavedEvent.of(savedSolution.getProblemId())); | ||
return SolutionResponseDto.toDto(savedSolution); | ||
} | ||
|
||
@Transactional | ||
public void updateUploaderInfo(final UUID uploaderId, final String nickName, | ||
final String instagramId) { | ||
solutionRepository.findAllByUploaderId(uploaderId) | ||
.forEach(solution -> solution.updateUploaderInfo(nickName, instagramId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...main/java/com/first/flash/climbing/solution/application/dto/SolutionUpdateRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.first.flash.climbing.solution.application.dto; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record SolutionUpdateRequestDto( | ||
@NotEmpty(message = "비디오 URL은 필수입니다.") String videoUrl, | ||
@Size(max = 500, message = "리뷰는 최대 500자까지 가능합니다.") String review) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/first/flash/climbing/solution/domain/SolutionDeletedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.first.flash.climbing.solution.domain; | ||
|
||
import com.first.flash.global.event.Event; | ||
import java.util.UUID; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class SolutionDeletedEvent extends Event { | ||
|
||
private UUID problemId; | ||
|
||
public static SolutionDeletedEvent of(final UUID problemId) { | ||
return new SolutionDeletedEvent(problemId); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.