Skip to content

Commit 63af568

Browse files
committed
fix: 코드리뷰 반영 — EMAIL_PROVIDER_MISMATCH 분리, AI_RESULT_FORBIDDEN 추가, ErrorCode 통일
1 parent 14c1b06 commit 63af568

5 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/main/java/com/Rootin/domain/ai/service/AiResultService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void delete(Long resultId, Long userId) {
9999
.orElseThrow(() -> CustomException.of(ErrorCode.AI_RESULT_NOT_FOUND));
100100

101101
if (!aiResult.getUser().getId().equals(userId)) {
102-
throw CustomException.forbidden("본인의 AI 결과만 삭제할 수 있습니다.");
102+
throw CustomException.of(ErrorCode.AI_RESULT_FORBIDDEN);
103103
}
104104

105105
aiResultRepository.delete(aiResult);

src/main/java/com/Rootin/domain/auth/service/AuthService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public TokenResponse googleLogin(GoogleLoginRequest request) {
205205
// 3. 신규 사용자 → 자동 회원가입
206206
if (user == null) {
207207
if (userRepository.existsByEmail(email)) {
208-
throw CustomException.of(ErrorCode.DUPLICATE_EMAIL);
208+
throw CustomException.of(ErrorCode.EMAIL_PROVIDER_MISMATCH);
209209
}
210210

211211
String nickname = generateUniqueNickname(googleName, sub);

src/main/java/com/Rootin/domain/garden/service/GardenService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void updateGardenLayout(Long userId, GardenLayoutUpdateRequest request) {
202202
List<Pot> pots = potRepository.findAllById(distinctPotIds);
203203

204204
if (pots.size() != distinctPotIds.size()) {
205-
throw new CustomException(ErrorCode.POT_NOT_FOUND);
205+
throw CustomException.of(ErrorCode.POT_NOT_FOUND);
206206
}
207207

208208
// Collectors.toMap() 연산 수행 시 중복 키로 인한 IllegalStateException(500 에러) 발생을 방지하기 위해

src/main/java/com/Rootin/domain/til/service/TilService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class TilService {
4242
@Transactional
4343
public TilResponse create(Long userId, TilCreateRequest request) {
4444
User user = userRepository.findById(userId)
45-
.orElseThrow(() -> CustomException.notFound("사용자를 찾을 수 없습니다."));
45+
.orElseThrow(() -> CustomException.of(ErrorCode.USER_NOT_FOUND));
4646

4747
// TIL 발행은 곧 화분 경험치 변경으로 이어집니다.
4848
// 같은 화분에 여러 요청이 동시에 들어오면 totalExp 계산이 꼬일 수 있으므로,
@@ -127,7 +127,7 @@ public void delete(Long tilId, Long userId) {
127127
@Transactional
128128
public TilResponse saveDraft(Long userId, DraftSaveRequest request) {
129129
User user = userRepository.findById(userId)
130-
.orElseThrow(() -> CustomException.notFound("사용자를 찾을 수 없습니다."));
130+
.orElseThrow(() -> CustomException.of(ErrorCode.USER_NOT_FOUND));
131131
Pot pot = potRepository.findById(request.potId())
132132
.orElseThrow(() -> CustomException.of(ErrorCode.POT_NOT_FOUND));
133133
validatePotOwner(pot, userId);

src/main/java/com/Rootin/global/exception/ErrorCode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public enum ErrorCode {
2424
DUPLICATE_EMAIL(HttpStatus.CONFLICT, "이미 사용 중인 이메일입니다."),
2525
DUPLICATE_NICKNAME(HttpStatus.CONFLICT, "이미 사용 중인 닉네임입니다."),
2626
INVALID_PASSWORD(HttpStatus.BAD_REQUEST, "현재 비밀번호가 일치하지 않습니다."),
27+
EMAIL_PROVIDER_MISMATCH(HttpStatus.CONFLICT, "이미 다른 방식으로 가입된 이메일입니다."),
2728

2829
// TIL
2930
TIL_NOT_FOUND(HttpStatus.NOT_FOUND, "TIL을 찾을 수 없습니다."),
@@ -38,6 +39,7 @@ public enum ErrorCode {
3839

3940
// AI
4041
AI_RESULT_NOT_FOUND(HttpStatus.NOT_FOUND, "AI 결과를 찾을 수 없습니다."),
42+
AI_RESULT_FORBIDDEN(HttpStatus.FORBIDDEN, "본인의 AI 결과만 삭제할 수 있습니다."),
4143
AI_REQUEST_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "AI 요청 처리 중 오류가 발생했습니다."),
4244
RATE_LIMIT_EXCEEDED(HttpStatus.TOO_MANY_REQUESTS, "요청이 너무 많습니다. 잠시 후 다시 시도해주세요."),
4345

0 commit comments

Comments
 (0)