-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat/#49] follow api #52
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
src/main/java/com/clokey/server/domain/member/application/FollowCommandService.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.clokey.server.domain.member.application; | ||
|
||
import com.clokey.server.domain.member.dto.MemberDTO; | ||
|
||
public interface FollowCommandService { | ||
void follow(MemberDTO.FollowRQ request); | ||
|
||
MemberDTO.FollowRP followCheck(MemberDTO.FollowRQ request); | ||
} | ||
|
58 changes: 58 additions & 0 deletions
58
src/main/java/com/clokey/server/domain/member/application/FollowCommandServiceImpl.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,58 @@ | ||
package com.clokey.server.domain.member.application; | ||
|
||
import com.clokey.server.domain.follow.dao.FollowRepository; | ||
import com.clokey.server.domain.member.dto.MemberDTO; | ||
import com.clokey.server.domain.model.Member; | ||
import com.clokey.server.domain.model.mapping.Follow; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FollowCommandServiceImpl implements FollowCommandService { | ||
|
||
private final MemberRepositoryService memberRepositoryService; | ||
private final FollowRepository followRepository; | ||
|
||
@Override | ||
public MemberDTO.FollowRP followCheck(MemberDTO.FollowRQ request) { | ||
Long myUserId = memberRepositoryService.findMemberByClokeyId(request.getMyClokeyId()).getId(); | ||
Long yourUserId = memberRepositoryService.findMemberByClokeyId(request.getYourClokeyId()).getId(); | ||
|
||
boolean isFollow = followRepository.existsByFollowing_IdAndFollowed_Id(myUserId, yourUserId); | ||
|
||
return new MemberDTO.FollowRP(isFollow); | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public void follow(MemberDTO.FollowRQ request) { | ||
// myClokeyIdλ‘ μ¬μ©μ μ‘°ν | ||
Long myUserId = memberRepositoryService.findMemberByClokeyId(request.getMyClokeyId()).getId(); | ||
Long yourUserId = memberRepositoryService.findMemberByClokeyId(request.getYourClokeyId()).getId(); | ||
|
||
// νλ‘μ° κ΄κ³κ° μ‘΄μ¬νλμ§ νμΈ | ||
boolean isFollow = followRepository.existsByFollowing_IdAndFollowed_Id(myUserId, yourUserId); | ||
|
||
if (isFollow) { | ||
// νλ‘μ°κ° μ΄λ―Έ μ‘΄μ¬νλ©΄ μΈνλ‘μ° μ²λ¦¬ | ||
Follow follow = followRepository.findByFollowing_IdAndFollowed_Id(myUserId, yourUserId) | ||
.orElseThrow(() -> new IllegalStateException("νλ‘μ° κ΄κ³κ° μ‘΄μ¬νμ§ μμ΅λλ€.")); | ||
|
||
// νλ‘μ° μμ (μΈνλ‘μ°) | ||
followRepository.delete(follow); | ||
} else { | ||
// νλ‘μ°κ° μ‘΄μ¬νμ§ μμΌλ©΄ νλ‘μ° μ²λ¦¬ | ||
Follow follow = Follow.builder() | ||
.following(memberRepositoryService.findMemberById(myUserId)) | ||
.followed(memberRepositoryService.findMemberById(yourUserId)) | ||
.build(); | ||
|
||
// νλ‘μ° μ μ₯ | ||
followRepository.save(follow); | ||
} | ||
} | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
src/main/java/com/clokey/server/domain/member/application/GetUserQueryService.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.clokey.server.domain.member.application; | ||
|
||
import com.clokey.server.domain.member.dto.MemberResponseDTO; | ||
import com.clokey.server.domain.member.dto.MemberDTO; | ||
|
||
public interface GetUserQueryService { | ||
|
||
MemberResponseDTO.GetUserRP getUser(String clokeyId); | ||
MemberDTO.GetUserRP getUser(String clokeyId); | ||
|
||
} |
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
4 changes: 2 additions & 2 deletions
4
src/main/java/com/clokey/server/domain/member/application/ProfileCommandService.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.clokey.server.domain.member.application; | ||
|
||
|
||
import com.clokey.server.domain.member.dto.MemberResponseDTO; | ||
import com.clokey.server.domain.member.dto.MemberDTO; | ||
|
||
|
||
public interface ProfileCommandService { | ||
MemberResponseDTO.ProfileRP updateProfile(Long userId, MemberResponseDTO.ProfileRQ request); | ||
MemberDTO.ProfileRP updateProfile(Long userId, MemberDTO.ProfileRQ request); | ||
} |
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
6 changes: 3 additions & 3 deletions
6
src/main/java/com/clokey/server/domain/member/converter/GetUserConverter.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
6 changes: 3 additions & 3 deletions
6
src/main/java/com/clokey/server/domain/member/converter/ProfileConverter.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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μΈμ€νκ·Έλ¨ μ²λΌ νμμ μ‘°νν κ²½μ° νλ‘μ°λ₯Ό νκ³ μλμ§ μμμΌ ν κ² κ°μμ.
λ°λΌμ, νμ μ‘°ν APIμ Responseμ "isFollowing"κ³Ό κ°μ΄ νλ‘μ° μ€μΈμ§ μ 보λ₯Ό λμ Έμ£Όμ΄μΌ ν κ² κ°μμ!
μ΄λ μλ‘μ΄ APIκ° μλ νμ μ‘°νμ μ°μ μ μΌλ‘ μΆκ°κ° λμ΄μΌ νλ€κ³ μκ°ν©λλ€!