Skip to content
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

Revert "Hotfix alarm list get api" #859

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading