-
Notifications
You must be signed in to change notification settings - Fork 0
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
[기본과제/심화과제] 3주차 JPA 활용해서 유저, 게시물 기능 구현하기 #3
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "3\uC8FC\uCC28"
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.
LGTM ^__________^
protected ApiResponseDto handleEntityNotFoundException(final EntityNotFoundException e) { | ||
return ApiResponseDto.error(ErrorStatus.NOT_FOUND_USER); | ||
} | ||
} |
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.
보통 여기에 500에러를 넣나요 안 넣나요?! (궁금해서 물어보는 것..)
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor |
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.
@RequestMapping("/post")
어노테이션 달아주고 아래 맵핑에는 /create
, /{id},
/search
만 써도 될 것 같네요!!
아래 user도 마찬가지~
|
||
@GetMapping("/user/{id}") | ||
@ResponseStatus(HttpStatus.OK) | ||
public ApiResponseDto<UserResponseDto> search(@PathVariable @Valid final Long id){ |
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.
보통 @Valid
는 dto 유효성 검사할 때 쓰는 어노테이션 아닌가요..?! id에도 써준 이유가 궁금합니다!
그리고 파라미터를 상수로 받아온 이유도 궁금해요~~
@Column(nullable = false) | ||
private String email; | ||
|
||
|
||
@Column(nullable = false) | ||
private String password; | ||
|
||
@OneToMany(mappedBy = "created_user") | ||
private List<Post> posts=new ArrayList<Post>(); | ||
@Builder | ||
public User(String nickname,String email,String password){ | ||
this.nickname=nickname; | ||
this.email=email; | ||
this.password=password; | ||
this.posts=new ArrayList<Post>(); | ||
} | ||
|
||
|
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.
린트가 상당히 킹받네요..
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "예상치 못한 서버 에러가 발생했습니다."), | ||
BAD_GATEWAY_EXCEPTION(HttpStatus.BAD_GATEWAY, "일시적인 에러가 발생하였습니다.\n잠시 후 다시 시도해주세요!"), | ||
SERVICE_UNAVAILABLE_EXCEPTION(HttpStatus.SERVICE_UNAVAILABLE, "현재 점검 중입니다.\n잠시 후 다시 시도해주세요!"), | ||
; |
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.
외로워보이는 땀이네요
VALIDATION_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 요청입니다."), | ||
VALIDATION_REQUEST_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "요청값이 입력되지 않았습니다."), | ||
|
||
NOT_FOUND_USER(HttpStatus.BAD_REQUEST, "검색 결과가 없습니다."), |
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.
NOT_FOUND면 404가 맞지 않나요?? 400으로 처리해줬네요!
spring: | ||
datasource: | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
url: jdbc:mysql://localhost:3306/sopt_32?useSSL=true&useUnicode=true&serverTimezone=Asia/Seoul | ||
username: sopt_server | ||
password: 1124 | ||
|
||
jpa: | ||
show-sql: true | ||
hibernate: | ||
ddl-auto: create | ||
properties: | ||
hibernate: | ||
format_sql: true | ||
logging: | ||
level: | ||
org: | ||
hibernate: | ||
type: | ||
descriptor: | ||
sql: trace |
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.
야믈파일이 올라와있네요 ㅎㅎ
🐕 과제 구현 명세
🐥 이런 점이 새로웠어요 / 어려웠어요
이런식으로, PostController를 작성해주었고, 여기서 Request 핸들링을 해주었고, 오류 처리까지 해주었습니다!
단,...서버 꿈나무인 제가 조금 헷갈렸던 부부은
세미나때와 저번 가희 코드리뷰에서 배웠던 빌더배턴을 써보려고 했고, User에서는 직접 빌더를 만들어주고, 여기서는 어노테이션을 써보려고 헀는데... 생성자를 요로코롬 선언해주는게 과연 맞을지 조오금 궁금합니다...