-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserConversationService.java
More file actions
29 lines (23 loc) · 1.06 KB
/
UserConversationService.java
File metadata and controls
29 lines (23 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.example.spring.app.llm.userConversation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;
@Service
public class UserConversationService {
@Autowired
private UserConversationRepository userConversationRepository;
public UserConversationModel getUserConversation(String conversationId, String userId) {
return userConversationRepository.findByConversationIdAndUserId(conversationId, userId);
}
public UserConversationModel createNewConversationForUser(String userId) {
UserConversationModel newConversation = new UserConversationModel();
newConversation.setUserId(userId);
String conversationId = UUID.randomUUID().toString();
newConversation.setConversationId(conversationId);
return userConversationRepository.save(newConversation);
}
public List<UserConversationModel> getAllConversationsForUser(String userId) {
return userConversationRepository.findAllByUserId(userId);
}
}