Compare commits
6 Commits
feature/ch
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fed37f10db | ||
|
|
35ed1c0130 | ||
|
|
3637580500 | ||
|
|
f6005ac1ae | ||
|
|
b31ef62253 | ||
|
|
af9c5bab9c |
10
README.md
10
README.md
@@ -49,7 +49,6 @@ erDiagram
|
||||
bigint id PK "영화 ID"
|
||||
varchar title "영화제목"
|
||||
int running_time "러닝타임"
|
||||
datetime deleted_at "삭제일시"
|
||||
datetime created_at "등록일시"
|
||||
datetime updated_at "수정일시"
|
||||
}
|
||||
@@ -59,7 +58,6 @@ erDiagram
|
||||
bigint id PK "상영관 ID"
|
||||
int theater_number "상영관 번호"
|
||||
int seat_count "좌석수"
|
||||
datetime deleted_at "삭제일시"
|
||||
datetime created_at "등록일시"
|
||||
datetime updated_at "수정일시"
|
||||
}
|
||||
@@ -69,7 +67,6 @@ erDiagram
|
||||
bigint theater_id FK "상영관 ID"
|
||||
int column "열"
|
||||
int row "행"
|
||||
datetime deleted_at "삭제일시"
|
||||
datetime created_at "등록일시"
|
||||
datetime updated_at "수정일시"
|
||||
}
|
||||
@@ -81,7 +78,6 @@ erDiagram
|
||||
int round "회차"
|
||||
time start_at "시작 시간"
|
||||
time end_at "종료 시간"
|
||||
datetime deleted_at "삭제일시"
|
||||
datetime created_at "등록일시"
|
||||
datetime updated_at "수정일시"
|
||||
}
|
||||
@@ -92,33 +88,31 @@ erDiagram
|
||||
bigint payment_id "결제 ID"
|
||||
varchar status "상태 - 구매가능/예약진행중/판매완료"
|
||||
int ticket_price "가격"
|
||||
datetime deleted_at "삭제일시"
|
||||
datetime created_at "등록일시"
|
||||
datetime updated_at "수정일시"
|
||||
}
|
||||
TICKET }|--|| PAYMENT : ""
|
||||
PAYMENT {
|
||||
bigint id PK "결제 ID"
|
||||
bigint user_alternate_id "유저 대체ID"
|
||||
bigint user_id "유저ID"
|
||||
varchar movie_title "영화제목"
|
||||
varchar type "결제 타입 - 예) 네이버페이, 카카오페이"
|
||||
varchar status "상태 - 완료/환불/실패"
|
||||
varchar failed_message "실패사유 - 컬럼명을 알아보기 쉬운가?"
|
||||
varchar payment_number "예매번호"
|
||||
int total_price "결제 금액"
|
||||
datetime deleted_at "삭제일시"
|
||||
datetime created_at "결제일시"
|
||||
datetime updated_at "수정일시"
|
||||
}
|
||||
USER ||--o{ PAYMENT : ""
|
||||
USER {
|
||||
bigint id "회원"
|
||||
bigint alternate_id "대체ID"
|
||||
varchar name "이름"
|
||||
varchar email "이메일"
|
||||
varchar password "비밀번호"
|
||||
varchar grade "등급 - 고객/임직원"
|
||||
varchar phone "휴대폰 번호"
|
||||
boolean is_deleted "탈퇴여부"
|
||||
datetime deleted_at "탈퇴일시"
|
||||
datetime created_at "가입일시"
|
||||
datetime updated_at "수정일시"
|
||||
|
||||
@@ -17,7 +17,6 @@ public enum ErrorCode {
|
||||
MISMATCH_PASSWORD(BAD_REQUEST, "비밀번호가 일치하지 않습니다."),
|
||||
TOKEN_TYPE(BAD_REQUEST, "토큰 타입이 올바르지 않습니다."),
|
||||
UNAVAILABLE_REFRESH_TOKEN(BAD_REQUEST, "사용할 수 없는 토큰 입니다."),
|
||||
UNABLE_CHANGE_GRADE(BAD_REQUEST, "동일한 등급으로 변경할 수 없습니다."),
|
||||
|
||||
/* 403 FORBIDDEN : 접근 권한 제한 */
|
||||
VALID_USER_ID(FORBIDDEN, "해당 정보에 접근 권한이 존재하지 않습니다."),
|
||||
@@ -51,10 +50,6 @@ public enum ErrorCode {
|
||||
throw new TicketingException(UNAVAILABLE_REFRESH_TOKEN);
|
||||
}
|
||||
|
||||
public static TicketingException throwUnableChangeGrade() {
|
||||
throw new TicketingException(UNABLE_CHANGE_GRADE);
|
||||
}
|
||||
|
||||
/* 403 FORBIDDEN : 접근 권한 제한 */
|
||||
public static TicketingException throwValidUserId() {
|
||||
throw new TicketingException(VALID_USER_ID);
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.ticketing.server.user.application;
|
||||
|
||||
import com.ticketing.server.user.domain.UserGrade;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class UserChangeGradeResponse {
|
||||
|
||||
private String email;
|
||||
|
||||
private UserGrade beforeGrade;
|
||||
|
||||
private UserGrade afterGrade;
|
||||
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
package com.ticketing.server.user.application;
|
||||
|
||||
import static com.ticketing.server.user.domain.UserGrade.ROLES.ADMIN;
|
||||
import static com.ticketing.server.user.domain.UserGrade.ROLES.USER;
|
||||
|
||||
import com.ticketing.server.user.application.request.SignUpRequest;
|
||||
import com.ticketing.server.user.application.request.UserChangeGradeRequest;
|
||||
import com.ticketing.server.user.application.request.UserChangePasswordRequest;
|
||||
import com.ticketing.server.user.application.request.UserDeleteRequest;
|
||||
import com.ticketing.server.user.application.response.PaymentsResponse;
|
||||
@@ -12,8 +8,8 @@ import com.ticketing.server.user.application.response.SignUpResponse;
|
||||
import com.ticketing.server.user.application.response.UserChangePasswordResponse;
|
||||
import com.ticketing.server.user.application.response.UserDeleteResponse;
|
||||
import com.ticketing.server.user.application.response.UserDetailResponse;
|
||||
import com.ticketing.server.user.domain.ChangeGradeDTO;
|
||||
import com.ticketing.server.user.domain.User;
|
||||
import com.ticketing.server.user.domain.UserGrade;
|
||||
import com.ticketing.server.user.service.dto.UserDetailDTO;
|
||||
import com.ticketing.server.user.service.interfaces.UserApisService;
|
||||
import com.ticketing.server.user.service.interfaces.UserService;
|
||||
@@ -51,21 +47,21 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
@Secured(USER)
|
||||
@Secured(UserGrade.ROLES.USER)
|
||||
public ResponseEntity<UserDetailResponse> details(@AuthenticationPrincipal UserDetails userRequest) {
|
||||
UserDetailDTO userDetail = userService.findDetailByEmail(userRequest.getUsername());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(userDetail.toResponse());
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Secured(USER)
|
||||
@Secured(UserGrade.ROLES.USER)
|
||||
public ResponseEntity<UserDeleteResponse> deleteUser(@RequestBody @Valid UserDeleteRequest request) {
|
||||
User user = userService.delete(request.toDeleteUserDto(passwordEncoder));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(UserDeleteResponse.from(user));
|
||||
}
|
||||
|
||||
@PutMapping("/password")
|
||||
@Secured(USER)
|
||||
@Secured(UserGrade.ROLES.USER)
|
||||
public ResponseEntity<UserChangePasswordResponse> changePassword(
|
||||
@AuthenticationPrincipal UserDetails userRequest,
|
||||
@RequestBody @Valid UserChangePasswordRequest request) {
|
||||
@@ -73,15 +69,8 @@ public class UserController {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(UserChangePasswordResponse.from(user));
|
||||
}
|
||||
|
||||
@PostMapping("/grade")
|
||||
@Secured(ADMIN)
|
||||
public ResponseEntity<UserChangeGradeResponse> changeGrade(@RequestBody @Valid UserChangeGradeRequest request) {
|
||||
ChangeGradeDTO changeGradeDto = userService.changeGrade(request.getEmail(), request.getAfterGrade());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(changeGradeDto.toResponse());
|
||||
}
|
||||
|
||||
@GetMapping("/payments")
|
||||
@Secured(USER)
|
||||
@Secured(UserGrade.ROLES.USER)
|
||||
public ResponseEntity<PaymentsResponse> getPayments(@AuthenticationPrincipal UserDetails userRequest) {
|
||||
PaymentsResponse paymentDetails = userApisService.findPaymentsByEmail(userRequest.getUsername());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(paymentDetails);
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.ticketing.server.user.application.request;
|
||||
|
||||
import com.ticketing.server.user.domain.UserGrade;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class UserChangeGradeRequest {
|
||||
|
||||
@NotEmpty(message = "{validation.not.empty.email}")
|
||||
@Email(message = "{validation.email}")
|
||||
private String email;
|
||||
|
||||
@NotNull(message = "{validation.not.null.grade}")
|
||||
private UserGrade afterGrade;
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.ticketing.server.user.domain;
|
||||
|
||||
import com.ticketing.server.user.application.UserChangeGradeResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class ChangeGradeDTO {
|
||||
|
||||
private final String email;
|
||||
private final UserGrade beforeGrade;
|
||||
private final UserGrade afterGrade;
|
||||
|
||||
public UserChangeGradeResponse toResponse() {
|
||||
return new UserChangeGradeResponse(email, beforeGrade, afterGrade);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,14 +93,4 @@ public class User extends AbstractEntity {
|
||||
}
|
||||
}
|
||||
|
||||
public ChangeGradeDTO changeGrade(UserGrade afterGrade) {
|
||||
if (grade.equals(afterGrade)) {
|
||||
throw ErrorCode.throwUnableChangeGrade();
|
||||
}
|
||||
final UserGrade beforeGrade = this.grade;
|
||||
|
||||
this.grade = afterGrade;
|
||||
return new ChangeGradeDTO(email, beforeGrade, afterGrade);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.ticketing.server.user.service;
|
||||
|
||||
import com.ticketing.server.global.exception.ErrorCode;
|
||||
import com.ticketing.server.user.domain.ChangeGradeDTO;
|
||||
import com.ticketing.server.user.domain.SequenceGenerator;
|
||||
import com.ticketing.server.user.domain.User;
|
||||
import com.ticketing.server.user.domain.UserGrade;
|
||||
import com.ticketing.server.user.domain.repository.UserRepository;
|
||||
import com.ticketing.server.user.service.dto.ChangePasswordDTO;
|
||||
import com.ticketing.server.user.service.dto.DeleteUserDTO;
|
||||
@@ -55,13 +53,6 @@ public class UserServiceImpl implements UserService {
|
||||
return user.changePassword(changePasswordDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ChangeGradeDTO changeGrade(@NotNull String email, @NotNull UserGrade grade) {
|
||||
User user = findNotDeletedUserByEmail(email);
|
||||
return user.changeGrade(grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetailDTO findDetailByEmail(@NotNull String email) {
|
||||
User user = userRepository.findByEmail(email)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.ticketing.server.user.service.interfaces;
|
||||
|
||||
import com.ticketing.server.user.domain.ChangeGradeDTO;
|
||||
import com.ticketing.server.user.domain.User;
|
||||
import com.ticketing.server.user.domain.UserGrade;
|
||||
import com.ticketing.server.user.service.dto.ChangePasswordDTO;
|
||||
import com.ticketing.server.user.service.dto.DeleteUserDTO;
|
||||
import com.ticketing.server.user.service.dto.SignUpDTO;
|
||||
import com.ticketing.server.user.service.dto.UserDetailDTO;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
@@ -19,9 +16,6 @@ public interface UserService {
|
||||
|
||||
User changePassword(@Valid ChangePasswordDTO changePasswordDto);
|
||||
|
||||
@Transactional
|
||||
ChangeGradeDTO changeGrade(@NotNull String email, @NotNull UserGrade grade);
|
||||
|
||||
UserDetailDTO findDetailByEmail(@NotNull String email);
|
||||
|
||||
User findNotDeletedUserByEmail(@NotNull String email);
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.ticketing.server.user.domain;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
|
||||
import com.ticketing.server.global.exception.ErrorCode;
|
||||
import com.ticketing.server.global.exception.TicketingException;
|
||||
import com.ticketing.server.user.service.dto.ChangePasswordDTO;
|
||||
import com.ticketing.server.user.service.dto.DeleteUserDTO;
|
||||
@@ -35,37 +33,6 @@ public class UserTest {
|
||||
users = provideCorrectUsers().collect(Collectors.toMap(User::getEmail, user -> user));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("동일한 권한으로 변경 시 예외처리")
|
||||
void changeGradeFail() {
|
||||
// given
|
||||
User user = users.get("ticketing1@gmail.com");
|
||||
|
||||
// when
|
||||
// then
|
||||
assertThatThrownBy(() -> user.changeGrade(UserGrade.USER))
|
||||
.isInstanceOf(TicketingException.class)
|
||||
.extracting("errorCode")
|
||||
.isEqualTo(ErrorCode.UNABLE_CHANGE_GRADE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("권한 변경 성공")
|
||||
void changeGradeSuccess() {
|
||||
// given
|
||||
User user = users.get("ticketing1@gmail.com");
|
||||
|
||||
// when
|
||||
ChangeGradeDTO changeGradeDto = user.changeGrade(UserGrade.ADMIN);
|
||||
|
||||
// then
|
||||
assertAll(
|
||||
() -> assertThat(changeGradeDto.getEmail()).isEqualTo("ticketing1@gmail.com"),
|
||||
() -> assertThat(changeGradeDto.getBeforeGrade()).isEqualTo(UserGrade.USER),
|
||||
() -> assertThat(changeGradeDto.getAfterGrade()).isEqualTo(UserGrade.ADMIN)
|
||||
);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideDifferentPasswordDeleteUsers")
|
||||
@DisplayName("입력된 패스워드가 다를 경우")
|
||||
|
||||
Reference in New Issue
Block a user