Skip to content

Commit fed168f

Browse files
committed
Revert "[refactor] 알림 도메인 전면 수정 (#331)"
This reverts commit 420b227.
1 parent b8f5d8e commit fed168f

33 files changed

Lines changed: 812 additions & 703 deletions

backend/src/main/java/com/back/api/auth/service/AuthService.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.time.LocalDate;
44

55
import org.apache.commons.lang3.StringUtils;
6-
import org.springframework.context.ApplicationEventPublisher;
76
import org.springframework.security.crypto.password.PasswordEncoder;
87
import org.springframework.stereotype.Service;
98
import org.springframework.transaction.annotation.Transactional;
@@ -23,7 +22,6 @@
2322
import com.back.domain.auth.entity.RefreshToken;
2423
import com.back.domain.auth.repository.ActiveSessionRepository;
2524
import com.back.domain.auth.repository.RefreshTokenRepository;
26-
import com.back.domain.notification.systemMessage.NotificationMessage;
2725
import com.back.domain.store.entity.Store;
2826
import com.back.domain.user.entity.User;
2927
import com.back.domain.user.entity.UserActiveStatus;
@@ -51,7 +49,6 @@ public class AuthService {
5149
private final ActiveSessionRepository activeSessionRepository;
5250
private final AuthStore authStore;
5351
private final StoreService storeService;
54-
private final ApplicationEventPublisher eventPublisher;
5552
private final OAuthExchangeCodeStore codeStore;
5653

5754
@Transactional
@@ -92,14 +89,6 @@ public AuthResponse signup(SignupRequest request) {
9289

9390
JwtDto tokens = loginAsSingleDevice(savedUser);
9491

95-
// 알림 메시지 발행
96-
eventPublisher.publishEvent(
97-
NotificationMessage.signUp(
98-
savedUser.getId(),
99-
savedUser.getNickname()
100-
)
101-
);
102-
10392
return buildAuthResponse(savedUser, tokens);
10493
}
10594

backend/src/main/java/com/back/api/notification/controller/NotificationApi.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@ ApiResponse<Void> markAsRead(
4747
})
4848
ApiResponse<Void> markAllAsRead(
4949
);
50-
5150
}

