22
33import BE_Elixir .Elixir .domain .achievement .service .MemberStatsService ;
44import BE_Elixir .Elixir .domain .challenge .event .events .DietLogEvent ;
5- import BE_Elixir .Elixir .domain .challenge .event .events .RecipeEvent ;
65import BE_Elixir .Elixir .domain .dietLog .dto .DietLogRequestDTO ;
76import BE_Elixir .Elixir .domain .dietLog .dto .DietLogResponseDTO ;
87import BE_Elixir .Elixir .domain .dietLog .dto .MonthlyDietScoreDTO ;
@@ -52,7 +51,7 @@ public DietLogResponseDTO createDietLog(DietLogRequestDTO dto, Long memberId, Mu
5251
5352 // 회원 조회
5453 Member member = memberRepository .findById (memberId )
55- .orElseThrow (() -> new IllegalArgumentException ( "회원이 존재하지 않습니다. member id: " + memberId ));
54+ .orElseThrow (() -> new CustomException ( ErrorCode . MEMBER_NOT_FOUND ));
5655
5756 // 식단 타입을 enum 타입으로 변환 및 검사
5857 DietLogType typeEnum = DietLogType .valueOf (dto .getType ().toUpperCase ());
@@ -98,11 +97,11 @@ public DietLogResponseDTO createDietLog(DietLogRequestDTO dto, Long memberId, Mu
9897 public void deleteDietLog (Long dietLogId , Long memberId ) {
9998 // 식단 기록 객체 찾기
10099 DietLog dietLog = dietLogRepository .findById (dietLogId )
101- .orElseThrow (() -> new IllegalArgumentException ( "해당 식단이 존재하지 않습니다. 식단 ID: " + dietLogId ));
100+ .orElseThrow (() -> new CustomException ( ErrorCode . DIETLOG_NOT_FOUND ));
102101
103102 // 권한 확인: 본인만 삭제 가능
104103 if (!dietLog .getMember ().getId ().equals (memberId )) {
105- throw new SecurityException ( "해당 식단을 삭제할 권한이 없습니다." );
104+ throw new CustomException ( ErrorCode . FORBIDDEN_ACCESS );
106105 }
107106
108107 // S3 버킷에서 이미지 삭제
@@ -117,11 +116,11 @@ public void deleteDietLog(Long dietLogId, Long memberId) {
117116 public DietLogResponseDTO updateDietLog (Long dietLogId , Long memberId , DietLogRequestDTO dto , MultipartFile image ) {
118117 // 기존 식단 조회
119118 DietLog dietLog = dietLogRepository .findById (dietLogId )
120- .orElseThrow (() -> new IllegalArgumentException ( "해당 식단이 존재하지 않습니다. 식단 ID: " + dietLogId ));
119+ .orElseThrow (() -> new CustomException ( ErrorCode . DIETLOG_NOT_FOUND ));
121120
122121 // 권한 확인: 본인만 수정 가능
123122 if (!dietLog .getMember ().getId ().equals (memberId )) {
124- throw new SecurityException ( "해당 식단을 수정할 권한이 없습니다." );
123+ throw new CustomException ( ErrorCode . FORBIDDEN_ACCESS );
125124 }
126125
127126 // 이름 수정
@@ -192,7 +191,7 @@ public DietLogResponseDTO getDietLog(Long dietLogId) {
192191
193192 // 식단 기록 객체 찾기
194193 DietLog dietLog = dietLogRepository .findById (dietLogId )
195- .orElseThrow (() -> new IllegalArgumentException ( "해당 식단이 존재하지 않습니다. 식단 ID: " + dietLogId ));
194+ .orElseThrow (() -> new CustomException ( ErrorCode . DIETLOG_NOT_FOUND ));
196195
197196 return dietLog .convertToResponseDTO ();
198197
@@ -258,7 +257,7 @@ private void validateDuplicateDietLogType(Long memberId, DietLogType typeEnum, L
258257 );
259258
260259 if (exists ) {
261- throw new CustomException (ErrorCode .DIET_LOG_TYPE_DUPLICATE );
260+ throw new CustomException (ErrorCode .DIETLOG_TYPE_DUPLICATE );
262261 }
263262 }
264263
@@ -276,7 +275,7 @@ private void validateDuplicateDietLogType(Long memberId, DietLogType typeEnum, L
276275 );
277276
278277 if (exists ) {
279- throw new CustomException (ErrorCode .DIET_LOG_TYPE_DUPLICATE );
278+ throw new CustomException (ErrorCode .DIETLOG_TYPE_DUPLICATE );
280279 }
281280 }
282281
0 commit comments