Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ask_data_ai_admin
Project
Project
Details
Activity
Releases
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
linyangyang
ask_data_ai_admin
Commits
a52c0d1b
Commit
a52c0d1b
authored
Aug 04, 2025
by
林洋洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改sql 工具
parent
1e8636b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
59 deletions
+2
-59
SqlTools.java
...ask-data-ai-biz/src/main/java/com/ask/tools/SqlTools.java
+2
-59
No files found.
ask-data-ai/ask-data-ai-biz/src/main/java/com/ask/tools/SqlTools.java
View file @
a52c0d1b
...
...
@@ -69,67 +69,10 @@ public class SqlTools {
*/
@Tool
(
description
=
"Postgres执行参数化SQL查询,支持命名参数,更安全"
)
public
List
<
Map
<
String
,
Object
>>
selectBySqlWithParams
(
@ToolParam
(
description
=
"SQL查询语句,支持命名参数如 :name"
)
String
sql
,
@ToolParam
(
description
=
"参数Map,key为参数名,value为参数值"
)
Map
<
String
,
Object
>
params
)
{
@ToolParam
(
description
=
"完整SQL查询语句"
)
String
sql
)
{
log
.
info
(
"selectBySqlWithParams:{}"
,
sql
);
return
executeQuery
(
sql
,
params
!=
null
?
params
:
Collections
.
emptyMap
());
return
executeQuery
(
sql
,
Collections
.
emptyMap
());
}
// /**
// * 执行分页查询
// *
// * @param sql SQL查询语句
// * @param offset 偏移量
// * @param limit 限制数量
// * @return 查询结果列表
// */
// @Tool(description = "执行分页查询")
// public List<Map<String, Object>> selectBySqlWithPaging(
// @ToolParam(description = "SQL查询语句") String sql,
// @ToolParam(description = "偏移量,从0开始") int offset,
// @ToolParam(description = "每页数量,最大1000") int limit) {
//
// // 限制分页参数
// offset = Math.max(0, offset);
// limit = Math.min(Math.max(1, limit), maxResults);
//
// String pagedSql = sql + " LIMIT " + limit + " OFFSET " + offset;
// return executeQuery(pagedSql, Collections.emptyMap());
// }
//
// /**
// * 获取查询结果总数
// *
// * @param sql 原始SQL查询语句
// * @return 总记录数
// */
// @Tool(description = "获取查询结果总数")
// public Long countBySql(@ToolParam(description = "SQL查询语句") String sql) {
//
// if (!isValidSql(sql)) {
// log.warn("无效的SQL语句: {}", sql);
// return 0L;
// }
//
// try {
// // 构建COUNT查询
// String countSql = "SELECT COUNT(*) FROM (" + sql + ") as count_query";
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
//
// Long count = jdbcTemplate.queryForObject(countSql, Long.class);
//
// stopWatch.stop();
// log.info("COUNT查询执行完成,耗时: {}ms", stopWatch.getTotalTimeMillis());
//
// return count != null ? count : 0L;
//
// } catch (Exception e) {
// log.error("COUNT查询异常: sql={}, error={}", sql, e.getMessage(), e);
// return 0L;
// }
// }
/**
* 执行查询的核心方法
*/
...
...
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