You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package cn.teammodel.dao;
|
|
|
|
|
|
|
|
import cn.teammodel.model.entity.ai.ChatSession;
|
|
|
|
import com.azure.spring.data.cosmos.repository.CosmosRepository;
|
|
|
|
import com.azure.spring.data.cosmos.repository.Query;
|
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author winter
|
|
|
|
* @create 2023-11-28 17:39
|
|
|
|
*/
|
|
|
|
@Repository
|
|
|
|
public interface ChatSessionRepository extends CosmosRepository<ChatSession, String> {
|
|
|
|
@Query("select c.id, c.code, c.title, c.userId, c.createTime from c where c.code = 'ChatSession' and c.sessionId = @sessionId")
|
|
|
|
List<ChatSession> findBySessionId(String sessionId);
|
|
|
|
|
|
|
|
@Query("select c.id, c.code, c.title, c.userId, c.createTime from c where c.code = 'ChatSession' and c.userId = @userId")
|
|
|
|
List<ChatSession> findByUserId(String userId);
|
|
|
|
|
|
|
|
@Query("SELECT value ARRAY_SLICE(c.history, -3) FROM c where c.id = @sessionId and c.code = 'ChatSession'")
|
|
|
|
List<ChatSession.Message> findLatestMessage(String sessionId);
|
|
|
|
}
|