-
Notifications
You must be signed in to change notification settings - Fork 112
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
강원대 BE_박지희 4주차 과제 (1단계) #228
base: peacefullyquietly
Are you sure you want to change the base?
강원대 BE_박지희 4주차 과제 (1단계) #228
Conversation
질문주신부분입니다.
정의주신부분을보면 상태코드와 중복된값이라 따로 내려주실필요는 없습니다. 일단 수정하고나서 다시 살펴보죠! |
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.
안녕하세요.
코멘트 남겨주신부분 참고하셔서 반영해주시면 감사하겠습니다.
|
||
@NotBlank(message = "카테고리 이름은 필수 입력 항목입니다.") | ||
private String name; | ||
private String color; |
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.
저장될때는 nullable하지 않게 되어있는데 앞에서도 검증이 필요할것같습니다.
public CategoryDTO updateCategory(Long id, CategoryDTO categoryDTO) { | ||
CategoryEntity category = categoryRepository.findById(id) | ||
.orElseThrow(() -> new RuntimeException("카테고리를 찾을 수 없습니다")); | ||
|
||
CategoryEntity updatedCategory = new CategoryEntity( | ||
category.getId(), | ||
categoryDTO.getName(), | ||
categoryDTO.getColor(), | ||
categoryDTO.getImageUrl(), | ||
categoryDTO.getDescription() | ||
); | ||
|
||
updatedCategory = categoryRepository.save(updatedCategory); | ||
return updatedCategory.toDTO(updatedCategory); |
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.
로직이 좀 이상한데 id를 가져와서 조회한후에 다른카테고리가 업데이트될수도있을거같은데요, 문제확인주시고 업데이트하는 대상에게 update메서드를 따로 만드는방식으로도 개선을 해주시면 될것같습니다.
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.
넵 알겠습니다!
@@ -21,7 +21,7 @@ public MemberEntity authenticateToken(MemberDTO memberDTO) { | |||
MemberEntity foundMember = memberRepository.findByEmail(memberDTO.getEmail()); | |||
|
|||
if (foundMember == null || !memberDTO.getPassword().equals(foundMember.getPassword())) { | |||
return null; | |||
throw new RuntimeException("Invalid email or password"); |
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.
정의된 예외를 사용해보는건 어떨까요?
|
||
@RestController | ||
@RequestMapping("/api/category") | ||
public class CategoryController { |
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.
상품추가할때 바로 카테고리를 지정해야하는 요구사항이 있는것으로 알고있는데요, 상품쪽 controller에 수정이 필요할것같습니다.
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.
넵 수정해보겠습니다!
변경 사항
궁금한점