-
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.
Browse files
Browse the repository at this point in the history
�Refactor/#38 유저 도메인 리팩터링
- Loading branch information
Showing
27 changed files
with
399 additions
and
314 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
43 changes: 0 additions & 43 deletions
43
src/main/java/coffeemeet/server/interest/service/InterestService.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
src/main/java/coffeemeet/server/interest/service/cq/InterestCommand.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,40 @@ | ||
package coffeemeet.server.interest.service.cq; | ||
|
||
import coffeemeet.server.interest.domain.Interest; | ||
import coffeemeet.server.interest.domain.Keyword; | ||
import coffeemeet.server.interest.repository.InterestRepository; | ||
import coffeemeet.server.user.domain.User; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class InterestCommand { | ||
|
||
private final InterestRepository interestRepository; | ||
|
||
public List<Interest> findAllByUserId(long userId) { | ||
return interestRepository.findAllByUserId(userId); | ||
} | ||
|
||
public void saveAll(List<Keyword> keywords, User user) { | ||
List<Interest> interests = keywords.stream() | ||
.map(keyword -> new Interest(keyword, user)) | ||
.toList(); | ||
interestRepository.saveAll(interests); | ||
} | ||
|
||
public void updateInterests(User user, List<Keyword> keywords) { | ||
List<Interest> currentInterests = findAllByUserId(user.getId()); | ||
deleteAll(currentInterests); | ||
saveAll(keywords, user); | ||
} | ||
|
||
public void deleteAll(List<Interest> interests) { | ||
interestRepository.deleteAllInBatch(interests); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/coffeemeet/server/interest/service/cq/InterestQuery.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,24 @@ | ||
package coffeemeet.server.interest.service.cq; | ||
|
||
import coffeemeet.server.interest.domain.Interest; | ||
import coffeemeet.server.interest.domain.Keyword; | ||
import coffeemeet.server.interest.repository.InterestRepository; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class InterestQuery { | ||
|
||
private final InterestRepository interestRepository; | ||
|
||
public List<Keyword> getKeywordsByUserId(Long userId) { | ||
return interestRepository.findAllByUserId(userId).stream() | ||
.map(Interest::getKeyword) | ||
.toList(); | ||
} | ||
|
||
} |
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
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
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.