# sql-parsing
**Repository Path**: flycatzly/sql-parsing
## Basic Information
- **Project Name**: sql-parsing
- **Description**: 使用mybatis 动态sql语法 解析sql
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 10
- **Forks**: 6
- **Created**: 2022-02-24
- **Last Updated**: 2025-08-14
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# sql-parsing
#### 介绍
使用mybatis 动态sql语法 解析sql
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
例子:
getScript:SQL
resultMap:参数
getDbType:数据库类型 例如:mysql,oracle,postgresql
SqlMeta sqlMeta = SqlEngineUtil.getEngine().parse(getScript, resultMap,getDbType);
示例:
public void test06(){
String str="select c.agent_no,\n" +
"a.order_times>0 as order_flag,\n" +
"b.operator_no,\n" +
"b.open_id,\n" +
"b.union_id,\n" +
"a.view_times,\n" +
"a.order_times,\n" +
"a.actual_amt as order_amt,\n" +
"a.active_times,\n" +
"a.service_times,\n" +
"e.nick_name as user_name,\n" +
"b.head_portrait\n" +
"from (select distinct agent_no,operator_no,max(create_time) create_time from dwd.dwd_agent_customer_relation group by agent_no,operator_no) c\n" +
"inner join ads.ads_user_behavior a on a.operator_no=c.operator_no\n" +
"\n" +
" \n" +
" and a.order_times >0\n" +
" \n" +
" \n" +
" \n" +
" \n" +
"\n" +
"left join dwd.dwd_user_info b on a.operator_no=b.operator_no\n" +
"left join dwd.dwd_user_di e on a.operator_no=e.operator_no\n" +
"where c.agent_no= #{agent_no}\n" +
"\n" +
" and b.user_name= #{user_name}\n" +
"\n" +
"order by c.create_time,c.operator_no desc";
Map params = new HashMap<>();
params.put("agent_no","TEST001");
params.put("order_flag",false);
params.put("user_name","");
DynamicSqlEngine engine = new DynamicSqlEngine();
SqlMeta sqlMeta = engine.parse(str, params);
System.out.println(SQLUtils.format(sqlMeta.getSql(), DbType.mysql));
System.out.println(sqlMeta.getJdbcParamValues());
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)