mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-31 03:32:43 +08:00
add client info
This commit is contained in:
@ -70,7 +70,7 @@ public class RdbDmlController {
|
|||||||
ListResult<ExecuteResult> resultDTOListResult = dlTemplateService.execute(param);
|
ListResult<ExecuteResult> resultDTOListResult = dlTemplateService.execute(param);
|
||||||
List<ExecuteResultVO> resultVOS = rdbWebConverter.dto2vo(resultDTOListResult.getData());
|
List<ExecuteResultVO> resultVOS = rdbWebConverter.dto2vo(resultDTOListResult.getData());
|
||||||
String type = Chat2DBContext.getConnectInfo().getDbType();
|
String type = Chat2DBContext.getConnectInfo().getDbType();
|
||||||
String clientId = getApiKey();
|
String clientId = getClientId(request.getClientId());
|
||||||
String sqlContent = request.getSql();
|
String sqlContent = request.getSql();
|
||||||
executorService.submit(() -> {
|
executorService.submit(() -> {
|
||||||
try {
|
try {
|
||||||
@ -102,11 +102,11 @@ public class RdbDmlController {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getApiKey() {
|
private String getClientId(String clientId) {
|
||||||
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
|
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
|
||||||
Config keyConfig = configService.find(Chat2dbAIClient.CHAT2DB_OPENAI_KEY).getData();
|
Config keyConfig = configService.find(Chat2dbAIClient.CHAT2DB_OPENAI_KEY).getData();
|
||||||
if (Objects.isNull(keyConfig) || StringUtils.isBlank(keyConfig.getContent())) {
|
if (Objects.isNull(keyConfig) || StringUtils.isBlank(keyConfig.getContent())) {
|
||||||
return null;
|
return clientId;
|
||||||
}
|
}
|
||||||
return keyConfig.getContent();
|
return keyConfig.getContent();
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ public class RdbDmlController {
|
|||||||
ExecuteResultVO executeResultVO = rdbWebConverter.dto2vo(result.getData());
|
ExecuteResultVO executeResultVO = rdbWebConverter.dto2vo(result.getData());
|
||||||
String type = Chat2DBContext.getConnectInfo().getDbType();
|
String type = Chat2DBContext.getConnectInfo().getDbType();
|
||||||
String sqlContent = request.getSql();
|
String sqlContent = request.getSql();
|
||||||
String clientId = getApiKey();
|
String clientId = getClientId(request.getClientId());
|
||||||
executorService.submit(() -> {
|
executorService.submit(() -> {
|
||||||
try {
|
try {
|
||||||
addOperationLog(clientId, type, sqlContent, result.getErrorMessage(), result.getSuccess(), Lists.newArrayList(executeResultVO));
|
addOperationLog(clientId, type, sqlContent, result.getErrorMessage(), result.getSuccess(), Lists.newArrayList(executeResultVO));
|
||||||
|
@ -44,4 +44,9 @@ public class DmlRequest extends DataSourceBaseRequest implements DataSourceConso
|
|||||||
* 只有select语句才有
|
* 只有select语句才有
|
||||||
*/
|
*/
|
||||||
private Boolean pageSizeAll;
|
private Boolean pageSizeAll;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端id
|
||||||
|
*/
|
||||||
|
private String clientId;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user