Skip to content

Commit 92a91c4

Browse files
committed
fix: runtime bugs
1 parent 21cee29 commit 92a91c4

File tree

6 files changed

+11
-53
lines changed

6 files changed

+11
-53
lines changed

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/mapper/AgentDatasourceMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.alibaba.cloud.ai.entity.AgentDatasource;
2020
import org.apache.ibatis.annotations.Delete;
21+
import org.apache.ibatis.annotations.Insert;
2122
import org.apache.ibatis.annotations.Mapper;
2223
import org.apache.ibatis.annotations.Param;
2324
import org.apache.ibatis.annotations.Select;
@@ -67,7 +68,7 @@ int countActiveByAgentIdExcluding(@Param("agentId") Integer agentId,
6768
@Delete("DELETE FROM agent_datasource WHERE datasource_id = #{datasourceId}")
6869
int deleteAllByDatasourceId(@Param("datasourceId") Integer datasourceId);
6970

70-
@Select("INSERT INTO agent_datasource (agent_id, datasource_id, is_active) VALUES (#{agentId}, #{datasourceId}, 1)")
71+
@Insert("INSERT INTO agent_datasource (agent_id, datasource_id, is_active) VALUES (#{agentId}, #{datasourceId}, 1)")
7172
int createNewRelationEnabled(@Param("agentId") Integer agentId, @Param("datasourceId") Integer datasourceId);
7273

7374
@Update("UPDATE agent_datasource SET is_active = #{isActive} WHERE agent_id = #{agentId} AND datasource_id = #{datasourceId}")

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/mapper/DatasourceMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.alibaba.cloud.ai.entity.Datasource;
2020
import org.apache.ibatis.annotations.Insert;
2121
import org.apache.ibatis.annotations.Mapper;
22+
import org.apache.ibatis.annotations.Options;
2223
import org.apache.ibatis.annotations.Param;
2324
import org.apache.ibatis.annotations.Select;
2425
import org.apache.ibatis.annotations.Update;
@@ -46,6 +47,7 @@ public interface DatasourceMapper {
4647
(name, type, host, port, database_name, username, password, connection_url, status, test_status, description, creator_id, create_time, update_time)
4748
VALUES (#{name}, #{type}, #{host}, #{port}, #{databaseName}, #{username}, #{password}, #{connectionUrl}, #{status}, #{testStatus}, #{description}, #{creatorId}, NOW(), NOW())
4849
""")
50+
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
4951
int insert(Datasource datasource);
5052

5153
/**

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/mapper/UserPromptConfigMapper.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.apache.ibatis.annotations.Delete;
2121
import org.apache.ibatis.annotations.Insert;
2222
import org.apache.ibatis.annotations.Mapper;
23-
import org.apache.ibatis.annotations.Options;
2423
import org.apache.ibatis.annotations.Param;
2524
import org.apache.ibatis.annotations.Select;
2625
import org.apache.ibatis.annotations.Update;
@@ -83,10 +82,9 @@ public interface UserPromptConfigMapper {
8382

8483
@Insert("""
8584
INSERT INTO user_prompt_config
86-
(name, prompt_type, system_prompt, enabled, description, priority, display_order, create_time, update_time, creator)
87-
VALUES (#{name}, #{promptType}, #{systemPrompt}, #{enabled}, #{description}, #{priority}, #{displayOrder}, NOW(), NOW(), #{creator})
85+
(id, name, prompt_type, system_prompt, enabled, description, priority, display_order, create_time, update_time, creator)
86+
VALUES (#{id}, #{name}, #{promptType}, #{systemPrompt}, #{enabled}, #{description}, #{priority}, #{displayOrder}, NOW(), NOW(), #{creator})
8887
""")
89-
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
9088
int insert(UserPromptConfig config);
9189

9290
@Select("""

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/service/UserPromptConfigService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public UserPromptConfig saveOrUpdateConfig(PromptConfigDTO configDTO) {
7979
else {
8080
// Create new configuration
8181
config = new UserPromptConfig();
82+
config.setId(UUID.randomUUID().toString());
8283
config.setName(configDTO.name());
8384
config.setPromptType(configDTO.promptType());
8485
config.setSystemPrompt(configDTO.optimizationPrompt());

spring-ai-alibaba-data-agent-management/src/main/java/com/alibaba/cloud/ai/controller/DatasourceController.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2024-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,11 +26,7 @@
2626
import java.util.Map;
2727
import java.util.HashMap;
2828

29-
/**
30-
* Data Source Controller
31-
*
32-
* @author Alibaba Cloud AI
33-
*/
29+
// todo: 不要吞掉所有异常,可以直接抛出,写一个Advice拦截异常并做日志
3430
@RestController
3531
@RequestMapping("/api/datasource")
3632
@CrossOrigin(origins = "*")

spring-ai-alibaba-data-agent-management/src/main/resources/application.yml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ server:
22
port: 8065
33
spring:
44
datasource:
5-
url: ${NL2SQL_DATASOURCE_URL:jdbc:mysql://127.0.0.1:3306/chat_bi?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowMultiQueries=true&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai}
5+
url: ${NL2SQL_DATASOURCE_URL:jdbc:mysql://127.0.0.1:3306/nl2sql_database?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowMultiQueries=true&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai}
66
username: ${NL2SQL_DATASOURCE_USERNAME:root}
7-
password: ${NL2SQL_DATASOURCE_PASSWORD:123456}
7+
password: ${NL2SQL_DATASOURCE_PASSWORD:root}
88
driver-class-name: com.mysql.cj.jdbc.Driver
99
type: com.alibaba.druid.pool.DruidDataSource
1010
jpa:
@@ -70,47 +70,7 @@ spring:
7070
mybatis:
7171
configuration:
7272
map-underscore-to-camel-case: true
73-
74-
# MyBatis Plus 配置
75-
mybatis-plus:
76-
configuration:
77-
# 开启驼峰命名转换
78-
map-underscore-to-camel-case: true
79-
# SQL 日志打印(生产环境建议关闭或使用 slf4j)
8073
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
81-
# 设置全局缓存开关
82-
cache-enabled: true
83-
# 延迟加载的核心开关
84-
lazy-loading-enabled: true
85-
# 按需加载属性
86-
aggressive-lazy-loading: false
87-
# 设置默认执行器类型
88-
default-executor-type: reuse
89-
# 设置默认语句超时时间
90-
default-statement-timeout: 30
91-
global-config:
92-
# 数据库配置
93-
db-config:
94-
# 主键类型(AUTO 自增,ASSIGN_ID 雪花算法,ASSIGN_UUID UUID)
95-
id-type: auto
96-
# 逻辑删除字段名
97-
logic-delete-field: deleted
98-
# 逻辑删除值(删除时设置的值)
99-
logic-delete-value: 1
100-
# 逻辑未删除值(正常时的值)
101-
logic-not-delete-value: 0
102-
# 字段验证策略
103-
insert-strategy: not_null
104-
update-strategy: not_null
105-
where-strategy: not_null
106-
# 关闭 MyBatis Plus 启动横幅
107-
banner: false
108-
# 是否开启 LOGO
109-
enable-sql-runner: false
110-
# Mapper XML 文件位置(如果有的话)
111-
mapper-locations: classpath*:/mapper/**/*.xml
112-
# 实体扫描,多个package用逗号或者分号分隔
113-
type-aliases-package: com.alibaba.cloud.ai.entity
11474

11575
# 日志配置
11676
logging:

0 commit comments

Comments
 (0)