Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
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
YZG
yzg-util
Commits
87c096d0
Commit
87c096d0
authored
May 09, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excel导出功能
parent
d11ca8a5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+12
-11
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
87c096d0
...
...
@@ -422,9 +422,12 @@ public abstract class BaseDaoSql {
sql
+=
code
;
}
}
// 代码片段缓存
Map
<
String
,
List
<
String
>>
codeMap
=
new
HashMap
<>(
DaoConst
.
COLLECTION_INIT_SIZE
);
// 代码片段处理
sql
=
handleCodeMap
(
sql
,
sqlData
,
model
);
// 处理字段以及代码片段
sql
=
handleCodeRelease
(
sql
,
sqlData
,
model
,
codeMap
);
sql
=
handleCodeReplace
(
sql
,
codeMap
);
// 通过正则表达式处理参数 @name 并替换SQL语句成 ?
sql
=
handlePara
(
sql
,
paras
,
model
);
...
...
@@ -439,7 +442,7 @@ public abstract class BaseDaoSql {
* @param codeMap 替换内容
* @return Sql语句值
*/
protected
String
handleCodeRep
al
ce
(
String
sql
,
Map
<
String
,
List
<
String
>>
codeMap
)
{
protected
String
handleCodeRep
la
ce
(
String
sql
,
Map
<
String
,
List
<
String
>>
codeMap
)
{
// 正则表达式匹配代码片段,并根据代码片段获取数组进行增加
String
regex
=
"\\{.*?\\}"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
...
...
@@ -458,15 +461,15 @@ public abstract class BaseDaoSql {
}
/**
*
代码片段处理
*
生成代码片段缓存
*
* @param sql sql语句
* @param sqlData sql语句实体
* @param model 实体参数
* @param codeMap 缓存对象
* @return
*/
private
String
handleCodeMap
(
String
sql
,
SqlData
sqlData
,
Object
model
)
{
// 处理字段以及代码片段
// 代码片段缓存
Map
<
String
,
List
<
String
>>
codeMap
=
new
HashMap
<>(
DaoConst
.
COLLECTION_INIT_SIZE
);
private
String
handleCodeRelease
(
String
sql
,
SqlData
sqlData
,
Object
model
,
Map
<
String
,
List
<
String
>>
codeMap
)
{
// 循环处理字段
for
(
SqlDataField
field
:
sqlData
.
getSqlDataFields
())
{
// 获取值
...
...
@@ -500,8 +503,6 @@ public abstract class BaseDaoSql {
addCodeMap
(
codeMap
,
codeName
,
codeValue
);
}
}
sql
=
handleCodeRepalce
(
sql
,
codeMap
);
return
sql
;
}
...
...
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