-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 회원 정보 수정 #63
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
[FEAT] 회원 정보 수정 #63
Conversation
…기본 소개글로 반환하는 방향으로 통일
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Walkthrough이번 변경에서는 회원 탈퇴 시 비밀번호 확인 절차가 추가되었고, 기본 프로필 이미지 및 소개글에 대한 기본값 제공이 DTO 레이어에서 처리되도록 리팩토링되었습니다. 또한, 사용자가 좋아요한 게시글 조회 기능이 제거되었으며, 데이터베이스 설정이 MySQL에서 H2로 전환되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller
participant Service
participant Repository
Client->>Controller: 회원 탈퇴 요청(비밀번호 포함)
Controller->>Service: withdraw(member, password)
Service->>Repository: 회원 정보 조회
Service->>Service: 비밀번호 일치 여부 확인
alt 비밀번호 불일치
Service-->>Controller: 예외 발생(INVALID_PASSWORD)
else 비밀번호 일치
Service->>Repository: 회원 탈퇴 처리(isDeleted=true)
Service-->>Controller: 성공 응답
end
Controller-->>Client: 탈퇴 결과 반환
sequenceDiagram
participant Service
participant DTO
Service->>DTO: LoginResponseDto.from(member, token)
DTO->>DTO: 프로필 이미지 URL null 체크 및 기본값 대입
DTO-->>Service: LoginResponseDto 반환
Suggested labels
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
src/main/java/com/example/FixLog/controller/MemberController.java (1)
44-50: 🛠️ Refactor suggestion일관성을 위해 팩토리 메서드 사용을 권장합니다.
MemberInfoResponseDto.from(member)팩토리 메서드를 사용하지 않고 있어 기본값 처리 로직이 중복됩니다. 새로 추가된 팩토리 메서드를 사용하여 일관성을 유지하세요.다음과 같이 수정하는 것을 권장합니다:
-MemberInfoResponseDto responseDto = new MemberInfoResponseDto( - member.getEmail(), - member.getNickname(), - member.getProfileImageUrl(), - member.getBio(), - member.getSocialType() -); +MemberInfoResponseDto responseDto = MemberInfoResponseDto.from(member);
🧹 Nitpick comments (6)
src/main/java/com/example/FixLog/util/DefaultText.java (1)
3-5: 유틸 클래스 개선 제안: 인스턴스화 방지
DefaultText는 상수만을 보유하는 유틸리티 클래스입니다. 인스턴스 생성을 막기 위해final선언과private생성자를 추가하는 것이 좋습니다.src/main/java/com/example/FixLog/util/DefaultImage.java (1)
3-5: 유틸 클래스 개선 제안: 인스턴스화 방지
DefaultImage역시 상수 전용 클래스이므로final선언 및private생성자 추가로 인스턴스 생성 방지를 권장합니다.src/main/resources/application.properties (1)
21-30: 프로파일별 설정 분리 권장
MySQL 설정을 주석 처리하는 대신 Spring 프로파일(application-dev.properties,application-h2.properties)을 활용해 환경별 설정을 분리 관리하면 유지보수가 수월해집니다.src/main/java/com/example/FixLog/FixLogApplication.java (1)
7-8: 주석 정리 제안
//Create_At 어노테이션주석은 모호하므로 삭제하거나 보다 명확한 설명으로 교체하는 것이 좋습니다.src/main/java/com/example/FixLog/controller/MypagePostController.java (1)
36-47: 좋아요 기능 완전 제거를 권장합니다.현재 코드가 주석 처리되어 있어 기능이 비활성화되었습니다. 이 기능을 완전히 제거할 계획이라면 주석 처리된 코드를 삭제하는 것이 좋겠습니다.
다음 diff를 적용하여 주석 처리된 코드를 완전히 제거하세요:
-// // 내가 좋아요한 글 -// @GetMapping("/likes") -// public ResponseEntity<Response<PageResponseDto<MyPostPageResponseDto>>> getLikedPosts( -// @AuthenticationPrincipal UserDetails userDetails, -// @RequestParam(defaultValue = "0") int page, -// @RequestParam(defaultValue = "4") int size, -// @RequestParam(defaultValue = "0") int sort) { -// -// String email = userDetails.getUsername(); -// PageResponseDto<MyPostPageResponseDto> result = mypagePostService.getLikedPosts(email, page, sort, size); -// return ResponseEntity.ok(Response.success("내가 좋아요한 글 보기 성공", result)); -// }src/main/java/com/example/FixLog/dto/WithdrawRequestDto.java (1)
5-8: 비밀번호 필드에 대한 validation 추가를 권장합니다.회원 탈퇴 시 비밀번호 확인용 DTO가 올바르게 구현되었습니다. 보안 강화를 위해 validation 어노테이션 추가를 고려해보세요.
다음과 같이 validation을 추가할 수 있습니다:
package com.example.FixLog.dto; import lombok.Getter; +import jakarta.validation.constraints.NotBlank; @Getter public class WithdrawRequestDto { + @NotBlank(message = "비밀번호는 필수입니다") private String password; }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
src/main/java/com/example/FixLog/FixLogApplication.java(1 hunks)src/main/java/com/example/FixLog/controller/MemberController.java(2 hunks)src/main/java/com/example/FixLog/controller/MypagePostController.java(1 hunks)src/main/java/com/example/FixLog/domain/member/Member.java(2 hunks)src/main/java/com/example/FixLog/dto/WithdrawRequestDto.java(1 hunks)src/main/java/com/example/FixLog/dto/member/LoginResponseDto.java(2 hunks)src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java(2 hunks)src/main/java/com/example/FixLog/service/AuthService.java(1 hunks)src/main/java/com/example/FixLog/service/MemberService.java(2 hunks)src/main/java/com/example/FixLog/service/MypagePostService.java(1 hunks)src/main/java/com/example/FixLog/util/DefaultImage.java(1 hunks)src/main/java/com/example/FixLog/util/DefaultText.java(1 hunks)src/main/resources/application.properties(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/main/java/com/example/FixLog/dto/WithdrawRequestDto.java (1)
src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java (1)
Getter(10-32)
src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java (2)
src/main/java/com/example/FixLog/util/DefaultImage.java (1)
DefaultImage(3-5)src/main/java/com/example/FixLog/util/DefaultText.java (1)
DefaultText(3-5)
src/main/java/com/example/FixLog/dto/member/LoginResponseDto.java (1)
src/main/java/com/example/FixLog/util/DefaultImage.java (1)
DefaultImage(3-5)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (12)
src/main/java/com/example/FixLog/FixLogApplication.java (1)
5-6: JPA Auditing 활성화
@EnableJpaAuditingimport와 애노테이션 추가가 적절하며, 엔티티 생성·수정 시각 자동 관리가 활성화됩니다.src/main/java/com/example/FixLog/service/MypagePostService.java (1)
29-33: 의존성 주입 정비 확인
PostLikeRepository제거 후PostRepository,MemberRepository,ForkRepository만 주입하도록 변경된 것이 적절합니다. 전체 로직에서 올바르게 사용되고 있어 문제 없습니다.src/main/java/com/example/FixLog/domain/member/Member.java (2)
60-61: 주석 업데이트가 적절합니다.주석이 변경된 로직을 정확하게 반영하고 있습니다.
87-87: 기본 이미지 처리 로직 개선이 잘 이루어졌습니다.도메인 객체에서 null로 저장하고 DTO 레이어에서 기본값을 처리하는 방식은 관심사 분리 원칙에 잘 부합합니다. 주석도 변경 의도를 명확하게 설명하고 있습니다.
src/main/java/com/example/FixLog/service/AuthService.java (1)
32-33: 정적 팩토리 메소드를 사용한 리팩토링이 적절합니다.기존의 인라인 null 체크와 수동 DTO 생성을 정적 팩토리 메소드로 대체하여 코드가 더 깔끔해졌습니다. 기본 이미지 처리 로직이 DTO 레이어로 적절히 캡슐화되었습니다.
src/main/java/com/example/FixLog/dto/member/LoginResponseDto.java (2)
3-4: 필요한 import가 적절히 추가되었습니다.새로운 정적 팩토리 메소드를 위해 Member와 DefaultImage import가 올바르게 추가되었습니다.
18-28: 정적 팩토리 메소드가 잘 구현되었습니다.
from메소드가 올바른 팩토리 메소드 패턴을 따르고 있으며, null 체크와 기본 이미지 처리 로직이 적절히 캡슐화되어 있습니다. 이로써 AuthService의 코드 중복이 제거되고 관심사가 적절히 분리되었습니다.src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java (1)
3-6: 새로운 의존성 추가가 적절합니다.Member 도메인과 유틸리티 클래스들의 import가 정확하게 추가되었습니다.
src/main/java/com/example/FixLog/service/MemberService.java (2)
36-45: 프로필 이미지 기본값 처리 방식 개선이 적절합니다.profileImageUrl을 null로 설정하여 DTO 레이어에서 기본값을 처리하도록 하는 접근 방식이 좋습니다. 관심사의 분리가 잘 이루어졌습니다.
69-76: 비밀번호 검증 로직이 보안상 안전합니다.회원 탈퇴 전 비밀번호 확인 절차가 적절하게 구현되었습니다. Spring Security의 PasswordEncoder를 사용한 비밀번호 검증과 적절한 예외 처리가 포함되어 있습니다.
src/main/java/com/example/FixLog/controller/MemberController.java (2)
5-5: 새로운 DTO import가 적절합니다.WithdrawRequestDto import가 정확하게 추가되었습니다.
55-61: 회원 탈퇴 API가 보안 요구사항을 충족합니다.비밀번호를 포함한 요청 DTO를 받아 서비스 계층에 전달하는 구조가 적절합니다. REST API 설계 원칙을 잘 따르고 있습니다.
| # DB setting | ||
| spring.h2.console.enabled=true | ||
| ''spring.h2.console.path=/h2-console | ||
|
|
||
| //# DataBase Info | ||
| //spring.datasource.url=jdbc:h2:tcp://localhost/~/fixlog | ||
| //spring.datasource.driver-class-name=org.h2.Driver | ||
| //spring.datasource.username=sa | ||
| //spring.datasource.password= | ||
| # DataBase Info | ||
| spring.datasource.url=jdbc:h2:tcp://localhost/~/fixlog | ||
| spring.datasource.driver-class-name=org.h2.Driver | ||
| spring.datasource.username=sa | ||
| spring.datasource.password= | ||
|
|
||
| //spring.jpa.show-sql=true | ||
| //spring.jpa.hibernate.ddl-auto=update | ||
| //spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect | ||
| spring.jpa.show-sql=true | ||
| spring.jpa.hibernate.ddl-auto=update | ||
| spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect |
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.
구성 오류: H2 콘솔 경로 설정 구문 오류
''spring.h2.console.path=/h2-console에 불필요한 작은따옴표('')가 포함되어 있어 적용되지 않습니다. 아래와 같이 오탈자를 수정해야 합니다.
- ''spring.h2.console.path=/h2-console
+ spring.h2.console.path=/h2-console📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # DB setting | |
| spring.h2.console.enabled=true | |
| ''spring.h2.console.path=/h2-console | |
| //# DataBase Info | |
| //spring.datasource.url=jdbc:h2:tcp://localhost/~/fixlog | |
| //spring.datasource.driver-class-name=org.h2.Driver | |
| //spring.datasource.username=sa | |
| //spring.datasource.password= | |
| # DataBase Info | |
| spring.datasource.url=jdbc:h2:tcp://localhost/~/fixlog | |
| spring.datasource.driver-class-name=org.h2.Driver | |
| spring.datasource.username=sa | |
| spring.datasource.password= | |
| //spring.jpa.show-sql=true | |
| //spring.jpa.hibernate.ddl-auto=update | |
| //spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect | |
| spring.jpa.show-sql=true | |
| spring.jpa.hibernate.ddl-auto=update | |
| spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect | |
| # DB setting | |
| spring.h2.console.enabled=true | |
| spring.h2.console.path=/h2-console | |
| # DataBase Info | |
| spring.datasource.url=jdbc:h2:tcp://localhost/~/fixlog | |
| spring.datasource.driver-class-name=org.h2.Driver | |
| spring.datasource.username=sa | |
| spring.datasource.password= | |
| spring.jpa.show-sql=true | |
| spring.jpa.hibernate.ddl-auto=update | |
| spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect |
🤖 Prompt for AI Agents
In src/main/resources/application.properties around lines 2 to 14, the H2
console path setting has incorrect syntax due to unnecessary single quotes
before the property key. Remove the leading two single quotes from the line
`''spring.h2.console.path=/h2-console` so it reads
`spring.h2.console.path=/h2-console` to fix the configuration error.
| public static MemberInfoResponseDto from(Member member) { | ||
| return new MemberInfoResponseDto( | ||
| member.getEmail(), | ||
| member.getNickname(), | ||
| member.getProfileImageUrl() != null | ||
| ? member.getProfileImageUrl() | ||
| : DefaultImage.PROFILE, | ||
| member.getBio() != null | ||
| ? member.getBio() | ||
| : DefaultText.BIO, | ||
| member.getSocialType() | ||
| ); | ||
| } |
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.
🛠️ Refactor suggestion
팩토리 메서드 구현이 우수합니다.
null 값에 대한 기본값 처리가 올바르게 구현되었고, 유틸리티 상수를 사용하여 일관성을 유지하고 있습니다. 정적 팩토리 메서드 패턴을 잘 활용했습니다.
컨트롤러에서 팩토리 메서드 사용을 권장합니다.
MemberController.getMyInfo 메서드에서 이 새로운 팩토리 메서드를 사용하지 않고 있어 일관성이 부족합니다. 기본값 처리 로직의 중복을 피하기 위해 팩토리 메서드 사용을 고려해보세요.
다음과 같이 수정을 제안합니다:
// MemberController.java의 getMyInfo 메서드에서
-MemberInfoResponseDto responseDto = new MemberInfoResponseDto(
- member.getEmail(),
- member.getNickname(),
- member.getProfileImageUrl(),
- member.getBio(),
- member.getSocialType()
-);
+MemberInfoResponseDto responseDto = MemberInfoResponseDto.from(member);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public static MemberInfoResponseDto from(Member member) { | |
| return new MemberInfoResponseDto( | |
| member.getEmail(), | |
| member.getNickname(), | |
| member.getProfileImageUrl() != null | |
| ? member.getProfileImageUrl() | |
| : DefaultImage.PROFILE, | |
| member.getBio() != null | |
| ? member.getBio() | |
| : DefaultText.BIO, | |
| member.getSocialType() | |
| ); | |
| } | |
| // In MemberController.java, inside getMyInfo(): | |
| MemberInfoResponseDto responseDto = MemberInfoResponseDto.from(member); |
🤖 Prompt for AI Agents
In src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java lines
19 to 31, the static factory method correctly handles null values with default
constants. To fix the issue, update the MemberController.getMyInfo method to use
this factory method when creating MemberInfoResponseDto instances. This will
ensure consistent default value handling and avoid duplication of null checks
across the codebase.
| member.getProfileImageUrl() != null | ||
| ? member.getProfileImageUrl() | ||
| : DefaultImage.PROFILE, | ||
| member.getBio() != null | ||
| ? member.getBio() | ||
| : DefaultText.BIO, |
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.
이 부분들은 서비스단에서 처리하는 게 더 좋지 않을까요?
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.
말씀 주신 부분을 반영하여 해당 처리는 서비스 단에서 담당하도록 변경했습니다.
확인 부탁드립니다! :)
| @AuthenticationPrincipal UserDetails userDetails, | ||
| @RequestBody EditPasswordRequestDto requestDto | ||
| ) { | ||
| Member member = memberService.getCurrentMemberInfo(); |
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.
@AuthenticationPrincipal UserDetails userDetails 이거랑 Member member = memberService.getCurrentMemberInfo(); 이거는 둘 중에 하나만 사용해도 되지 않나요?
저는 매개변수에 @AuthenticationPrincipal 사용은 안하고 서비스 단에서 member 객체 불러와서 사용하도록 했거든요!
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.
저는 인증 관련 처리를 컨트롤러에서 분리하고자 @AuthenticationPrincipal은 사용하지 않고, 서비스 단에서 SecurityContextHolder를 활용해 getCurrentMemberInfo()로 인증된 회원 정보를 가져오도록 통일했습니다. 확인 부탁드립니다!!
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter |
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.
Setter는 객체 상태를 너무 쉽게 바꿀 수 있어서 setter 사용하면 불변성 유지가 어렵다고 알고있어요!
Setter 사용은 정말 꼭 필요하지 않으면 지양하는 게 좋다고 알고있는데, 혹시 다른 있으면 말씀해주세요!
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.
해당 필드에 대한 변경은 명시적인 메서드를 통해 처리하도록 Setter를 제거하고 로직을 수정했습니다! 확인 부탁드립니다~
|
@CodeRabbit review this PR with full context |
|
Tip For best results, initiate chat on the files or code changes. @sungchaewon Below is a comprehensive review of PR #63 based on the full context provided. I focused on correctness, security, future maintainability, and consistency with existing conventions. ──────────────────────── ────────────────────────
──────────────────────── flowchart LR
A["MemberController.withdraw"] -->|old| S1["Service.withdraw(member)"]
A2["MemberController.withdraw"] -->|new| S2["Service.withdraw(member,password)"]
S2 -->|throws| E["INVALID_PASSWORD"]
Any client must now supply JSON body: { "password": "string" }Update API docs & FE. ──────────────────────── ────────────────────────
Let me know if you’d like code snippets or follow-up issues created for any point. Great progress overall! |
…기본 소개글로 반환하는 방향으로 통일
이슈 번호
작업 내용
기타
Summary by CodeRabbit