Skip to content

Commit

Permalink
Merge pull request #51 from HanaFun/feat/category
Browse files Browse the repository at this point in the history
feat: 마이페이지 출력 userId-> 토큰 받아오도록 변경
  • Loading branch information
yubin-im authored Jul 3, 2024
2 parents d7b592e + e1c148e commit c459f2d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.hanaro.hanafun.reservation.service.ReservationService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.util.List;
Expand All @@ -18,8 +19,8 @@ public class ReservationController {

// 마이페이지 데이터 출력
@GetMapping("/my")
public ResponseEntity<ApiResponse> myPage(@RequestBody MyPageReqDto myPageReqDto) {
MyPageResDto myPageResDto = reservationService.myPage(myPageReqDto);
public ResponseEntity<ApiResponse> myPage(@AuthenticationPrincipal Long userId) {
MyPageResDto myPageResDto = reservationService.myPage(userId);
return ResponseEntity.ok(new ApiResponse<>(true, "ok", myPageResDto));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public interface ReservationService {
// 마이페이지 데이터 출력
MyPageResDto myPage(MyPageReqDto myPageReqDto);
MyPageResDto myPage(Long userId);

// 나의 신청 클래스 데이터 출력
List<ReservationList> myLessons(MyPageReqDto myPageReqDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class ReservationServiceImpl implements ReservationService {
// 마이페이지 데이터 출력
@Transactional
@Override
public MyPageResDto myPage(MyPageReqDto myPageReqDto) {
UserEntity user = userRepository.findById(myPageReqDto.getUserId()).orElseThrow(() -> new UserNotFoundException());
public MyPageResDto myPage(Long userId) {
UserEntity user = userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException());
List<ReservationEntity> reservations = reservationRepository.findReservationEntitiesByUserEntity(user);

LocalDate today = LocalDate.now(); // 오늘이후 날짜의 예약만 출력
Expand Down

0 comments on commit c459f2d

Please sign in to comment.