Skip to content

전남대 BE_김명진_ 2주차 과제(Step1)#141

Open
kmj452 wants to merge 13 commits intokakao-tech-campus-2nd-step2:kmj452from
kmj452:step1
Open

전남대 BE_김명진_ 2주차 과제(Step1)#141
kmj452 wants to merge 13 commits intokakao-tech-campus-2nd-step2:kmj452from
kmj452:step1

Conversation

@kmj452
Copy link
Copy Markdown

@kmj452 kmj452 commented Jul 3, 2024

궁금한점: 카카오 라는 단어가 들어가면 협의후에 사용가능하다고 나와있는데 이건 관리자나 특수 사용자의 경우에 사용이 가능하다는 의미일까요? 커스텀 validation을 만들어 해결하긴했는데 다른 방법이 있는지 궁금합니다.

힘들었던점 :
오류를 처리하는데 힘들었습니다.... BindingResult 객체는 전역 핸들러를 사용하면 더이상 반환할 필요가 없단걸 꺠닫기까지 많은 시간이 소모되었습니다.

Copy link
Copy Markdown

@Hongdonggeon Hongdonggeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 명진님 전체적으로 잘 구현해셨네요!!
간단한 코멘트 남겨놓았습니다!
반영하시면서 궁금한점 있으면 편하게 DM 주세요 😃

public String showEditForm(@PathVariable("id") Long id, Model model) {
if (productService.getProductById(id) == null) {
throw new RuntimeException("해당 id의 상품이 존재하지 않습니다");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

검증 로직은 Controller 계층보다 Service 계층에서 해주는게 더 좋지않을까요?
각 레이어의 역할에 대해서 학습해보시면 좋을 것 같습니다!

import java.util.Map;

@RestControllerAdvice
public class GlobalExceptionHandler {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예측하지 못한 서버에러인 케이스도 (HttpStatus : 500 - Internal Server Error) 만들어주면 좋을 것 같아요!

package gift.Validation;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
public class KakaoValidator implements ConstraintValidator<KaKao, String> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConstraintValidator 를 사용하셨네요 👍
카카오 검증만 이방법을 사용한 방법이 있을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants