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
edc89a28
Commit
edc89a28
authored
Sep 09, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
3eaf2dd2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
15 deletions
+75
-15
ArrayHelper.java
...rc/main/java/com/yanzuoguang/util/helper/ArrayHelper.java
+68
-0
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+1
-4
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+6
-11
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/ArrayHelper.java
0 → 100755
View file @
edc89a28
package
com
.
yanzuoguang
.
util
.
helper
;
import
java.util.*
;
/**
* 字符串帮主类
*
* @author 颜佐光
*/
public
class
ArrayHelper
{
/**
* 合并为数组列表
*
* @param from 参数列表
* @param froms 参数列表
* @return 第一个非空字符串
*/
public
static
<
T
extends
Object
>
List
<
T
>
megerNotEmpty
(
T
from
,
List
<
T
>
froms
)
{
List
<
T
>
tos
=
new
ArrayList
<>();
if
(!
StringHelper
.
isEmpty
(
from
))
{
tos
.
add
(
from
);
}
if
(
froms
!=
null
)
{
for
(
T
item
:
froms
)
{
if
(!
StringHelper
.
isEmpty
(
item
))
{
tos
.
add
(
item
);
}
}
}
return
tos
;
}
/**
* 判断对象是否是数组或者List
*
* @param val
* @return
*/
public
static
boolean
isArrayOrList
(
Object
val
)
{
boolean
isArray
=
val
!=
null
&&
(
val
instanceof
List
||
val
.
getClass
().
isArray
());
return
isArray
;
}
/**
* 获取对象为对象列表
*
* @param val 需要获取的对象,可以为List或者Array或者其他对象.
* @return
*/
public
static
List
getList
(
Object
val
)
{
boolean
isArray
=
isArrayOrList
(
val
);
List
list
;
// 判断处理
if
(
val
instanceof
List
)
{
list
=
(
List
)
val
;
}
else
if
(
isArray
)
{
Object
[]
arr
=
(
Object
[])
val
;
list
=
Arrays
.
asList
(
arr
);
}
else
{
list
=
new
ArrayList
();
list
.
add
(
val
);
}
return
list
;
}
}
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
edc89a28
...
@@ -8,10 +8,7 @@ import java.io.UnsupportedEncodingException;
...
@@ -8,10 +8,7 @@ import java.io.UnsupportedEncodingException;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.security.MessageDigest
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
edc89a28
...
@@ -7,6 +7,7 @@ import com.yanzuoguang.db.impl.DbRow;
...
@@ -7,6 +7,7 @@ import com.yanzuoguang.db.impl.DbRow;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.ArrayHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeData
;
...
@@ -526,7 +527,7 @@ public abstract class BaseDaoSql {
...
@@ -526,7 +527,7 @@ public abstract class BaseDaoSql {
// 根据输入字段从参数中取值
// 根据输入字段从参数中取值
Object
val
=
ObjectHelper
.
get
(
model
,
field
);
Object
val
=
ObjectHelper
.
get
(
model
,
field
);
// 判断是否为数组
// 判断是否为数组
boolean
isArray
=
val
!=
null
&&
(
val
instanceof
List
||
val
.
getClass
().
isArray
()
);
boolean
isArray
=
ArrayHelper
.
isArrayOrList
(
val
);
if
(
isArray
)
{
if
(
isArray
)
{
sql
=
getListSql
(
paras
,
sql
,
name
,
val
);
sql
=
getListSql
(
paras
,
sql
,
name
,
val
);
}
else
{
}
else
{
...
@@ -547,7 +548,9 @@ public abstract class BaseDaoSql {
...
@@ -547,7 +548,9 @@ public abstract class BaseDaoSql {
*/
*/
private
Object
getParaValue
(
Object
val
)
{
private
Object
getParaValue
(
Object
val
)
{
if
(
val
instanceof
Boolean
)
{
if
(
val
instanceof
Boolean
)
{
val
=
(
Boolean
)
val
?
1
:
0
;
val
=
(
Boolean
)
val
?
1
:
0
;
}
else
if
(
val
instanceof
Double
||
val
instanceof
Float
)
{
val
=
StringHelper
.
toDouble
(
val
);
}
}
val
=
StringHelper
.
toString
(
val
);
val
=
StringHelper
.
toString
(
val
);
return
val
;
return
val
;
...
@@ -563,15 +566,7 @@ public abstract class BaseDaoSql {
...
@@ -563,15 +566,7 @@ public abstract class BaseDaoSql {
* @return 获取包含列表的SQL语句的值
* @return 获取包含列表的SQL语句的值
*/
*/
private
String
getListSql
(
List
<
Object
>
paras
,
String
sql
,
String
name
,
Object
val
)
{
private
String
getListSql
(
List
<
Object
>
paras
,
String
sql
,
String
name
,
Object
val
)
{
List
list
;
List
list
=
ArrayHelper
.
getList
(
val
);
// 判断处理
if
(
val
instanceof
List
)
{
list
=
(
List
)
val
;
}
else
{
Object
[]
arr
=
(
Object
[])
val
;
list
=
Arrays
.
asList
(
arr
);
}
int
length
=
list
.
size
();
int
length
=
list
.
size
();
// 进行循环
// 进行循环
...
...
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