fix scroll sorting
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user