-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
core-module/src/main/java/com/foodgo/coremodule/community/service/ChallengeQueryService.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,23 @@ | ||
package com.foodgo.coremodule.community.service; | ||
|
||
import com.foodgo.coremodule.community.domain.Challenge; | ||
import com.foodgo.coremodule.community.repository.ChallengeDetailRepository; | ||
import com.foodgo.coremodule.community.repository.ChallengeRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ChallengeQueryService { | ||
|
||
private final ChallengeRepository challengeRepository; | ||
private final ChallengeDetailRepository challengeDetailRepository; | ||
|
||
public Challenge findRecentChallenge(Long userId) { | ||
return challengeRepository.findTopByFriendshipUserIdOrderByCreatedAtDesc(userId); | ||
} | ||
|
||
public Boolean checkChallengeYn(Long friendshipId) { | ||
return challengeRepository.existsChallengeByFriendshipId(friendshipId); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
core-module/src/main/java/com/foodgo/coremodule/community/service/FriendQueryService.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,30 @@ | ||
package com.foodgo.coremodule.community.service; | ||
|
||
import com.foodgo.coremodule.community.domain.Friendship; | ||
import com.foodgo.coremodule.community.repository.FriendShipRepository; | ||
import com.foodgo.coremodule.user.domain.User; | ||
import com.foodgo.coremodule.user.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FriendQueryService { | ||
|
||
private final FriendShipRepository friendShipRepository; | ||
private final UserRepository userRepository; | ||
|
||
public List<User> findFriendWithNickname(String nickname) { | ||
return userRepository.findAllByNicknameContaining(nickname); | ||
} | ||
|
||
public Boolean checkFriendShipYn(Long userId, Long friendId) { | ||
return friendShipRepository.existsFriendshipByUserIdAndFriendId(userId, friendId); | ||
} | ||
|
||
public Friendship findByUserIdAndFriendId(Long userId, Long friendId) { | ||
return friendShipRepository.findFriendshipByUserIdAndFriendId(userId, friendId); | ||
} | ||
} |
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
34 changes: 19 additions & 15 deletions
34
core-module/src/main/java/com/foodgo/coremodule/user/service/UserQueryService.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,32 +1,36 @@ | ||
package com.foodgo.coremodule.user.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.foodgo.commonmodule.user.exception.UserErrorCode; | ||
import com.foodgo.commonmodule.user.exception.UserExceptionHandler; | ||
import com.foodgo.coremodule.user.domain.User; | ||
import com.foodgo.coremodule.user.repository.UserRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
@Service | ||
public class UserQueryService { | ||
|
||
private final UserRepository userRepository; | ||
private final UserRepository userRepository; | ||
|
||
public Boolean checkUsername(String username) { | ||
return userRepository.existsByUsername(username); | ||
} | ||
|
||
public Boolean checkUsername(String username) { | ||
return userRepository.existsByUsername(username); | ||
} | ||
public Boolean checkNickname(String nickname) { | ||
return userRepository.existsByNickname(nickname); | ||
} | ||
|
||
public Boolean checkNickname(String nickname) { | ||
return userRepository.existsByNickname(nickname); | ||
} | ||
public User findByUserName(String username) { | ||
return userRepository.findByUsername(username) | ||
.orElseThrow(() -> new UserExceptionHandler(UserErrorCode.USER_NOT_FOUND)); | ||
} | ||
|
||
public User findByUserName(String username) { | ||
return userRepository.findByUsername(username) | ||
.orElseThrow(() -> new UserExceptionHandler(UserErrorCode.USER_NOT_FOUND)); | ||
} | ||
public List<User> findAllUsers() { | ||
return userRepository.findAll(); | ||
} | ||
} |