Skip to content

과제 1-1 jihoonwjj 과제제출 #3

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

Open
wants to merge 1 commit into
base: task/hjh
Choose a base branch
from

Conversation

jihoonwjj
Copy link
Collaborator

No description provided.

Copy link
Member

@snowykte0426 snowykte0426 left a comment

Choose a reason for hiding this comment

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

수고 하셨습니다😁

엔티티하고 레포지터리 이름 정상화하고
서비스 인터페이스에 어노테이션을 붙여놓으신것도 세부 구현 클래스에 붙이는 걸로 수정 바랍니다

}

@PatchMapping(("/{id}"))
public ResponseEntity<Ang> editThatShit(AnggimoddiDTO anggimoddiDTO, @PathVariable Long id) {
Copy link
Member

Choose a reason for hiding this comment

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

@Vaild 어노테이션 적용 안하면 값 검증이 활성화가 안되요!

Comment on lines +8 to +16
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Builder
public class AnggimoddiDTO {
private Long id;
private String title;
private String content;
}
Copy link
Member

Choose a reason for hiding this comment

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

@Size@Max 등 수많은 값 검증 어노테이션이 있으니까 특히 Request로 받는 DTO는 검증을 강화해줍시다

Comment on lines +17 to +24
public ResponseEntity<List<Ang>> getAngs() {
try {
return ResponseEntity.ok(angRepository.findAll());
} catch (IllegalArgumentException e) {
List<Ang> emptyList = Collections.emptyList();
return ResponseEntity.ok(emptyList);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

같이 협업하는 클라이언트 마다 다르긴 했는데 대부분의 클라이언트는 List형 API에서는 값이 없으면 그냥 Empty List를 반환해 주는 것을 선호하더라고요

Comment on lines +11 to +22
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Ang extends BaseIdxEntity{
private String title;
private String content;

@Builder
public Ang(Long idx, String title, String content){
this.idx = idx;
this.title = title;
this.content = content;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

image
클래스명 정상화 부탁드립니다

private final AngRepository angRepository;

public ResponseEntity<Ang> postPost(Ang ang) {
return ResponseEntity.ok(angRepository.save(ang));
Copy link
Member

Choose a reason for hiding this comment

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

이런 식으로 설계되어 있으면 오류 발생 시 500뜨고 말거나 이상한 값이 날라갈 거 같은데 예외 처리를 해주는건 어떨까요

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Service
Copy link
Member

Choose a reason for hiding this comment

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

이 녀석 인터페이스에 @Service? 보통의 Aura가 아니군

Comment on lines +26 to +39
@GetMapping("/")
public ResponseEntity<List<Ang>> getShitAll() {
return getPost.getAngs();
}

@GetMapping("/{id}")
public ResponseEntity<Optional<Ang>> getThatShit(@PathVariable Long id) {
return getPost.getAngById(id);
}

@PostMapping("/")
public ResponseEntity<Ang> makeShit(Ang ang) {
return postpost.postPost(ang);
}
Copy link
Member

Choose a reason for hiding this comment

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

GET /articlesPOST /articles 와 같은 상황에서는 ("/")로 명시하는 것보다 그냥 아무것도 안남기고 @PostMapping 이렇게만 하는게 관례에 더 맞을 것 같습니다

@snowykte0426 snowykte0426 changed the title feat: 앙기모띠 과제 1-1 jihoonwjj 과제제출 Feb 21, 2025
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