-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 회원 전체 코드 리팩토링 - 회원 요청 DTO 내부 클래스화 - 특정 컨트롤러 메소드 권한 설정 Related to: #95
- Loading branch information
1 parent
5016341
commit 4b30314
Showing
17 changed files
with
376 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/prgrms2/java/bitta/member/controller/advice/MemberControllerAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.prgrms2.java.bitta.member.controller.advice; | ||
|
||
import com.prgrms2.java.bitta.member.exception.MemberTaskException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.authorization.AuthorizationDeniedException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
import java.util.Map; | ||
|
||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class MemberControllerAdvice { | ||
@ExceptionHandler(AuthorizationDeniedException.class) | ||
public ResponseEntity<?> handleArgsException(AuthorizationDeniedException e) { | ||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED) | ||
.body(Map.of("error", "해당 리소스에 대한 권한이 없습니다.")); | ||
} | ||
|
||
@ExceptionHandler(MemberTaskException.class) | ||
public ResponseEntity<?> handleArgsException(MemberTaskException e) { | ||
return ResponseEntity.status(e.getCode()) | ||
.body(Map.of("error", e.getMessage())); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/com/prgrms2/java/bitta/member/dto/MemberRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.prgrms2.java.bitta.member.dto; | ||
|
||
import com.prgrms2.java.bitta.member.entity.Role; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.*; | ||
|
||
@Schema(title = "회원 요청 DTO", description = "회원 관련 요청에 사용하는 DTO입니다.") | ||
public class MemberRequestDto { | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Schema(title = "로그인 DTO", description = "로그인 요청에 사용하는 DTO입니다.") | ||
public static class Login { | ||
@Schema(title = "아이디", description = "로그인에 사용할 아이디입니다.", example = "username") | ||
private String username; | ||
|
||
@Schema(title = "비밀번호", description = "로그인에 사용할 비밀번호입니다.", example = "password") | ||
private String password; | ||
} | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Schema(title = "회원가입 DTO", description = "회원가입 요청에 사용하는 DTO입니다.") | ||
public static class Register { | ||
@Schema(title = "아이디", description = "회원가입에 사용할 아이디입니다.", example = "username") | ||
private String username; | ||
|
||
@Schema(title = "비밀번호", description = "회원가입에 사용할 비밀번호입니다.", example = "password") | ||
private String password; | ||
|
||
@Schema(title = "별명", description = "회원가입에 사용할 별명입니다.", example = "nickname") | ||
private String nickname; | ||
|
||
@Schema(title = "주소", description = "회원의 주소입니다.", example = "경기도 고양시 일산동구 중앙로 1256") | ||
private String address; | ||
|
||
@Builder.Default | ||
@Schema(title = "회원 권한", description = "회원이 갖는 액세스 권한입니다.", example = "USER") | ||
private Role role = Role.USER; | ||
} | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Schema(title = "비밀번호 변경 DTO", description = "비밀번호 변경 요청에 사용하는 DTO입니다.") | ||
public static class ChangePassword { | ||
@Schema(title = "회원 ID (PK)", description = "변경할 회원의 기본키입니다.", example = "1") | ||
private Long id; | ||
|
||
@Schema(title = "이전 비밀번호", description = "이전에 사용하던 비밀번호입니다.", example = "password1") | ||
private String beforePassword; | ||
|
||
@Schema(title = "새로운 비밀번호", description = "새롭게 변경할 비밀번호입니다.", example = "password1") | ||
private String afterPassword; | ||
} | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Schema(title = "회원정보 변경 DTO", description = "회원정보 변경 요청에 사용하는 DTO입니다.") | ||
public static class Modify { | ||
@Schema(title = "회원 ID (PK)", description = "변경할 회원의 기본키입니다.", example = "1") | ||
private Long id; | ||
|
||
@Schema(title = "아이디", description = "비밀번호를 변경할 아이디입니다.", example = "username") | ||
private String username; | ||
|
||
@Schema(title = "새로운 별명", description = "새롭게 변경할 별명입니다.", example = "nickname") | ||
private String nickname; | ||
|
||
@Schema(title = "새로운 주소", description = "새롭게 변경할 회원의 주소입니다.", example = "경기도 고양시 일산동구 중앙로 1256") | ||
private String address; | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
src/main/java/com/prgrms2/java/bitta/member/dto/SignInDTO.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.