Skip to content
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

🚀 [Deploy] - ResponseDTO 반영 #34

Merged
merged 39 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e7febbf
Feat: customException 구현
Jang99u May 2, 2024
4767908
Feat: responseDto 구현
Jang99u May 2, 2024
b6fcd13
Merge pull request #9 from Jang99u/feature/4
Jang99u May 2, 2024
6ff9b15
Feat: 내 근처 킥보드 주차장 찾기 API 구현
Jang99u May 3, 2024
fdbc061
Fix: BoardingRecord 도메인 수정
Jang99u May 5, 2024
0db2509
Feat: Spring Security, JWT Cookie, 소셜 로그인 기능 구현
JeongHeumChoi May 5, 2024
83b0ab5
Feat: Spring Security, JWT Cookie, 소셜 로그인 기능 구현
JeongHeumChoi May 5, 2024
f29ef02
Fix: 코드 에러 수정
JeongHeumChoi May 5, 2024
31f231e
Refactor: 아직 사용하지 않는 코드 삭제
JeongHeumChoi May 5, 2024
4810467
Feat: oauth2 의존성 추가
JeongHeumChoi May 6, 2024
bdc6b6d
Chore: Credentials 추가
JeongHeumChoi May 6, 2024
1236819
Merge pull request #12 from JeongHeumChoi/feature/#5
JeongHeumChoi May 6, 2024
e1e1dc6
✨ [Feature] - 서버 날짜 설정 및 유저 닉네임 설정 (#15)
JeongHeumChoi May 6, 2024
476770b
Merge branch 'main' into dev
JeongHeumChoi May 6, 2024
a681714
Fix: nickname 에러 수정 (#18)
JeongHeumChoi May 6, 2024
02ad9a0
Merge branch 'main' into dev
JeongHeumChoi May 6, 2024
4a095b0
Merge pull request #20 from Jang99u/feature/10
Jang99u May 6, 2024
5895a77
Fix: BoardingRecord 도메인 수정
Jang99u May 6, 2024
e78c912
Merge branch 'dev' into dev
Jang99u May 6, 2024
67927ba
Merge pull request #21 from Jang99u/dev
Jang99u May 6, 2024
2facd1e
Feat: 디펜던시 추가
Jang99u May 6, 2024
d25eb02
Feat: ErrorCode 추가
Jang99u May 6, 2024
a8e20f0
Feat: Image API 구현
Jang99u May 6, 2024
74a58ee
Feat: WebClientConfig 구현
Jang99u May 6, 2024
d342989
Feat: S3ClientConfig 구현
Jang99u May 6, 2024
865eadc
Feat: BoardingRecord API 구현
Jang99u May 6, 2024
328b74a
Feat: 주차장 예측 결과 관련 기능 추가
Jang99u May 6, 2024
13712d2
Feat: 탑승 기록 저장 API 구현
Jang99u May 6, 2024
9c52bc2
Merge pull request #23 from Jang99u/feature/9
Jang99u May 6, 2024
e0ee004
Fix: 디렉토리 경로 수정
Jang99u May 7, 2024
f29d0b8
Merge pull request #24 from Jang99u/feature/9
Jang99u May 7, 2024
193d9a7
Feat: 코드 리팩터링 진행
Jang99u May 7, 2024
45f55ec
Merge pull request #27 from Jang99u/dev
Jang99u May 7, 2024
a3aca24
Chore: Credentials 수정 (#29)
JeongHeumChoi May 8, 2024
a537187
!HOTFIX: 서브 모듈 컨플릭트 해결
JeongHeumChoi May 8, 2024
001b632
✨ [Feature] - Reissue 토큰 기능 추가 (#31)
JeongHeumChoi May 8, 2024
179a774
Merge branch 'main' into dev
JeongHeumChoi May 8, 2024
702f10b
Fix: JsonProperty 추가
Jang99u May 8, 2024
3456ff2
Merge pull request #33 from Jang99u/dev
Jang99u May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/main/java/ice/spot/controller/AuthController.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package ice.spot.controller;

import ice.spot.annotation.UserId;
import ice.spot.constant.Constants;
import ice.spot.dto.global.ResponseDto;
import ice.spot.dto.request.OauthSignUpDto;
import ice.spot.dto.response.JwtTokenDto;
import ice.spot.exception.CommonException;
import ice.spot.exception.ErrorCode;
import ice.spot.service.AuthService;
import ice.spot.util.CookieUtil;
import ice.spot.util.HeaderUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -17,11 +26,31 @@
@RequiredArgsConstructor
public class AuthController {

@Value("${server.domain}")
private String domain;

private final AuthService authService;

@PostMapping("/oauth2/sign-up")
public ResponseDto<?> signUp(@UserId Long userId, @RequestBody OauthSignUpDto oauthSignUpDto) {
authService.signUp(userId, oauthSignUpDto);
return ResponseDto.ok(null);
}

@PostMapping("/auth/reissue")
public ResponseDto<?> reissue(
HttpServletRequest request,
HttpServletResponse response,
@UserId Long userId){
log.info("controller 진입 성공");
String refreshToken = HeaderUtil.refineHeader(request, Constants.PREFIX_AUTH, Constants.PREFIX_BEARER)
.orElseThrow(() -> new CommonException(ErrorCode.INVALID_HEADER_VALUE));
log.info("헤더값 조회 성공");
JwtTokenDto jwtTokenDto = authService.reGenerateTokens(userId, refreshToken);

CookieUtil.addCookie(response, domain, Constants.ACCESS_COOKIE_NAME, jwtTokenDto.accessToken());
CookieUtil.addSecureCookie(response, domain, Constants.REFRESH_COOKIE_NAME, jwtTokenDto.refreshToken(), 60 * 60 * 24 * 14);

return ResponseDto.ok(jwtTokenDto);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package ice.spot.dto.boardingrecord.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import ice.spot.dto.user.response.PersonResponse;
import lombok.Builder;

import java.util.List;

@Builder
public record BoardingRecordListResponse(
@JsonProperty("person")
PersonResponse personResponse,

@JsonProperty("records")
List<BoardingRecordResponse> boardingRecordResponseList
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ice.spot.dto.parkingLot.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;

import java.util.List;

@Builder
public record ParkingLotResponseList(
@JsonProperty("parkingLotList")
List<ParkingLotResponse> parkingLotResponseList
) {
public static ParkingLotResponseList of(final List<ParkingLotResponse> parkingLotResponse) {
return ParkingLotResponseList.builder()
.parkingLotResponseList(parkingLotResponse)
.build();
}
}
14 changes: 14 additions & 0 deletions src/main/java/ice/spot/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import ice.spot.domain.User;
import ice.spot.dto.request.OauthSignUpDto;
import ice.spot.dto.response.JwtTokenDto;
import ice.spot.exception.CommonException;
import ice.spot.exception.ErrorCode;
import ice.spot.repository.UserRepository;
import ice.spot.util.JwtUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -16,6 +18,7 @@
public class AuthService {

private final UserRepository userRepository;
private final JwtUtil jwtUtil;

@Transactional
public void signUp(Long userId, OauthSignUpDto oauthSignUpDto){
Expand All @@ -25,4 +28,15 @@ public void signUp(Long userId, OauthSignUpDto oauthSignUpDto){
oauthUser.register(oauthSignUpDto.nickname());
}

@Transactional
public JwtTokenDto reGenerateTokens(Long userId, String refreshToken){
log.info("re generate tokens 진입성공");
User loginUser = userRepository.findByIdAndRefreshToken(userId, refreshToken)
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_USER));
log.info("유저 조회 성공");
JwtTokenDto jwtTokenDto = jwtUtil.generateTokens(loginUser.getId(), loginUser.getRole());

loginUser.updateRefreshToken(jwtTokenDto.refreshToken());
return jwtTokenDto;
}
}
5 changes: 3 additions & 2 deletions src/main/java/ice/spot/service/ParkingLotService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ice.spot.service;

import ice.spot.dto.parkingLot.response.ParkingLotResponse;
import ice.spot.dto.parkingLot.response.ParkingLotResponseList;
import ice.spot.repository.ParkingLotRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -19,7 +20,7 @@ public class ParkingLotService {
private final ParkingLotRepository parkingLotRepository;

@Transactional(readOnly = true)
public List<ParkingLotResponse> parkingLotList(Double lat, Double lon) {
public ParkingLotResponseList parkingLotList(Double lat, Double lon) {

List<ParkingLotResponse> parkingLotResponseList = new ArrayList<>(parkingLotRepository.findAll().stream()
.map(parkingLot -> ParkingLotResponse.builder()
Expand All @@ -41,6 +42,6 @@ public int compare(ParkingLotResponse o1, ParkingLotResponse o2) {
}
});

return parkingLotResponseList.subList(0, 5);
return ParkingLotResponseList.of(parkingLotResponseList.subList(0, 5));
}
}