@@ -9,7 +9,7 @@ namespace SmartTalk.Core.Services.AiSpeechAssistant;
9
9
public interface IAiSpeechAssistantDataProvider : IScopedDependency
10
10
{
11
11
Task < ( Domain . AISpeechAssistant . AiSpeechAssistant , AiSpeechAssistantPromptTemplate , AiSpeechAssistantUserProfile ) >
12
- GetAiSpeechAssistantInfoByNumbersAsync ( string callerNumber , string didNumber , CancellationToken cancellationToken ) ;
12
+ GetAiSpeechAssistantInfoByNumbersAsync ( string callerNumber , string didNumber , int ? assistantId = null , CancellationToken cancellationToken = default ) ;
13
13
14
14
Task < Domain . AISpeechAssistant . AiSpeechAssistant > GetAiSpeechAssistantByNumbersAsync ( string didNumber , CancellationToken cancellationToken ) ;
15
15
@@ -28,7 +28,7 @@ public AiSpeechAssistantDataProvider(IRepository repository)
28
28
}
29
29
30
30
public async Task < ( Domain . AISpeechAssistant . AiSpeechAssistant , AiSpeechAssistantPromptTemplate , AiSpeechAssistantUserProfile ) >
31
- GetAiSpeechAssistantInfoByNumbersAsync ( string callerNumber , string didNumber , CancellationToken cancellationToken )
31
+ GetAiSpeechAssistantInfoByNumbersAsync ( string callerNumber , string didNumber , int ? assistantId = null , CancellationToken cancellationToken = default )
32
32
{
33
33
var assistantInfo =
34
34
from assistant in _repository . Query < Domain . AISpeechAssistant . AiSpeechAssistant > ( )
@@ -38,12 +38,13 @@ from promptTemplate in promptGroup.DefaultIfEmpty()
38
38
join userProfile in _repository . Query < AiSpeechAssistantUserProfile > ( ) . Where ( x => x . CallerNumber == callerNumber )
39
39
on assistant . Id equals userProfile . AssistantId into userProfileGroup
40
40
from userProfile in userProfileGroup . DefaultIfEmpty ( )
41
- where assistant . DidNumber == didNumber
42
41
select new
43
42
{
44
43
assistant , promptTemplate , userProfile
45
44
} ;
46
45
46
+ assistantInfo = assistantInfo . Where ( x => assistantId . HasValue ? x . assistant . Id == assistantId . Value : x . assistant . DidNumber == didNumber ) ;
47
+
47
48
var result = await assistantInfo . FirstOrDefaultAsync ( cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
48
49
49
50
return ( result . assistant , result . promptTemplate , result . userProfile ) ;
0 commit comments