backend/src/main/java/com/back/api/notification/controller/NotificationController.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
@RestController
2020
@RequiredArgsConstructor
21-
@RequestMapping("/api")
21+
@RequestMapping("/api/v1/notifications")
2222
public class NotificationController implements NotificationApi {
2323

2424
private final NotificationService notificationService;
2525
private final HttpRequestContext httpRequestContext;
2626

2727
@Override
28-
@GetMapping("/v2/notifications")
28+
@GetMapping
2929
public ApiResponse<List<NotificationResponseDto>> getNotifications(
3030
) {
3131
Long userId = httpRequestContext.getUserId();
@@ -39,7 +39,8 @@ public ApiResponse<List<NotificationResponseDto>> getNotifications(
3939
/**
4040
* 읽지 않은 알림 개수 조회
4141
*/
42-
@GetMapping("/v2/notifications/unread-count")
42+
@Override
43+
@GetMapping("/unread-count")
4344
public ApiResponse<UnreadCountResponseDto> getUnreadCount(
4445
) {
4546
Long userId = httpRequestContext.getUserId();
@@ -50,7 +51,8 @@ public ApiResponse<UnreadCountResponseDto> getUnreadCount(
5051
/**
5152
* 개별 알림 읽음 처리
5253
*/
53-
@PatchMapping("/v2/notifications/{notificationId}/read")
54+
@Override
55+
@PatchMapping("/{notificationId}/read")
5456
public ApiResponse<Void> markAsRead(
5557
@PathVariable Long notificationId
5658
) {
@@ -63,7 +65,8 @@ public ApiResponse<Void> markAsRead(
6365
/**
6466
* 전체 알림 읽음 처리
6567
*/
66-
@PatchMapping("/v2/notifications/read-all")
68+
@Override
69+
@PatchMapping("/read-all")
6770
public ApiResponse<Void> markAllAsRead() {
6871
Long userId = httpRequestContext.getUserId();
6972
notificationService.markAllAsRead(userId);

backend/src/main/java/com/back/api/notification/dto/NotificationResponseDto.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@
44

55
import com.back.domain.notification.entity.Notification;
66

7+
import io.swagger.v3.oas.annotations.media.Schema;
8+
9+
@Schema(description = "알림 조회 응답용 DTO")
710
public record NotificationResponseDto(
811
Long id,
9-
String type,
12+
String type, // enum name
13+
String typeDetail,
1014
String title,
11-
String content,
15+
String message,
16+
boolean isRead,
1217
LocalDateTime createdAt,
13-
Boolean isRead,
1418
LocalDateTime readAt
1519
) {
1620
public static NotificationResponseDto from(Notification notification) {
17-
1821
return new NotificationResponseDto(
1922
notification.getId(),
20-
notification.getType().getFrontType().name(),
23+
notification.getType().name(),
24+
notification.getTypeDetail().name(),
2125
notification.getTitle(),
22-
notification.getContent(),
23-
notification.getCreateAt(),
26+
notification.getMessage(),
2427
notification.isRead(),
28+
notification.getCreateAt(),
2529
notification.getReadAt()
2630
);
2731
}

backend/src/main/java/com/back/api/notification/listener/NotificationEventListener.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@ public void handleNotificationMessage(NotificationMessage message) {
3737
.orElseThrow(
3838
() -> new NoSuchElementException("ID " + message.getUserId() + "에 해당하는 사용자가 존재하지 않습니다."))
3939
)
40-
.type(message.getNotificationVar())
40+
.type(message.getNotificationType())
41+
.typeDetail(message.getTypeDetail())
4142
.domainName(message.getDomainName())
42-
.title(message.getNotificationVar().getTitle())
43-
.content(message.getNotificationVar().formatMessage(message.getContext()))
43+
.domainId(message.getDomainId())
44+
.title(message.getTitle())
45+
.message(message.getMessage())
4446
.isRead(false)
4547
.build();
4648

4749
notificationRepository.save(notification);
4850

4951
// 웹소켓으로 실시간 알림 전송
50-
v2_sendNotificationViaWebSocket(message.getUserId(), notification);
52+
sendNotificationViaWebSocket(message.getUserId(), notification);
5153

5254
} catch (Exception e) {
5355
}
@@ -59,7 +61,7 @@ public void handleNotificationMessage(NotificationMessage message) {
5961
* @param userId 대상 사용자 ID
6062
* @param notification 전송할 알림 엔티티
6163
*/
62-
private void v2_sendNotificationViaWebSocket(Long userId, Notification notification) {
64+
private void sendNotificationViaWebSocket(Long userId, Notification notification) {
6365

6466
boolean isOnline = sessionManager.isUserOnline(userId);
6567

backend/src/main/java/com/back/api/payment/payment/service/PaymentService.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.back.api.payment.order.service.OrderService;
1010
import com.back.api.payment.payment.client.PaymentClient;
11+
import com.back.domain.payment.order.entity.V2_Order;
1112
import com.back.api.payment.payment.dto.request.PaymentConfirmCommand;
1213
import com.back.api.payment.payment.dto.request.V2_PaymentConfirmRequest;
1314
import com.back.api.payment.payment.dto.response.PaymentConfirmResult;
@@ -16,9 +17,8 @@
1617
import com.back.api.payment.payment.dto.response.V2_PaymentConfirmResponse;
1718
import com.back.api.queue.service.QueueEntryProcessService;
1819
import com.back.api.ticket.service.TicketService;
19-
import com.back.domain.notification.systemMessage.NotificationMessage;
20+
import com.back.domain.notification.systemMessage.OrderSuccessMessage;
2021
import com.back.domain.payment.order.entity.Order;
21-
import com.back.domain.payment.order.entity.V2_Order;
2222
import com.back.domain.payment.payment.entity.ApproveStatus;
2323
import com.back.domain.ticket.entity.Ticket;
2424
import com.back.global.error.code.PaymentErrorCode;
@@ -96,10 +96,11 @@ public PaymentReceiptResponse confirmPayment(
9696

9797
// 알림 메시지 발행
9898
eventPublisher.publishEvent(
99-
NotificationMessage.paymentSuccess(
99+
new OrderSuccessMessage(
100100
userId,
101-
eventTitle,
102-
order.getAmount()
101+
orderId,
102+
order.getAmount(),
103+
eventTitle
103104
)
104105
);
105106

backend/src/main/java/com/back/api/payment/payment/service/PaymentTransactionService.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.back.api.payment.payment.dto.response.V2_PaymentConfirmResponse;
99
import com.back.api.queue.service.QueueEntryProcessService;
1010
import com.back.api.ticket.service.TicketService;
11-
import com.back.domain.notification.systemMessage.NotificationMessage;
11+
import com.back.domain.notification.systemMessage.OrderSuccessV2Message;
1212
import com.back.domain.payment.order.entity.OrderStatus;
1313
import com.back.domain.payment.order.entity.V2_Order;
1414
import com.back.domain.payment.order.repository.V2_OrderRepository;
@@ -109,12 +109,13 @@ public V2_PaymentConfirmResponse handleSuccess(
109109
userId
110110
);
111111

112-
// 알림 메시지 발행
112+
// 알림 발행
113113
eventPublisher.publishEvent(
114-
NotificationMessage.paymentSuccess(
114+
new OrderSuccessV2Message(
115115
userId,
116-
ticket.getEvent().getTitle(),
117-
order.getAmount()
116+
orderId,
117+
order.getAmount(),
118+
ticket.getEvent().getTitle()
118119
)
119120
);
120121

backend/src/main/java/com/back/api/preregister/service/PreRegisterService.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.back.api.s3.service.S3PresignedService;
1616
import com.back.domain.event.entity.Event;
1717
import com.back.domain.event.repository.EventRepository;
18-
import com.back.domain.notification.systemMessage.NotificationMessage;
18+
import com.back.domain.notification.systemMessage.PreRegisterDoneMessage;
1919
import com.back.domain.preregister.entity.PreRegister;
2020
import com.back.domain.preregister.entity.PreRegisterStatus;
2121
import com.back.domain.preregister.repository.PreRegisterRepository;
@@ -121,8 +121,9 @@ public PreRegisterResponse register(Long eventId, Long userId, PreRegisterCreate
121121
deleteSmsVerificationFlag(request.phoneNumber());
122122

123123
eventPublisher.publishEvent(
124-
NotificationMessage.preRegisterDone(
124+
new PreRegisterDoneMessage(
125125
userId,
126+
savedPreRegister.getId(),
126127
event.getTitle()
127128
)
128129
);
@@ -157,15 +158,6 @@ public void cancel(Long eventId, Long userId) {
157158
}
158159

159160
preRegister.cancel();
160-
161-
eventPublisher.publishEvent(
162-
NotificationMessage.preRegisterCancel(
163-
userId,
164-
eventRepository.findById(eventId)
165-
.map(Event::getTitle)
166-
.orElse("제목 없음")
167-
)
168-
);
169161
}
170162

171163
public boolean isRegistered(Long eventId, Long userId) {
@@ -180,7 +172,7 @@ public List<PreRegisterResponse> getMyPreRegister(Long userId) {
180172
.map(preRegister -> {
181173
Event event = preRegister.getEvent();
182174
String imageUrl = null;
183-
if (event.getImageUrl() != null && !event.getImageUrl().isBlank()) {
175+
if(event.getImageUrl() != null && !event.getImageUrl().isBlank()) {
184176
imageUrl = s3PresignedService.issueDownloadUrl(event.getImageUrl());
185177
}
186178

backend/src/main/java/com/back/api/queue/service/QueueEntryProcessService.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import com.back.api.ticket.service.TicketService;
2121
import com.back.domain.event.entity.Event;
2222
import com.back.domain.event.repository.EventRepository;
23-
import com.back.domain.notification.systemMessage.NotificationMessage;
23+
import com.back.domain.notification.systemMessage.QueueEntriesMessage;
24+
import com.back.domain.notification.systemMessage.QueueExpiredMessage;
2425
import com.back.domain.queue.entity.QueueEntry;
2526
import com.back.domain.queue.entity.QueueEntryStatus;
2627
import com.back.domain.queue.repository.QueueEntryRedisRepository;
@@ -71,8 +72,9 @@ public void processEntry(Long eventId, Long userId) {
7172
publishEnteredEvent(queueEntry); // 입장 처리 웹소켓 이벤트 발행
7273

7374
eventPublisher.publishEvent(
74-
NotificationMessage.queueEntered(
75+
new QueueEntriesMessage(
7576
userId,
77+
enqueue.getId(),
7678
eventRepository.findById(eventId)
7779
.map(Event::getTitle)
7880
.orElse("제목 없음")
@@ -318,7 +320,7 @@ public void expireEntry(Long eventId, Long userId) {
318320
}
319321

320322
queueEntry.expire();
321-
QueueEntry expired = queueEntryRepository.save(queueEntry);
323+
QueueEntry deque = queueEntryRepository.save(queueEntry);
322324

323325
try {
324326
queueEntryRedisRepository.removeFromEnteredQueue(eventId, userId);
@@ -330,8 +332,9 @@ public void expireEntry(Long eventId, Long userId) {
330332
publishExpiredEvent(queueEntry); // 만료 처리 웹소켓 이벤트 발행
331333

332334
eventPublisher.publishEvent(
333-
NotificationMessage.queueExpired(
335+
new QueueExpiredMessage(
334336
userId,
337+
deque.getId(),
335338
eventRepository.findById(eventId)
336339
.map(Event::getTitle)
337340
.orElse("제목 없음")
@@ -361,6 +364,15 @@ public void expireWaitingAndEnteredEntry(Long eventId, Long userId) {
361364

362365
publishExpiredEvent(queueEntry); // 만료 처리 웹소켓 이벤트 발행
363366

367+
eventPublisher.publishEvent(
368+
new QueueExpiredMessage(
369+
userId,
370+
deque.getId(),
371+
eventRepository.findById(eventId)
372+
.map(Event::getTitle)
373+
.orElse("제목 없음")
374+
)
375+
);
364376
}
365377

366378
@Transactional

backend/src/main/java/com/back/api/queue/service/QueueShuffleService.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.back.api.event.service.EventService;
1313
import com.back.domain.event.entity.Event;
1414
import com.back.domain.event.entity.EventStatus;
15-
import com.back.domain.notification.systemMessage.NotificationMessage;
1615
import com.back.domain.queue.entity.QueueEntry;
1716
import com.back.domain.queue.entity.QueueEntryStatus;
1817
import com.back.domain.queue.repository.QueueEntryRedisRepository;
@@ -21,7 +20,6 @@
2120
import com.back.domain.user.repository.UserRepository;
2221
import com.back.global.error.code.QueueEntryErrorCode;
2322
import com.back.global.error.exception.ErrorException;
24-
import com.back.global.event.EventPublisher;
2523

2624
import lombok.RequiredArgsConstructor;
2725
import lombok.extern.slf4j.Slf4j;
@@ -32,7 +30,6 @@
3230
* 자동으로 섞기 + 관리자 전용 수동 섞기
3331
* 공정한 대기열 생성 로직 논의 필요 -> 현재는 SecureRandom 이용한 랜덤 섞기 로직으로 구현
3432
*/
35-
3633
@Service
3734
@RequiredArgsConstructor
3835
@Slf4j
@@ -42,7 +39,6 @@ public class QueueShuffleService {
4239
private final QueueEntryRedisRepository queueEntryRedisRepository;
4340
private final UserRepository userRepository;
4441
private final EventService eventService;
45-
private final EventPublisher eventPublisher;
4642

4743
@Transactional
4844
public void shuffleQueue(Long eventId, List<Long> preRegisteredUserIds) {
@@ -61,8 +57,6 @@ public void shuffleQueue(Long eventId, List<Long> preRegisteredUserIds) {
6157
saveToRedis(eventId, shuffledUserIds);
6258
saveToDatabase(event, users, shuffledUserIds);
6359

64-
publishQueueWaitingNotifications(event, shuffledUserIds);
65-
6660
event.changeStatus(EventStatus.QUEUE_READY);
6761

6862
}
@@ -132,17 +126,4 @@ private void saveToDatabase(Event event, List<User> users, List<Long> shuffledUs
132126
}
133127
queueEntryRepository.saveAll(entries);
134128
}
135-
136-
private void publishQueueWaitingNotifications(Event event, List<Long> shuffledUserIds) {
137-
for (int i = 0; i < shuffledUserIds.size(); i++) {
138-
Long userId = shuffledUserIds.get(i);
139-
Long rank = (long)(i + 1);
140-
141-
eventPublisher.publishEvent(
142-
NotificationMessage.queueWaiting(userId, event.getTitle(), rank)
143-
);
144-
}
145-
}
146-
147129
}
148-

0 commit comments

Comments
 (0)