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
9df52bc3
Commit
9df52bc3
authored
Apr 13, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
不记录系统日志
parent
cec5bd9f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
9 deletions
+38
-9
SqlCondDefault.java
...rc/main/java/com/yanzuoguang/dao/cond/SqlCondDefault.java
+6
-0
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+31
-8
SqlCodeParameter.java
.../main/java/com/yanzuoguang/dao/impl/SqlCodeParameter.java
+1
-1
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/cond/SqlCondDefault.java
View file @
9df52bc3
package
com
.
yanzuoguang
.
dao
.
cond
;
package
com
.
yanzuoguang
.
dao
.
cond
;
import
com.yanzuoguang.dao.impl.SqlCodeParameter
;
import
com.yanzuoguang.dao.impl.SqlDataField
;
import
com.yanzuoguang.dao.impl.SqlDataField
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.helper.ArrayHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -51,6 +53,10 @@ public class SqlCondDefault extends SqlCondBase<SqlCondDefault> {
...
@@ -51,6 +53,10 @@ public class SqlCondDefault extends SqlCondBase<SqlCondDefault> {
if
(
StringHelper
.
isEmpty
(
val
)
||
StringHelper
.
isEmptyArray
(
val
))
{
if
(
StringHelper
.
isEmpty
(
val
)
||
StringHelper
.
isEmptyArray
(
val
))
{
continue
;
continue
;
}
}
// 代码片段
if
(
val
instanceof
SqlCodeParameter
&&
ArrayHelper
.
isEmpty
(((
SqlCodeParameter
)
val
).
getLatitude
()))
{
continue
;
}
// 只要有值不为空,则条件满足
// 只要有值不为空,则条件满足
return
COND_TYPE_CODE_COND
;
return
COND_TYPE_CODE_COND
;
}
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
9df52bc3
...
@@ -653,15 +653,19 @@ public abstract class BaseDaoSql {
...
@@ -653,15 +653,19 @@ public abstract class BaseDaoSql {
String
field
=
m
.
group
(
1
);
String
field
=
m
.
group
(
1
);
// 根据输入字段从参数中取值
// 根据输入字段从参数中取值
Object
val
=
ObjectHelper
.
get
(
model
,
field
);
Object
val
=
ObjectHelper
.
get
(
model
,
field
);
// 判断是否为数组
if
(
val
instanceof
SqlCodeParameter
)
{
boolean
isArray
=
ArrayHelper
.
isArrayOrList
(
val
);
sql
=
getSqlCodeParameter
(
paras
,
sql
,
name
,
(
SqlCodeParameter
)
val
);
if
(
isArray
)
{
sql
=
getListSql
(
paras
,
sql
,
name
,
val
);
}
else
{
}
else
{
// 当参数不为数组时,则直接增加
// 判断是否为数组
sql
=
sql
.
replaceFirst
(
name
,
"?"
);
boolean
isArray
=
ArrayHelper
.
isArrayOrList
(
val
);
val
=
this
.
getParaValue
(
val
);
if
(
isArray
)
{
paras
.
add
(
val
);
sql
=
getListSql
(
paras
,
sql
,
name
,
val
);
}
else
{
// 当参数不为数组时,则直接增加
sql
=
sql
.
replaceFirst
(
name
,
"?"
);
val
=
this
.
getParaValue
(
val
);
paras
.
add
(
val
);
}
}
}
}
}
return
sql
;
return
sql
;
...
@@ -715,6 +719,25 @@ public abstract class BaseDaoSql {
...
@@ -715,6 +719,25 @@ public abstract class BaseDaoSql {
return
sql
;
return
sql
;
}
}
/**
* 获取代码片段
*
* @param paras
* @param sql
* @param name
* @param val
* @return
*/
protected
String
getSqlCodeParameter
(
List
<
Object
>
paras
,
String
sql
,
String
name
,
SqlCodeParameter
val
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
Object
item
:
val
.
getLatitude
())
{
String
codeTo
=
StringHelper
.
getCodeString
(
val
.
getLatitudeCode
(),
item
);
sb
.
append
(
codeTo
);
}
sql
=
sql
.
replaceFirst
(
name
,
sb
.
toString
());
return
sql
;
}
/**
/**
* 添加数组型参数
* 添加数组型参数
*
*
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/SqlCodeParameter.java
View file @
9df52bc3
...
@@ -13,7 +13,7 @@ import java.util.List;
...
@@ -13,7 +13,7 @@ import java.util.List;
public
class
SqlCodeParameter
{
public
class
SqlCodeParameter
{
/**
/**
* 纬度
* 纬度
SQL语句,里面的{xxx}对应 latitude 数组中对象的字段.
*/
*/
private
String
latitudeCode
=
StringHelper
.
EMPTY
;
private
String
latitudeCode
=
StringHelper
.
EMPTY
;
...
...
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