-
Notifications
You must be signed in to change notification settings - Fork 16
[신동진] Sprint11 #163
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: 신동진
Are you sure you want to change the base?
[신동진] Sprint11 #163
Conversation
BinaryContent의 상태를 업데이트하는 메서드를 정의하는 것까지 했습니다.
BinaryContentCreatedEventListener의 이벤트 리스너에 시험삼아 condition으로 조건을 걸어봤습니다.
채널에 새로운 메시지가 등록된 경우 알림을 받을 수 있도록 리팩토링하세요.
- MessageCreatedEvent를 정의하고 새로운 메시지가 등록되면 이벤트를 발행하세요.
- 사용자 별로 관심있는 채널의 알림만 받을 수 있도록 ReadStatus 엔티티에 채널 알림 여부 속성(notificationEnabled)을 추가하세요.
- PRIVATE 채널은 알림 여부를 true로 초기화합니다.
- PUBLIC 채널은 알림 여부를 false로 초기화합니다.
- 알림 여부를 수정할 수 있게 ReadStatusUpdateRequest를 수정하세요.
[ ] 사용자의 권한(Role)이 변경된 경우 알림을 받을 수 있도록 리팩토링하세요. [ ] 알림 API를 구현하세요. * 요청자 본인의 알림에 대해서만 수행할 수 있습니다. << fix 해야함 [ ] 알림이 필요한 이벤트가 발행되었을 때 알림을 생성하세요.
* TaskDecorator 수정 필요
* 재시도가 모두 실패했을 때 대응전략 수정 필요
| } | ||
|
|
||
| // 트랜잭션이 commit되었을 때 실행 | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) |
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.
TransactionPhase.AFTER_COMMIT 가 default 설정인데 이렇게 해두신것은 의도를 표현하기 위함인가요?
|
|
||
| @Transactional | ||
| @Override | ||
| public UserDto updateRoleInternal(RoleUpdateRequest 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.
해당 로직에서도 이벤트 발행이 필요해보이는데 누락된것 같습니다 !
| @Bean(name = "taskExecutor") | ||
| public Executor taskExecutor() { | ||
| // TaskDecorator는 인터페이스다 | ||
| CustomTaskDecorator decorator = new CustomTaskDecorator(); |
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.
파라미터로 필요한 정보 추가로 넣어주시면 좋을것 같습니다 !
|
|
||
| @Configuration | ||
| @EnableAsync | ||
| public class AsyncConfig implements AsyncConfigurer { |
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.
설정은 잘하셨는데 어노테이션으로 적용하는 부분이 없는것 같습니다. 요구사항에 맞춰 어노테이션을 적용해보시면 좋을것 같습니다.
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| @EnableRetry |
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.
RetryConfig 보다는 AppConfig라고 명명하고 추후 앱관련 공통설정은 여기다 몰아넣는게 좋은것 같아요!
요구사항
기본
Spring Event - 파일 업로드 로직 분리하기
`-- schema.sql
CREATE TABLE binary_contents
(
id uuid PRIMARY KEY,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone,
file_name varchar(255) NOT NULL,
size bigint NOT NULL,
content_type varchar(100) NOT NULL,
status varchar(20) NOT NULL
);
-- ALTER TABLE binary_contents
-- ADD COLUMN updated_at timestamp with time zone;
-- ALTER TABLE binary_contents
`
Spring Event - 알림 기능 추가하기
`-- schema.sql
CREATE TABLE read_statuses
(
id uuid PRIMARY KEY,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone,
user_id uuid NOT NULL,
channel_id uuid NOT NULL,
last_read_at timestamp with time zone NOT NULL,
notification_enabled boolean NOT NULL,
UNIQUE (user_id, channel_id)
);
-- ALTER TABLE read_statuses
-- ADD COLUMN notification_enabled boolean NOT NULL;
`
알림 여부를 수정할 수 있게 ReadStatusUpdateRequest를 수정하세요.
사용자의 권한(Role)이 변경된 경우 알림을 받을 수 있도록 리팩토링하세요.
알림 API를 구현하세요.
NotificationDto를 정의하세요.
알림 조회
알림 확인
알림이 필요한 이벤트가 발행되었을 때 알림을 생성하세요.
`public class NotificationRequiredEventListener {
@TransactionalEventListener
public void on(MessageCreatedEvent event) {...}
@TransactionalEventListener
public void on(RoleUpdatedEvent event) {...}
}`
해당 채널의 알림 여부를 활성화한 ReadStatus를 조회합니다.
해당 ReadStatus의 사용자들에게 알림을 생성합니다.
단, 해당 메시지를 보낸 사람은 알림 대상에서 제외합니다.
on(RoleUpdatedEvent)
심화
주요 변경사항
스크린샷
멘토에게