-
Notifications
You must be signed in to change notification settings - Fork 2
[BE] SISC1 [FIX] controller annotation 수정 #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
Conversation
- 세션 CRUD 기능 테스트 - 권한별 접근 제어 검증 - 유효성 검증 및 예외 상황 테스트
…-179-BE-AttendanceControllerTest-코드-작성
전체 흐름스프링 MVC 컨트롤러 두 개를 RESTful 컨트롤러로 변환하고, 사용자 회원가입 및 OAuth 인증을 위한 새로운 DTO와 엔티티를 추가하며, 기본 테스트 클래스와 테스트 메타데이터를 보완했습니다. 변경사항
시퀀스 다이어그램sequenceDiagram
participant Client
participant Controller as 회원가입<br/>Controller
participant Service as User<br/>Service
participant DB as Database
Client->>Controller: POST /signup<br/>(SignupRequest)
Note over Controller: @RestController<br/>요청 검증
Controller->>Service: signup(request)
Service->>DB: User 저장
Service->>DB: UserOauthAccount 생성
DB-->>Service: 생성 완료
Service-->>Controller: User 반환
Note over Controller: SignupResponse로<br/>변환
Controller-->>Client: 200 OK<br/>(SignupResponse)
예상 코드 리뷰 난이도🎯 2 (Simple) | ⏱️ ~12 분
관련 PR
추천 리뷰어
시
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 1
🧹 Nitpick comments (2)
backend/src/main/java/org/sejongisc/backend/user/dto/SignupResponse.java (1)
24-31: 할당 연산자 주변의 공백을 일관되게 유지하세요.생성자 내 할당문에서
=연산자 주변에 공백이 없어 코드 일관성이 떨어집니다.다음 diff를 적용하여 일관성을 개선할 수 있습니다:
private SignupResponse(UUID userId, String name, String email, Role role, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.userId=userId; - this.name=name; - this.email=email; - this.role=role; + this.userId = userId; + this.name = name; + this.email = email; + this.role = role; this.createdAt = createdAt; this.updatedAt = updatedAt; }backend/src/main/java/org/sejongisc/backend/user/dto/SignupRequest.java (1)
27-29:@Pattern애노테이션에 사용자 친화적인 메시지를 추가하세요.전화번호 패턴 검증에
message속성이 누락되어 있어, 검증 실패 시 사용자에게 명확한 오류 메시지가 전달되지 않습니다.다음 diff를 적용하여 개선할 수 있습니다:
@NotBlank(message = "전화번호는 필수입니다.") - @Pattern(regexp = "^[0-9]{10,11}$") + @Pattern(regexp = "^[0-9]{10,11}$", message = "전화번호는 10-11자리 숫자여야 합니다.") private String phoneNumber;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceController.java(1 hunks)backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceSessionController.java(1 hunks)backend/src/main/java/org/sejongisc/backend/user/dto/SignupRequest.java(1 hunks)backend/src/main/java/org/sejongisc/backend/user/dto/SignupResponse.java(1 hunks)backend/src/main/java/org/sejongisc/backend/user/entity/AuthProvider.java(1 hunks)backend/src/main/java/org/sejongisc/backend/user/entity/UserOauthAccount.java(1 hunks)backend/src/test/java/org/sejongisc/backend/BackendApplicationTests.java(1 hunks)backend/src/test/java/org/sejongisc/backend/attendance/controller/AttendanceSessionControllerTest.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
backend/src/main/java/org/sejongisc/backend/user/entity/UserOauthAccount.java (3)
backend/src/main/java/org/sejongisc/backend/user/entity/User.java (1)
Entity(12-65)backend/src/main/java/org/sejongisc/backend/auth/entity/UserOauthAccount.java (1)
Entity(10-37)backend/src/main/java/org/sejongisc/backend/user/service/UserServiceImpl.java (2)
Slf4j(24-128)newUser(79-97)
backend/src/main/java/org/sejongisc/backend/user/dto/SignupResponse.java (4)
backend/src/main/java/org/sejongisc/backend/user/dto/SignupRequest.java (1)
Getter(9-30)backend/src/main/java/org/sejongisc/backend/user/service/UserService.java (1)
signUp(12-12)backend/src/test/java/org/sejongisc/backend/user/service/UserServiceImplTest.java (1)
Test(46-92)backend/src/main/java/org/sejongisc/backend/user/service/UserServiceImpl.java (1)
Override(34-68)
backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceController.java (1)
backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceSessionController.java (1)
RestController(18-211)
backend/src/main/java/org/sejongisc/backend/user/dto/SignupRequest.java (3)
backend/src/main/java/org/sejongisc/backend/user/dto/SignupResponse.java (1)
Getter(11-43)backend/src/main/java/org/sejongisc/backend/common/auth/springsecurity/CustomUserDetails.java (1)
Getter(14-65)backend/src/main/java/org/sejongisc/backend/user/dto/UserInfoResponse.java (1)
Getter(9-19)
backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceSessionController.java (1)
backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceController.java (1)
RestController(19-100)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Backend Gate
🔇 Additional comments (5)
backend/src/test/java/org/sejongisc/backend/attendance/controller/AttendanceSessionControllerTest.java (1)
117-117: 오타 수정 완료!테스트 표시명에서 "유혀성"을 올바른 단어인 "유효성"으로 수정했습니다. 테스트 가독성이 개선되었습니다.
backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceSessionController.java (1)
18-18: REST API 패턴에 맞는 올바른 변경입니다!
@Controller에서@RestController로 변경한 것은 적절합니다. 모든 메서드가ResponseEntity를 반환하므로@RestController사용이 REST API의 의도를 명확히 표현하며, 자동 JSON 직렬화가 적용됩니다.AttendanceController.java와의 일관성도 확보되었습니다.backend/src/main/java/org/sejongisc/backend/attendance/controller/AttendanceController.java (1)
19-19: LGTM!
@RestController어노테이션으로의 변경이 올바르게 적용되었습니다. 모든 핸들러 메서드가ResponseEntity를 반환하므로 REST API 컨트롤러로서의 의도가 명확해졌으며,AttendanceSessionController와 일관된 패턴을 유지하고 있습니다.backend/src/test/java/org/sejongisc/backend/BackendApplicationTests.java (1)
1-15: LGTM! 표준적인 Spring Boot 테스트 구성입니다.
@SpringBootTest와@ActiveProfiles("test")를 사용하여 테스트 프로파일에서 애플리케이션 컨텍스트가 정상적으로 로드되는지 검증하는 표준적인 패턴입니다.backend/src/main/java/org/sejongisc/backend/user/entity/AuthProvider.java (1)
1-5: LGTM! 명확하고 간결한 enum 정의입니다.OAuth 인증 제공자를 표현하는 표준적인 enum 구현입니다.
| @Entity | ||
| @Table(name = "user_oauth_account") | ||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class UserOauthAccount extends BasePostgresEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.UUID) | ||
| @Column(name = "user_oauth_account_id", columnDefinition = "uuid") | ||
| private UUID userOauthAccountId; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "user_id", nullable = false, columnDefinition = "uuid") | ||
| private User user; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(nullable = false) | ||
| private AuthProvider provider; | ||
|
|
||
| @Column(name = "provider_uid", nullable = false) | ||
| private String providerUid; | ||
| } |
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.
🧩 Analysis chain
중복 엔티티 클래스가 존재합니다 - JPA 매핑 충돌 발생 위험
동일한 테이블(user_oauth_account)에 대한 엔티티 클래스가 이미 backend/src/main/java/org/sejongisc/backend/auth/entity/UserOauthAccount.java에 존재합니다.
두 엔티티의 주요 차이점:
- 기존 엔티티에는
@UniqueConstraint(columnNames = {"provider", "provider_uid"})가 있지만 새 엔티티에는 없습니다 - 서로 다른 패키지에 위치:
user.entityvsauth.entity
이로 인한 문제:
- JPA가 동일한 테이블에 대해 어떤 엔티티를 사용할지 결정할 수 없어 충돌이 발생합니다
- 유니크 제약조건 누락으로 중복 OAuth 계정이 생성될 수 있습니다
UserServiceImpl의oauthAccountRepository는auth.entity.UserOauthAccount를 참조하고 있어 불일치가 발생합니다
다음 스크립트로 중복을 확인하세요:
두 엔티티 중 하나를 제거하거나, 용도가 다르다면 테이블 이름을 변경해야 합니다.
🏁 Script executed:
#!/bin/bash
# Description: 동일한 테이블에 매핑된 엔티티 클래스 확인
# user_oauth_account 테이블에 매핑된 모든 엔티티 검색
rg -n --type=java -C3 '@Table\(name\s*=\s*"user_oauth_account"'
# UserOauthAccount 클래스 정의 위치 확인
fd -e java UserOauthAccount.java
# UserOauthAccount를 사용하는 Repository 확인
rg -n --type=java -C3 'UserOauthAccountRepository'Length of output: 5862
Now let me verify the specific details by checking the repository and entity usages:Based on my verification using the provided script output and web search findings, I can now generate the rewritten review comment:
중복 엔티티 클래스 제거 필요 - 동일 테이블에 매핑된 두 개의 JPA 엔티티 존재
동일한 테이블에 두 개의 엔티티를 매핑하는 것은 좋지 않은 설계 관행입니다. 현재 user_oauth_account 테이블에 대해 두 엔티티가 존재합니다:
backend/src/main/java/org/sejongisc/backend/user/entity/UserOauthAccount.javabackend/src/main/java/org/sejongisc/backend/auth/entity/UserOauthAccount.java
주요 문제:
auth.entity버전에는@UniqueConstraint(columnNames = {"provider", "provider_uid"})가 있지만, 새로운user.entity버전에는 없습니다- 여러 엔티티 타입을 동일한 데이터베이스 테이블 레코드에 대해 fetch하면 Persistence Context flush 시 불일치가 발생할 수 있습니다
UserOauthAccountRepository는auth.entity.UserOauthAccount를 참조하고 있어,user.entity버전과의 불일치가 발생합니다
해결 방안:
user.entity.UserOauthAccount클래스를 삭제하고, 기존auth.entity.UserOauthAccount만 사용하거나- 두 버전이 서로 다른 목적이 있다면 테이블을 분리하고 명확한 구조 설계 필요
🤖 Prompt for AI Agents
In backend/src/main/java/org/sejongisc/backend/user/entity/UserOauthAccount.java
around lines 10 to 34, there is a duplicate JPA entity mapping the same
user_oauth_account table which conflicts with
backend/src/main/java/org/sejongisc/backend/auth/entity/UserOauthAccount; remove
or consolidate the duplicate: delete this user.entity.UserOauthAccount (or merge
its intent into the auth.entity version), ensure the retained entity contains
the @UniqueConstraint(columnNames = {"provider","provider_uid"}) and all needed
fields/annotations, and update every import/usages (repositories, services,
DTOs) to reference the single entity package so there are no remaining
references to the removed class.
Summary by CodeRabbit
릴리스 노트
새로운 기능
리팩토링
테스트