Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-api
Commits
3f5aad29
Commit
3f5aad29
authored
Jan 24, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:Agent API 用户校验
parent
b1844a67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
ModelLinkRestImpl.java
...n/java/cn/com/poc/expose/rest/impl/ModelLinkRestImpl.java
+10
-8
No files found.
src/main/java/cn/com/poc/expose/rest/impl/ModelLinkRestImpl.java
View file @
3f5aad29
...
@@ -32,9 +32,7 @@ public class ModelLinkRestImpl implements ModelLinkRest {
...
@@ -32,9 +32,7 @@ public class ModelLinkRestImpl implements ModelLinkRest {
Assert
.
notBlank
(
dto
.
getAgentId
(),
"Agent Id Can't Null"
);
Assert
.
notBlank
(
dto
.
getAgentId
(),
"Agent Id Can't Null"
);
String
apiKey
=
httpServletRequest
.
getHeader
(
"x-api-key"
);
String
apiKey
=
httpServletRequest
.
getHeader
(
"x-api-key"
);
String
apiSecret
=
httpServletRequest
.
getHeader
(
"x-api-secret"
);
String
apiSecret
=
httpServletRequest
.
getHeader
(
"x-api-secret"
);
if
(
apiKey
==
null
||
apiSecret
==
null
)
{
checkApiKeyAndSecret
(
httpServletRequest
);
throw
new
BusinessException
(
"Api Key or Api Secret Can't Null"
);
}
return
agentApplicationApiService
.
conversation
(
apiKey
,
apiSecret
,
dto
.
getAgentId
());
return
agentApplicationApiService
.
conversation
(
apiKey
,
apiSecret
,
dto
.
getAgentId
());
}
}
...
@@ -42,9 +40,7 @@ public class ModelLinkRestImpl implements ModelLinkRest {
...
@@ -42,9 +40,7 @@ public class ModelLinkRestImpl implements ModelLinkRest {
public
void
completions
(
CompletionsDto
dto
,
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
public
void
completions
(
CompletionsDto
dto
,
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
String
apiKey
=
httpServletRequest
.
getHeader
(
"x-api-key"
);
String
apiKey
=
httpServletRequest
.
getHeader
(
"x-api-key"
);
String
apiSecret
=
httpServletRequest
.
getHeader
(
"x-api-secret"
);
String
apiSecret
=
httpServletRequest
.
getHeader
(
"x-api-secret"
);
if
(
apiKey
==
null
||
apiSecret
==
null
)
{
checkApiKeyAndSecret
(
httpServletRequest
);
throw
new
BusinessException
(
"Api Key or Api Secret Can't Null"
);
}
List
<
String
>
fileIds
=
new
ArrayList
<>();
List
<
String
>
fileIds
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
dto
.
getFileId
()))
{
if
(
StringUtils
.
isNotBlank
(
dto
.
getFileId
()))
{
fileIds
.
add
(
dto
.
getFileId
());
fileIds
.
add
(
dto
.
getFileId
());
...
@@ -56,9 +52,15 @@ public class ModelLinkRestImpl implements ModelLinkRest {
...
@@ -56,9 +52,15 @@ public class ModelLinkRestImpl implements ModelLinkRest {
public
String
uploadFile
(
String
agentId
,
String
conversationId
,
MultipartFile
file
,
HttpServletRequest
httpServletRequest
)
throws
Exception
{
public
String
uploadFile
(
String
agentId
,
String
conversationId
,
MultipartFile
file
,
HttpServletRequest
httpServletRequest
)
throws
Exception
{
String
apiKey
=
httpServletRequest
.
getHeader
(
"x-api-key"
);
String
apiKey
=
httpServletRequest
.
getHeader
(
"x-api-key"
);
String
apiSecret
=
httpServletRequest
.
getHeader
(
"x-api-secret"
);
String
apiSecret
=
httpServletRequest
.
getHeader
(
"x-api-secret"
);
if
(
apiKey
==
null
||
apiSecret
==
null
)
{
checkApiKeyAndSecret
(
httpServletRequest
);
return
agentApplicationApiService
.
uploadFile
(
apiKey
,
apiSecret
,
agentId
,
conversationId
,
file
);
}
private
void
checkApiKeyAndSecret
(
HttpServletRequest
httpServletRequest
)
{
String
apiKey
=
httpServletRequest
.
getHeader
(
"x-api-key"
);
String
apiSecret
=
httpServletRequest
.
getHeader
(
"x-api-secret"
);
if
(
StringUtils
.
isBlank
(
apiKey
)
||
StringUtils
.
isBlank
(
apiSecret
))
{
throw
new
BusinessException
(
"Api Key or Api Secret Can't Null"
);
throw
new
BusinessException
(
"Api Key or Api Secret Can't Null"
);
}
}
return
agentApplicationApiService
.
uploadFile
(
apiKey
,
apiSecret
,
agentId
,
conversationId
,
file
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment