-
Notifications
You must be signed in to change notification settings - Fork 2
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
회원 정보 수정, 삭제 리팩토링 #134
회원 정보 수정, 삭제 리팩토링 #134
Changes from 6 commits
eee1655
82aef00
cd3bea8
68d4731
6fad4ca
be85105
252a758
9aed039
c24b3fa
338f600
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package balancetalk.global.jwt; | ||
|
||
public class JwtUtils { | ||
|
||
// TODO: static으로 메서드 선언 & member 조회 까지 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package balancetalk.module.member.dto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class TokenDto { | ||
private String grantType; | ||
private String accessToken; | ||
private String refreshToken; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
package balancetalk.module.member.presentation; | ||
|
||
import balancetalk.global.jwt.JwtTokenProvider; | ||
import balancetalk.module.member.application.MemberService; | ||
import balancetalk.module.member.dto.*; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@Tag(name = "member", description = "회원 API") | ||
@RequestMapping("/members") | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
@ResponseStatus(HttpStatus.CREATED) | ||
@PostMapping("/join") | ||
@Operation(summary = "회원 가입", description = "닉네임, 이메일, 비밀번호를 입력하여 회원 가입을 한다.") | ||
|
@@ -37,40 +39,41 @@ public LoginSuccessDto login(@Valid @RequestBody LoginDto loginDto) { | |
} | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/{memberId}") | ||
@Operation(summary = "단일 회원 조회", description = "해당 id값과 일치하는 회원 정보를 조회한다.") | ||
public MemberResponseDto findMemberInfo(@PathVariable("memberId") Long memberId) { | ||
return memberService.findById(memberId); | ||
@GetMapping("/find") | ||
@Operation(summary = "단일 회원 조회", description = "해당 jwt 토큰 값과 일치하는 회원 정보를 조회한다.") | ||
public MemberResponseDto findMemberInfo(HttpServletRequest request) { | ||
return memberService.findMember(request); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 회원 단건 조회 같은 경우는 사용자 본인이 아닌 타 사용자가 조회할 때 사용하는 API라서 memberId를 직접 전달 받아 조회해야 하지 않을까요?? |
||
} | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping | ||
@GetMapping("/findAll") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 회원 목록 조회 API의 경우 URL은 "/members"로도 충분해보입니다! |
||
@Operation(summary = "전체 회원 조회", description = "모든 회원 정보를 조회한다.") | ||
public List<MemberResponseDto> findAllMemberInfo() { | ||
return memberService.findAll(); | ||
} | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@PutMapping("/nickname/{memberId}") | ||
@PutMapping("/update/nickname") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 수정 API를 포함해 삭제 등 모든 API는 메서드를 통해서 CRUD의 성격을 알 수 있습니다. |
||
@Operation(summary = "회원 닉네임 수정", description = "회원 닉네임을 수정한다.") | ||
public String updateNickname(@PathVariable("memberId") Long memberId, @Valid @RequestBody NicknameUpdate nicknameUpdate) { | ||
memberService.updateNickname(memberId, nicknameUpdate); | ||
public String updateNickname(@Valid @RequestBody NicknameUpdate nicknameUpdate, HttpServletRequest request) { | ||
memberService.updateNickname(nicknameUpdate, request); | ||
return "회원 닉네임이 변경되었습니다."; | ||
} | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@PutMapping("/{memberId}") | ||
@PutMapping("/update/password") | ||
@Operation(summary = "회원 비밀번호 수정", description = "회원 패스워드를 수정한다.") | ||
public String updatePassword(@PathVariable("memberId") Long memberId, @Valid @RequestBody PasswordUpdate passwordUpdate) { | ||
memberService.updatePassword(memberId, passwordUpdate); | ||
public String updatePassword(@Valid @RequestBody PasswordUpdate passwordUpdate, HttpServletRequest request) { | ||
memberService.updatePassword(passwordUpdate, request); | ||
return "회원 비밀번호가 변경되었습니다."; | ||
} | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@DeleteMapping("/{memberId}") | ||
@DeleteMapping("/delete") | ||
@Operation(summary = "회원 삭제", description = "해당 id값과 일치하는 회원 정보를 삭제한다.") | ||
public String deleteMember(@PathVariable("memberId") Long memberId, @Valid @RequestBody LoginDto loginDto) { | ||
memberService.delete(memberId, loginDto); | ||
public String deleteMember(@Valid @RequestBody LoginDto loginDto, HttpServletRequest request) { | ||
memberService.delete(loginDto, request); | ||
return "회원 탈퇴가 정상적으로 처리되었습니다."; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 파일은 어떤 작업이 이루어진걸까요???🤔