Skip to content

Commit

Permalink
#52 [feat] 회원가입시 희망 지역 리스트 전체 조회 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
hellozo0 committed Jan 10, 2024
1 parent 8cf0ff9 commit 53d5f96
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/moddy/server/service/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
import com.moddy.server.common.exception.model.NotFoundException;
import com.moddy.server.config.jwt.JwtService;
import com.moddy.server.controller.auth.dto.response.LoginResponseDto;
import com.moddy.server.controller.auth.dto.response.RegionResponse;
import com.moddy.server.domain.region.Region;
import com.moddy.server.domain.region.repository.RegionJpaRepository;
import com.moddy.server.domain.user.User;
import com.moddy.server.domain.user.repository.UserRepository;
import com.moddy.server.external.kakao.service.KakaoSocialService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

import static com.moddy.server.common.exception.enums.ErrorCode.USER_NOT_FOUND_EXCEPTION;

@Service
Expand All @@ -18,6 +24,7 @@ public class AuthService {
private final JwtService jwtService;
private final KakaoSocialService kakaoSocialService;
private final UserRepository userRepository;
private final RegionJpaRepository regionJpaRepository;

public LoginResponseDto login(final String baseUrl, final String kakaoCode) {
String kakaoId = kakaoSocialService.getIdFromKakao(baseUrl, kakaoCode);
Expand All @@ -26,4 +33,18 @@ public LoginResponseDto login(final String baseUrl, final String kakaoCode) {

return new LoginResponseDto(tokenPair.accessToken(), tokenPair.refreshToken(), user.getRole().name());
}

public List<RegionResponse> getRegionList(){

List<RegionResponse> regionResponseList = regionJpaRepository.findAll().stream().map(region -> {
RegionResponse regionResponse = new RegionResponse(
region.getId(),
region.getName()
);
return regionResponse;
}).collect(Collectors.toList());

return regionResponseList;
}

}

0 comments on commit 53d5f96

Please sign in to comment.