-
Notifications
You must be signed in to change notification settings - Fork 2
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 #16 from jjuuuunnii/main
Feat: 서비스 위치 변경
- Loading branch information
Showing
4 changed files
with
45 additions
and
18 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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/snowthon/snowman/service/UserService.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,20 +1,46 @@ | ||
package com.snowthon.snowman.service; | ||
|
||
import com.snowthon.snowman.domain.User; | ||
import com.snowthon.snowman.domain.VoteHistory; | ||
import com.snowthon.snowman.dto.response.ArchivingDto; | ||
import com.snowthon.snowman.dto.type.ErrorCode; | ||
import com.snowthon.snowman.exception.CommonException; | ||
import com.snowthon.snowman.repository.UserRepository; | ||
import com.snowthon.snowman.repository.VoteHistoryRepository; | ||
import com.snowthon.snowman.utility.JwtUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UserService { | ||
|
||
private final UserRepository userRepository; | ||
private final VoteHistoryRepository voteHistoryRepository; | ||
private final JwtUtil jwtUtil; | ||
|
||
@Transactional | ||
public User saveUser(User user) { | ||
return userRepository.save(user); | ||
} | ||
|
||
//4-1. 모아 보기 | ||
public ArchivingDto getVoteHistoriesByUser(Long userId) { | ||
List<VoteHistory> voteHistories = voteHistoryRepository.findByUserId(userId); | ||
return ArchivingDto.fromEntity(voteHistories.stream() | ||
.map(ArchivingDto.ArchivingDetailDto::fromEntity).collect(Collectors.toList())); | ||
} | ||
|
||
|
||
//4-2. 모아 보기(상세) | ||
public ArchivingDto.ArchivingDetailDto getVoteHistoryById(Long voteHistoryId) { | ||
return ArchivingDto.ArchivingDetailDto.fromEntity(voteHistoryRepository.findById(voteHistoryId) | ||
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_HISTORY))); | ||
} | ||
|
||
|
||
} |
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