Skip to content

Commit 58ef2a4

Browse files
committed
fix : 이미지 삭제
1 parent 31d3197 commit 58ef2a4

File tree

5 files changed

+44
-14
lines changed

5 files changed

+44
-14
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cmf.commitField.domain.noti.noti.event;
2+
3+
import lombok.Getter;
4+
import org.springframework.context.ApplicationEvent;
5+
6+
@Getter
7+
public class NotiEvent extends ApplicationEvent {
8+
private final String username;
9+
private final String message;
10+
11+
public NotiEvent(Object source, String username, String message) {
12+
super(source);
13+
this.username = username;
14+
this.message = message;
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cmf.commitField.domain.noti.noti.event;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import org.springframework.context.event.EventListener;
5+
import org.springframework.stereotype.Component;
6+
7+
@Component
8+
@RequiredArgsConstructor
9+
public class NotiListener {
10+
@EventListener
11+
public void handleNotiEvent(NotiEvent event) {
12+
System.out.println("NotiEvent: " + event.getMessage());
13+
}
14+
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
package cmf.commitField.global.scheduler;
22

33
import cmf.commitField.domain.noti.noti.service.NotiService;
4+
import cmf.commitField.domain.user.entity.User;
45
import cmf.commitField.domain.user.repository.UserRepository;
6+
import cmf.commitField.global.error.ErrorCode;
7+
import cmf.commitField.global.exception.CustomException;
58
import lombok.RequiredArgsConstructor;
9+
import org.springframework.context.ApplicationEventPublisher;
10+
import org.springframework.scheduling.annotation.Scheduled;
611
import org.springframework.stereotype.Component;
712

813
@Component
914
@RequiredArgsConstructor
1015
public class NotiTestScheduler {
1116
private final NotiService notiService;
1217
private final UserRepository userRepository;
18+
private final ApplicationEventPublisher eventPublisher;
1319

14-
// @Scheduled(cron = "0 44 * * * *")
15-
// public void test() {
16-
// System.out.println("test 실행");
17-
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
18-
//
19-
// if (authentication instanceof OAuth2AuthenticationToken) {
20-
// OAuth2User principal = (OAuth2User) authentication.getPrincipal();
21-
// Map<String, Object> attributes = principal.getAttributes();
22-
// String username = (String) attributes.get("login"); // GitHub ID
23-
// User user = userRepository.findByUsername(username).orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_USER));
24-
// notiService.createNoti(user);
25-
// }
26-
//
27-
// }
20+
@Scheduled(cron = "30 14 * * * *")
21+
public void test() {
22+
System.out.println("test 실행");
23+
24+
User user = userRepository.findById(1L).orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_USER));
25+
notiService.createNoti(user);
26+
// eventPublisher.publishEvent();
27+
}
2828
}

0 commit comments

Comments
 (0)