View Javadoc
1   package fr.tiogars.chat.domains.prompt.repositories;
2   
3   import java.util.List;
4   import java.util.UUID;
5   
6   import org.springframework.data.domain.Page;
7   import org.springframework.data.domain.Pageable;
8   import org.springframework.data.jpa.repository.JpaRepository;
9   
10  import fr.tiogars.chat.domains.prompt.entities.PromptEntity;
11  
12  /**
13   * Repository for prompt entities.
14   */
15  public interface PromptRepository extends JpaRepository<PromptEntity, UUID> {
16  
17      /**
18       * Find prompts by user ID.
19       *
20       * @param userId the user ID
21       * @param pageable pagination information
22       * @return page of prompts for the user
23       */
24      Page<PromptEntity> findByUserId(UUID userId, Pageable pageable);
25  
26      /**
27       * Find prompts by session ID.
28       *
29       * @param sessionId the session ID
30       * @param pageable pagination information
31       * @return page of prompts for the session
32       */
33      Page<PromptEntity> findBySessionId(String sessionId, Pageable pageable);
34  
35      /**
36       * Find prompts by user ID and session ID.
37       *
38       * @param userId the user ID
39       * @param sessionId the session ID
40       * @param pageable pagination information
41       * @return page of prompts for the user and session
42       */
43      Page<PromptEntity> findByUserIdAndSessionId(UUID userId, String sessionId, Pageable pageable);
44  
45      /**
46       * Find the most recent prompts for a user.
47       *
48       * @param userId the user ID
49       * @param limit the maximum number of results
50       * @return list of recent prompts
51       */
52      List<PromptEntity> findTopNByUserIdOrderByCreatedAtDesc(UUID userId, int limit);
53  }