Skip to content

Commit

Permalink
1.controller string > dto변경
Browse files Browse the repository at this point in the history
2.springmocktest제거
3.멤버쉽api가입/탈퇴 추가 필요 정리
  • Loading branch information
kohbyeongchan committed Oct 30, 2024
1 parent f3f9395 commit a948d9a
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 231 deletions.
4 changes: 2 additions & 2 deletions app-main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ repositories {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
implementation 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
public class AuthController {
//회원가입 api
@PostMapping("/register")
public String register(@RequestBody UserDto userDto) {
return "회원가입 성공 " + userDto.getName();
public UserDto register(@RequestBody UserDto userDto) {
return userDto;
}

//로그인 api
@PostMapping("/login")
public String login(@RequestBody UserDto userDto) {
return "로그인 성공 " + userDto.getEmail();
public UserDto login(@RequestBody UserDto userDto) {
return userDto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ public class ReservationController {

//예매완료 api
@PostMapping("/complete")
public String completeReservation(@RequestBody ReservationDto reservationDto) {
return "예매 성공 ID: " + reservationDto.getReservationId();
public ReservationDto completeReservation(@RequestBody ReservationDto reservationDto) {
return reservationDto;
}

//예매취소 api
// 예매 취소 API
@PostMapping("/cancel")
public String cancelReservation(@RequestParam int reservationId) {
return "예매 ID " + reservationId + " 취소 완료";
public ReservationDto cancelReservation(@RequestParam int reservationId) {
// 취소 후 ID만 포함한 ReservationDto 반환
ReservationDto reservationDto = new ReservationDto();
reservationDto.setReservationId(reservationId);
return reservationDto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,29 @@
@RequestMapping("/seats")
public class SeatSelectionController {

// 자동 좌석 배정 api

// 자동 좌석 배정 API
@PostMapping("/auto-assign")
public String autoAssignSeats(@RequestBody SeatSelectionDto seatSelectionDto) {
return "자동 좌석 선택 완료: " + seatSelectionDto.getSeatCount() + "개 좌석 배정";
public SeatSelectionDto autoAssignSeats(@RequestBody SeatSelectionDto seatSelectionDto) {
// 요청받은 좌석 정보 그대로 반환
return seatSelectionDto;
}

// 수동 좌석 선택 api
// 수동 좌석 선택 API
@PostMapping("/select")
public String selectSeats(@RequestBody SeatSelectionDto seatSelectionDto) {
return "수동 좌석 선택 완료: 좌석 ID " + Arrays.toString(seatSelectionDto.getSeatIds());
public SeatSelectionDto selectSeats(@RequestBody SeatSelectionDto seatSelectionDto) {
// 요청받은 좌석 정보 그대로 반환
return seatSelectionDto;
}

// 선예매 권한 확인 api
// 예매 권한을 자동 좌석 과 수동 좌석에서 추가 검증하는 로직 추가 필요
// 멤버쉽 가입 및 탈퇴 api 추가 필요
@GetMapping("/vip-access")
public String checkVIPAccess(@RequestParam UserType userType) {
if (userType == UserType.VIP) {
return "선예매 유저입니다.";
} else {
return "현재 선예매유저만 접근이 가능합니다.";
}

public SeatSelectionDto checkVIPAccess(@RequestParam UserType userType) {
SeatSelectionDto seatSelectionDto = new SeatSelectionDto();
seatSelectionDto.setVipAccess(userType == UserType.VIP); // VIP 접근 가능 여부 설정
return seatSelectionDto;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ public class SeatSelectionDto {
private int sectionId; // 선택한 좌석 구역 ID
private int seatCount; // 자동 좌석 배정 시 좌석 수
private int[] seatIds; // 수동 좌석 선택 시 선택한 좌석 ID 리스트
private boolean vipAccess; // VIP 접근 권한 여부 필드

public boolean isVipAccess() {
return vipAccess;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,54 @@ public class SeatSelectionControllerIntegrationTest {
@Test
public void testAutoAssignSeats() {
// given
SeatSelectionDto requestDto = new SeatSelectionDto(1,2,3, null);
HttpEntity<SeatSelectionDto> request = new HttpEntity<>(requestDto);
SeatSelectionDto seatSelectionDto = new SeatSelectionDto();
seatSelectionDto.setSeatCount(3);

// when
ResponseEntity<String> response = restTemplate.postForEntity("/seats/auto-assign", request, String.class);
ResponseEntity<SeatSelectionDto> response = restTemplate.postForEntity("/seats/auto-assign", seatSelectionDto, SeatSelectionDto.class);

// then
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody()).contains("자동 좌석 선택 완료: 3개 좌석 배정");
assertThat(response.getBody().getSeatCount()).isEqualTo(3);
}

@Test
public void testSelectSeats() {
// given
SeatSelectionDto requestDto = new SeatSelectionDto(0,0,0, new int[]{101, 102, 103});
HttpEntity<SeatSelectionDto> request = new HttpEntity<>(requestDto);
SeatSelectionDto seatSelectionDto = new SeatSelectionDto();
seatSelectionDto.setSeatIds(new int[]{101, 102, 103});

// when
ResponseEntity<String> response = restTemplate.postForEntity("/seats/select", request, String.class);
ResponseEntity<SeatSelectionDto> response = restTemplate.postForEntity("/seats/select", seatSelectionDto, SeatSelectionDto.class);

// then
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody()).contains("수동 좌석 선택 완료: 좌석 ID [101, 102, 103]");
assertThat(response.getBody().getSeatIds()).containsExactly(101, 102, 103);
}

@Test
public void testCheckVIPAccess() {
public void testCheckVIPAccess_VIPUser() {
// given
String url = "/seats/vip-access?userType=VIP";

// when
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
ResponseEntity<SeatSelectionDto> response = restTemplate.getForEntity(url, SeatSelectionDto.class);

// then
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody()).isEqualTo("선예매 유저입니다.");
assertThat(response.getBody().isVipAccess()).isTrue();
}

@Test
public void testCheckVIPAccess_RegularUser() {
// given
String url = "/seats/vip-access?userType=REGULAR";

// when
ResponseEntity<SeatSelectionDto> response = restTemplate.getForEntity(url, SeatSelectionDto.class);

// then
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody().isVipAccess()).isFalse();
}
}

This file was deleted.

0 comments on commit a948d9a

Please sign in to comment.