-
Notifications
You must be signed in to change notification settings - Fork 56
[이규석]sprint6 #337
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
base: part2-이규석
Are you sure you want to change the base?
[이규석]sprint6 #337
The head ref may contain hidden characters: "part2-\uC774\uADDC\uC11D-sprint6-ver2"
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.
안녕하세요 규석님.
과제하는데 시간이 오래 걸렸을거라 예상이 됩니다. 구현이 누락된 요구사항이 눈에 들어오네요😭
그래도 controller-service-repository 계층 분리와 각 계층의 역할은 명확하게 구현해주신듯 합니다.
이번 과제의 핵심이라고 할 수 있었던 페이징과 N+1 쿼리에 대해선 꼭 다시 구현해보시길 바랍니다.
궁금하시다면 아래 내용 참고해도 좋아요!
https://jojoldu.tistory.com/165
https://jojoldu.tistory.com/528
https://jojoldu.tistory.com/529
https://jojoldu.tistory.com/530
https://jojoldu.tistory.com/531
sql: | ||
init: | ||
mode: always # 스키마 초기화 실행 | ||
schema-locations: classpath:schema.sql # schema.sql 파일 실행 |
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.
기본값이 classpath:schema.sql 인 것 아실까요~~?
그래도 명시적으로 선언해주시면 설정을 보는 사람이 이해하기 쉬울듯 합니다 👍
@OneToMany(mappedBy = "channel", cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<Message> messages = new ArrayList<>(); |
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.
해당 내용은 과제 요구사항에 없긴 한데요!
실제 디스코드 서버라고 한다면 채널에 무수히 많은 메시지가 있을거에요.
이를 페이징 없이 lazy loading 한다고 하면 오랜 수행시간이 필요할겁니다!
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) | ||
@JoinColumn(name = "message_id") | ||
private List<BinaryContent> attachments = new ArrayList<>(); |
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.
BinaryContent 와의 연관관계는 다시 확인해보시는게 좋겠습니다!
Message와 BinaryContent는 ManyToMany 관계거든요.
그래서 중간에 매핑 테이블이 필요합니다. 따라서 매핑 엔티티를 만들어서 OneToMany로 참조하거나
아니면 JoinTable 어노테이션을 통해 매핑 엔티티 없이 BinaryContent를 OneToMany 참조하는 방법이 있겠습니다.
public interface MessageRepository extends JpaRepository<Message, UUID> { | ||
List<Message> findAllByChannelId(UUID channelId); | ||
} |
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.
페이징 처리에 대한 요구사항 구현이 안되어 있네요ㅠㅠ
시간이 되시면 꼭 구현해보시길 바래요. 이번 과제에 중요한 내용 중 하나입니다!
public ResponseEntity<List<Message>> findAllByChannelId( | ||
@RequestParam("channelId") UUID channelId) { | ||
List<Message> messages = messageService.findAllByChannelId(channelId); | ||
return ResponseEntity | ||
.status(HttpStatus.OK) | ||
.body(messages); | ||
} |
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.
API에선 DTO를 사용자에게 반환하도록 하면 어때요?
API의 변경사항이 엔티티에 영향을 주지 않도록, 그리고 엔티티의 영향이 API에 영향을 끼치지 않도록 하기 위해서 DTO와 엔티티 분리는 중요해요!
return ResponseEntity.ok() | ||
.contentType(mediaType) | ||
.contentLength(contentLength) | ||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"") |
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.
ContentDisposition 이라는 클래스를 사용하면 헤더를 쉽게 만들 수 있습니다!
요구사항
기본
schema.sql
포함)application.yaml
설정 작성 (DB 연결, SQL 로그 등)@CreatedDate
,@LastModifiedDate
를 통한 자동 시간 처리Page
/Slice
활용)심화
주요 변경사항
schema.sql
을 작성하여 ERD 기반 테이블 생성BaseEntity
를 통해createdAt
,updatedAt
필드 자동 처리UserMapper
,ChannelMapper
등 생성local
조건 처리Pageable
및Page<T>
기반 메시지 목록 조회 기능 구현엔티티 관계
멘토에게