@@ -28,11 +28,15 @@ private void saveNotification(final Long userId, final Long storeId, final Strin
2828 final String content , final NotificationType type , final String path ) {
2929 final String clickUrl = frontendUrl + path ;
3030 final List <String > tokens = deviceTokenRepository .findActiveTokensByUserId (userId );
31- for (String token : tokens ) {
32- final NotificationEntity notification = NotificationEntity .create (
33- userId , storeId , title , content , null , clickUrl , type , token
34- );
31+
32+ if (tokens .isEmpty ()) {
33+ final NotificationEntity notification = NotificationEntity .create (userId , storeId , title , content , null , clickUrl , type , null );
3534 notificationRepository .save (notification );
35+ } else {
36+ for (String token : tokens ) {
37+ final NotificationEntity notification = NotificationEntity .create (userId , storeId , title , content , null , clickUrl , type , token );
38+ notificationRepository .save (notification );
39+ }
3640 }
3741 }
3842
@@ -159,4 +163,17 @@ public void saveAttendanceEditRejectNotification(final AttendanceEditEntity atte
159163 public List <NotificationEntity > getNotificationsByUserAndStore (final Long userId , final Long storeId ) {
160164 return notificationRepository .findByUserIdAndStoreIdOrderByCreatedAtDesc (userId , storeId );
161165 }
166+
167+ @ Transactional
168+ public void saveWorkReportNotificationToBoss (final Long bossUserId , final Long storeId , final String staffName ) {
169+ String content = String .format ("%s님이 보고사항을 작성했어요." , staffName );
170+ saveNotification (
171+ bossUserId ,
172+ storeId ,
173+ "보고사항 작성" ,
174+ content ,
175+ NotificationType .WORK_REPORT ,
176+ "/boss/task?type=report"
177+ );
178+ }
162179}
0 commit comments