Skip to content

Commit

Permalink
Merge pull request #859 from peer-42seoul/revert-858-hotfix-alarm-lis…
Browse files Browse the repository at this point in the history
…t-get-api

Revert "Hotfix alarm list get api"
  • Loading branch information
Paul2021-R authored Feb 14, 2024
2 parents e6c0c36 + 9d1d2e9 commit 0d6af05
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class NotificationController {

private final UserRepository userRepository;

///api/v1/noti/spring?type=${}&pgIdx=${number}&pgSize={number}
@GetMapping("/spring")
public ResponseEntity<?> getAlarmList(Authentication auth,
@Param("type") NotificationType type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import peer.backend.entity.noti.Notification;
import peer.backend.entity.noti.NotificationTarget;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

Expand All @@ -17,26 +16,14 @@ public interface NotificationTargetRepository extends JpaRepository<Notification
List<String> findUserListById(@Param("eventId") Long eventId);


@Query("SELECT m.specificEvent FROM NotificationTarget m " +
"WHERE (" +
"(m.columnIndex = :columnIndex AND m.userList LIKE %:userId% AND m.messageType = :type AND m.specificEvent.priority != 'SCHEDULED')" +
"OR " +
"(m.columnIndex = :columnIndex AND m.userList LIKE %:userId% AND m.messageType = :type AND m.specificEvent.priority = 'SCHEDULED' AND m.specificEvent.scheduledTime < :standardDate)" +
") ORDER BY m.createdAt DESC")
@Query("SELECT m.specificEvent FROM NotificationTarget m WHERE m.columnIndex = :columnIndex AND m.userList LIKE %:userId% AND m.messageType = :type ORDER BY m.createdAt DESC")
List<Notification> getAllEventsByColumnIndexAndUserIdAndMessageType(@Param("columnIndex") Long columnIndex,
@Param("userId") String userId,
@Param("type") NotificationType type,
@Param("standardDate") LocalDateTime standardDate);

@Query("SELECT m.specificEvent FROM NotificationTarget m " +
"WHERE (" +
"(m.columnIndex = :columnIndex AND m.userList LIKE %:userId% AND m.specificEvent.priority != 'SCHEDULED') " +
"OR " +
"(m.columnIndex = :columnIndex AND m.userList LIKE %:userId% AND m.specificEvent.priority = 'SCHEDULED' AND m.specificEvent.scheduledTime < :standardDate)" +
") ORDER BY m.createdAt DESC")
@Param("type") NotificationType type);

@Query("SELECT m.specificEvent FROM NotificationTarget m WHERE m.columnIndex = :columnIndex AND m.userList LIKE %:userId% ORDER BY m.createdAt DESC")
List<Notification> getAllEventsByColumnIndexAndUserId(@Param("columnIndex") Long columnIndex,
@Param("userId") String userId,
@Param("standardDate") LocalDateTime standardDate);
@Param("userId") String userId);

@Query("SELECT m FROM NotificationTarget m WHERE m.columnIndex = :columnIndex AND m.userList LIKE %:userId% ORDER BY m.createdAt DESC")
List<NotificationTarget> findAllByColumnIndexAndUserId(@Param("columnIndex") Long columnIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import peer.backend.repository.user.UserRepository;

import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -73,16 +72,14 @@ public List<NotificationDTO> getNotificationList(User user,
{
specificEventList = this.notificationTargetRepository.getAllEventsByColumnIndexAndUserId(
user.getId() / 100,
user.getId().toString(),
LocalDateTime.now()
user.getId().toString()
);
}
else {
specificEventList = this.notificationTargetRepository
.getAllEventsByColumnIndexAndUserIdAndMessageType(user.getId() / 100,
user.getId().toString(),
type,
LocalDateTime.now());
type);
}
int start = (int) (pgIndex * size - size);
int end = (int) (start + size - 1);
Expand Down

0 comments on commit 0d6af05

Please sign in to comment.