fix scroll sorting

This commit is contained in:
2026-04-15 13:05:50 -06:00
parent 89fb7554e0
commit f226e335c2
5 changed files with 14 additions and 12 deletions

View File

@@ -8,7 +8,8 @@ import java.util.List;
@Repository
public interface ConversationRepository extends JpaRepository<Conversation, Long> {
List<Conversation> findByCustomerId(Long customerId);
List<Conversation> findByStaffId(Long staffId);
List<Conversation> findByStaffIdIsNull();
List<Conversation> findByCustomerIdOrderByUpdatedAtDesc(Long customerId);
List<Conversation> findByStaffIdOrderByUpdatedAtDesc(Long staffId);
List<Conversation> findByStaffIdIsNullOrderByUpdatedAtDesc();
List<Conversation> findAllByOrderByUpdatedAtDesc();
}

View File

@@ -8,6 +8,7 @@ import java.util.List;
@Repository
public interface RefundRepository extends JpaRepository<Refund, Long> {
List<Refund> findByCustomerId(Long customerId);
List<Refund> findByCustomerIdOrderByCreatedAtDesc(Long customerId);
List<Refund> findAllByOrderByCreatedAtDesc();
List<Refund> findBySaleId(Long saleId);
}

View File

@@ -73,14 +73,14 @@ public class ChatService {
List<Conversation> conversations;
if (mine || role == User.Role.CUSTOMER) {
conversations = conversationRepository.findByCustomerId(userId);
conversations = conversationRepository.findByCustomerIdOrderByUpdatedAtDesc(userId);
} else if (role == User.Role.STAFF) {
List<Conversation> assignedToMe = conversationRepository.findByStaffId(userId);
List<Conversation> unassigned = conversationRepository.findByStaffIdIsNull();
List<Conversation> assignedToMe = conversationRepository.findByStaffIdOrderByUpdatedAtDesc(userId);
List<Conversation> unassigned = conversationRepository.findByStaffIdIsNullOrderByUpdatedAtDesc();
conversations = new java.util.ArrayList<>(assignedToMe);
conversations.addAll(unassigned);
} else {
conversations = conversationRepository.findAll();
conversations = conversationRepository.findAllByOrderByUpdatedAtDesc();
}
return conversations.stream()

View File

@@ -100,9 +100,9 @@ public class RefundService {
List<Refund> refunds;
if (customerId != null) {
refunds = refundRepository.findByCustomerId(customerId);
refunds = refundRepository.findByCustomerIdOrderByCreatedAtDesc(customerId);
} else {
refunds = refundRepository.findAll();
refunds = refundRepository.findAllByOrderByCreatedAtDesc();
}
return refunds.stream()