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
02b4927f
Commit
02b4927f
authored
May 20, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
57e0e808
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
155 additions
and
99 deletions
+155
-99
MethodField.java
.../src/main/java/com/yanzuoguang/util/base/MethodField.java
+46
-5
ObjectHelper.java
...src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
+21
-21
MemoryCacheCenter.java
...in/java/com/yanzuoguang/util/cache/MemoryCacheCenter.java
+1
-1
CheckerHelper.java
.../main/java/com/yanzuoguang/util/helper/CheckerHelper.java
+5
-7
FileHelper.java
...src/main/java/com/yanzuoguang/util/helper/FileHelper.java
+12
-6
HttpHelper.java
...src/main/java/com/yanzuoguang/util/helper/HttpHelper.java
+3
-3
RandomHelper.java
...c/main/java/com/yanzuoguang/util/helper/RandomHelper.java
+5
-3
RunHelper.java
.../src/main/java/com/yanzuoguang/util/helper/RunHelper.java
+1
-1
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+3
-2
AbstractThreadList.java
.../java/com/yanzuoguang/util/thread/AbstractThreadList.java
+2
-2
RunPlan.java
...se/src/main/java/com/yanzuoguang/util/thread/RunPlan.java
+4
-3
RunPlanData.java
...rc/main/java/com/yanzuoguang/util/thread/RunPlanData.java
+4
-4
RunnableListAuto.java
...in/java/com/yanzuoguang/util/thread/RunnableListAuto.java
+1
-1
ThreadListData.java
...main/java/com/yanzuoguang/util/thread/ThreadListData.java
+3
-3
Ref.java
yzg-util-base/src/main/java/com/yanzuoguang/util/vo/Ref.java
+1
-0
CodePwdImpl.java
...il-db/src/main/java/com/yanzuoguang/code/CodePwdImpl.java
+9
-7
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+9
-8
TableSqlCache.java
...src/main/java/com/yanzuoguang/dao/impl/TableSqlCache.java
+3
-2
TableStruct.java
...b/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
+9
-9
AllBeanRowMapper.java
...c/main/java/com/yanzuoguang/db/impl/AllBeanRowMapper.java
+8
-7
ExcelConsole.java
...-db/src/main/java/com/yanzuoguang/excel/ExcelConsole.java
+4
-1
TokenHelper.java
...l-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
+1
-1
TokenLoad.java
...til-db/src/main/java/com/yanzuoguang/token/TokenLoad.java
+0
-2
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/base/MethodField.java
View file @
02b4927f
...
...
@@ -12,21 +12,62 @@ public class MethodField {
/**
* 名称
*/
p
ublic
String
name
;
p
rivate
String
name
;
/**
* 缩写名称
*/
p
ublic
String
nameSimple
;
p
rivate
String
nameSimple
;
/**
* 对应的字段
*/
p
ublic
Field
field
;
p
rivate
Field
field
;
/**
* 对应的获取方法
*/
p
ublic
Method
getMethod
;
p
rivate
Method
getMethod
;
/**
* 对应的设置方法
*/
public
Method
setMethod
;
private
Method
setMethod
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getNameSimple
()
{
return
nameSimple
;
}
public
void
setNameSimple
(
String
nameSimple
)
{
this
.
nameSimple
=
nameSimple
;
}
public
Field
getField
()
{
return
field
;
}
public
void
setField
(
Field
field
)
{
this
.
field
=
field
;
}
public
Method
getGetMethod
()
{
return
getMethod
;
}
public
void
setGetMethod
(
Method
getMethod
)
{
this
.
getMethod
=
getMethod
;
}
public
Method
getSetMethod
()
{
return
setMethod
;
}
public
void
setSetMethod
(
Method
setMethod
)
{
this
.
setMethod
=
setMethod
;
}
}
yzg-util-base/src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
View file @
02b4927f
...
...
@@ -156,10 +156,10 @@ public class ObjectHelper {
return
null
;
}
try
{
if
(
item
.
field
!=
null
&&
Modifier
.
isPublic
(
item
.
field
.
getModifiers
()))
{
return
item
.
field
.
get
(
target
);
}
else
if
(
item
.
get
Method
!=
null
&&
Modifier
.
isPublic
(
item
.
getMethod
.
getModifiers
()))
{
return
item
.
get
Method
.
invoke
(
target
);
if
(
item
.
getField
()
!=
null
&&
Modifier
.
isPublic
(
item
.
getField
()
.
getModifiers
()))
{
return
item
.
getField
()
.
get
(
target
);
}
else
if
(
item
.
get
GetMethod
()
!=
null
&&
Modifier
.
isPublic
(
item
.
getGetMethod
()
.
getModifiers
()))
{
return
item
.
get
GetMethod
()
.
invoke
(
target
);
}
}
catch
(
Exception
ex
)
{
ExceptionHelper
.
handleException
(
ObjectHelper
.
class
,
ex
,
field
);
...
...
@@ -206,14 +206,14 @@ public class ObjectHelper {
return
;
}
try
{
if
(
item
.
field
!=
null
&&
Modifier
.
isPublic
(
item
.
field
.
getModifiers
()))
{
Class
toType
=
item
.
field
.
getType
();
if
(
item
.
getField
()
!=
null
&&
Modifier
.
isPublic
(
item
.
getField
()
.
getModifiers
()))
{
Class
toType
=
item
.
getField
()
.
getType
();
Object
toValue
=
StringHelper
.
to
(
toType
,
value
);
item
.
field
.
set
(
target
,
toValue
);
}
else
if
(
item
.
setMethod
!=
null
&&
Modifier
.
isPublic
(
item
.
setMethod
.
getModifiers
()))
{
Class
toType
=
item
.
setMethod
.
getParameterTypes
()[
0
];
item
.
getField
()
.
set
(
target
,
toValue
);
}
else
if
(
item
.
getSetMethod
()
!=
null
&&
Modifier
.
isPublic
(
item
.
getSetMethod
()
.
getModifiers
()))
{
Class
toType
=
item
.
getSetMethod
()
.
getParameterTypes
()[
0
];
Object
toValue
=
StringHelper
.
to
(
toType
,
value
);
item
.
setMethod
.
invoke
(
target
,
toValue
);
item
.
getSetMethod
()
.
invoke
(
target
,
toValue
);
}
}
catch
(
Exception
ex
)
{
ExceptionHelper
.
handleException
(
ObjectHelper
.
class
,
ex
,
field
);
...
...
@@ -254,8 +254,8 @@ public class ObjectHelper {
if
(!
typeCache
.
containsKey
(
toName
))
{
MethodField
newObj
=
new
MethodField
();
typeCache
.
put
(
toName
,
newObj
);
newObj
.
name
=
fromName
;
newObj
.
nameSimple
=
toName
;
newObj
.
setName
(
fromName
)
;
newObj
.
setNameSimple
(
toName
)
;
}
return
typeCache
.
get
(
toName
);
}
...
...
@@ -307,8 +307,8 @@ public class ObjectHelper {
if
(
Modifier
.
isStatic
(
field
.
getModifiers
()))
{
continue
;
}
if
(
obj
.
field
==
null
)
{
obj
.
field
=
field
;
if
(
obj
.
getField
()
==
null
)
{
obj
.
setField
(
field
)
;
}
}
for
(
Method
method
:
methods
)
{
...
...
@@ -324,24 +324,24 @@ public class ObjectHelper {
continue
;
}
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
);
if
(
obj
.
setMethod
==
null
)
{
obj
.
set
Method
=
method
;
if
(
obj
.
getSetMethod
()
==
null
)
{
obj
.
set
SetMethod
(
method
)
;
}
}
else
if
(
methodNameSimple
.
startsWith
(
"get"
))
{
if
(
method
.
getReturnType
()
==
null
)
{
continue
;
}
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
);
if
(
obj
.
get
Method
==
null
)
{
obj
.
getMethod
=
method
;
if
(
obj
.
get
GetMethod
()
==
null
)
{
obj
.
setGetMethod
(
method
)
;
}
}
else
if
(
methodNameSimple
.
startsWith
(
"is"
))
{
if
(
method
.
getReturnType
()
==
null
)
{
continue
;
}
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
);
if
(
obj
.
get
Method
==
null
)
{
obj
.
getMethod
=
method
;
if
(
obj
.
get
GetMethod
()
==
null
)
{
obj
.
setGetMethod
(
method
)
;
}
}
}
...
...
@@ -538,7 +538,7 @@ public class ObjectHelper {
return
to
;
}
for
(
Map
.
Entry
<
String
,
MethodField
>
field
:
mapField
.
entrySet
())
{
String
name
=
field
.
getValue
().
name
;
String
name
=
field
.
getValue
().
getName
()
;
Object
fromValue
=
ObjectHelper
.
get
(
from
,
name
);
if
(
StringHelper
.
isEmpty
(
fromValue
))
{
continue
;
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/cache/MemoryCacheCenter.java
View file @
02b4927f
...
...
@@ -16,7 +16,7 @@ public class MemoryCacheCenter {
/**
* 缓存的对象
*/
public
static
List
<
MemoryCache
>
CLEAR_LIST
=
new
Vector
<
MemoryCache
>();
public
final
static
List
<
MemoryCache
>
CLEAR_LIST
=
new
Vector
<
MemoryCache
>();
static
{
init
();
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/CheckerHelper.java
View file @
02b4927f
...
...
@@ -11,12 +11,13 @@ import java.util.regex.Pattern;
/**
* 参数业务逻辑校验
*
* @author 颜佐光
*/
public
final
class
CheckerHelper
{
public
static
final
String
PARAM_NOT_NULL_TIPS
=
"param [%s] is null"
;
public
static
final
String
PARAM_NOT_EMPTY_TIPS
=
"param [%s] is empty"
;
public
static
final
String
PARAM_NOT_NUMBER
=
"param [%s] must be number"
;
public
static
final
String
PARAM_NOT_NUMBER
=
"param [%s]
value [%s]
must be number"
;
public
static
final
String
PARAM_OVER_MAX_LENGTH
=
"param [%s] maxlength is "
;
public
static
final
String
PARAM_NOT_DATE_MONTH
=
"param [%s] must be yyyyMM"
;
...
...
@@ -176,9 +177,6 @@ public final class CheckerHelper {
String
eL
=
""
;
String
msg
=
""
;
if
(
StringHelper
.
isEmpty
(
paramVal
))
{
msg
=
PARAM_NOT_NULL_TIPS
;
this
.
checkResult
=
String
.
format
(
msg
,
paramName
,
paramVal
);
this
.
setValid
(
false
);
return
this
;
}
if
(
DATE_CHECK_TYPE_DAY
.
equals
(
queryType
))
{
...
...
@@ -328,7 +326,7 @@ public final class CheckerHelper {
return
this
;
}
if
(
paramVal
<
min
)
{
this
.
checkResult
=
String
.
format
(
PARAM_NOT_MIN
,
min
,
paramName
);
this
.
checkResult
=
String
.
format
(
PARAM_NOT_MIN
,
paramName
,
min
);
this
.
setValid
(
false
);
}
return
this
;
...
...
@@ -347,7 +345,7 @@ public final class CheckerHelper {
return
this
;
}
if
(
paramVal
>
max
)
{
this
.
checkResult
=
String
.
format
(
PARAM_NOT_MAX
,
max
,
paramName
);
this
.
checkResult
=
String
.
format
(
PARAM_NOT_MAX
,
paramName
,
max
);
this
.
setValid
(
false
);
}
return
this
;
...
...
@@ -367,7 +365,7 @@ public final class CheckerHelper {
return
this
;
}
if
(
paramVal
>
max
||
paramVal
<
min
)
{
this
.
checkResult
=
String
.
format
(
PARAM_NOT_RANGE
,
min
,
max
,
paramName
);
this
.
checkResult
=
String
.
format
(
PARAM_NOT_RANGE
,
paramName
,
min
,
max
);
this
.
setValid
(
false
);
}
return
this
;
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/FileHelper.java
View file @
02b4927f
...
...
@@ -87,18 +87,24 @@ public class FileHelper {
try
{
// 删除文件
if
(
file
.
exists
())
{
file
.
delete
();
if
(!
file
.
delete
())
{
throw
new
CodeException
(
"文件删除失败"
);
}
}
if
(
file
.
exists
())
{
throw
new
CodeException
(
"文件删除失败"
);
}
// 创建文件夹
File
parentFile
=
file
.
getParentFile
();
if
(
parentFile
!=
null
&&
!
parentFile
.
exists
())
{
parentFile
.
mkdirs
();
}
if
(!
parentFile
.
exists
())
{
throw
new
CodeException
(
"创建文件夹失败"
);
if
(
parentFile
!=
null
)
{
if
(!
parentFile
.
exists
())
{
if
(!
parentFile
.
mkdirs
())
{
throw
new
CodeException
(
"创建文件夹失败"
);
}
}
if
(!
parentFile
.
exists
())
{
throw
new
CodeException
(
"创建文件夹失败"
);
}
}
file
.
createNewFile
();
// 写入文件
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/HttpHelper.java
View file @
02b4927f
...
...
@@ -86,7 +86,7 @@ public class HttpHelper {
*/
public
static
String
post
(
HttpURLConnection
httpConn
,
String
jsonString
)
throws
IOException
{
// 返回的结果
String
result
=
""
;
String
Builder
result
=
new
StringBuilder
()
;
// 读取响应输入流
BufferedReader
in
=
null
;
PrintWriter
out
=
null
;
...
...
@@ -107,7 +107,7 @@ public class HttpHelper {
String
line
;
// 读取返回的内容
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
+=
line
;
result
.
append
(
line
)
;
}
}
finally
{
if
(
out
!=
null
)
{
...
...
@@ -117,7 +117,7 @@ public class HttpHelper {
in
.
close
();
}
}
return
result
;
return
result
.
toString
()
;
}
/**
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/RandomHelper.java
View file @
02b4927f
...
...
@@ -2,10 +2,12 @@ package com.yanzuoguang.util.helper;
import
com.yanzuoguang.util.contants.SystemContants
;
import
java.util.Random
;
import
java.util.UUID
;
/**
* 随机码生成工具
*
* @author 颜佐光
*/
public
final
class
RandomHelper
{
...
...
@@ -75,7 +77,7 @@ public final class RandomHelper {
* 随机生成指定字符集、指定长度的的随机码
*
* @param charset 基础字符集
* @param len 生成随机码长度
* @param len
生成随机码长度
* @return
*/
public
static
String
generateRandomCode
(
String
charset
,
int
len
)
{
...
...
@@ -102,12 +104,12 @@ public final class RandomHelper {
* @return
*/
private
static
String
generateRandomCodeOne
(
String
charset
,
int
len
)
{
int
index
=
(
int
)
(
Math
.
random
()
*
len
);
int
index
=
new
Random
().
nextInt
(
len
);
return
String
.
valueOf
(
charset
.
charAt
(
index
));
}
private
static
String
replace
(
String
str
,
String
olds
,
String
news
)
{
if
(
null
==
str
)
{
if
(
null
==
str
)
{
return
""
;
}
while
(
str
.
indexOf
(
olds
)
>
-
1
)
{
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/RunHelper.java
View file @
02b4927f
...
...
@@ -13,7 +13,7 @@ public class RunHelper {
/**
* 执行次数
*/
public
static
int
REQ_SIZE
=
3
;
public
final
static
int
REQ_SIZE
=
3
;
/**
* 执行次数,并且获取最后一次的异常
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
02b4927f
...
...
@@ -5,6 +5,7 @@ import com.yanzuoguang.util.exception.CodeException;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.Charset
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Arrays
;
...
...
@@ -531,7 +532,7 @@ public class StringHelper {
try
{
buff
=
from
.
getBytes
(
charset
);
// 将字节流转换为字符串
from
=
new
String
(
buff
);
from
=
new
String
(
buff
,
charset
);
from
=
from
.
replace
(
"\0"
,
""
).
replace
(
"\n"
,
""
);
}
catch
(
UnsupportedEncodingException
e
)
{
ExceptionHelper
.
handleException
(
StringHelper
.
class
,
e
,
from
);
...
...
@@ -781,7 +782,7 @@ public class StringHelper {
// 生成实现指定摘要算法的 MessageDigest 对象。
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
// 使用指定的字节数组更新摘要。
md
.
update
(
from
.
getBytes
());
md
.
update
(
from
.
getBytes
(
Charset
.
forName
(
"utf-8"
)
));
// 通过执行诸如填充之类的最终操作完成哈希计算。
byte
[]
b
=
md
.
digest
();
// 生成具体的md5密码到buf数组
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/thread/AbstractThreadList.java
View file @
02b4927f
...
...
@@ -16,7 +16,7 @@ public abstract class AbstractThreadList<T extends Object> implements ThreadWait
/**
* 线程等待间隔
*/
public
static
int
PrintTimeout
=
1000
*
2
;
public
final
static
int
PrintTimeout
=
1000
*
2
;
/**
* 线程数量
...
...
@@ -283,7 +283,7 @@ public abstract class AbstractThreadList<T extends Object> implements ThreadWait
}
ThreadListData
<
T
>
data
=
cacheThread
.
get
(
Thread
.
currentThread
());
data
.
setDate
(
new
Date
());
data
.
setDate
(
System
.
currentTimeMillis
());
data
.
setData
(
item
);
try
{
this
.
run
(
item
);
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/thread/RunPlan.java
View file @
02b4927f
...
...
@@ -10,6 +10,7 @@ import java.util.List;
/**
* 自动执行任务
*
* @author 颜佐光
*/
public
class
RunPlan
{
...
...
@@ -82,7 +83,7 @@ public class RunPlan {
*/
public
final
void
run
(
boolean
isRemove
,
int
maxError
)
{
for
(
int
i
=
list
.
size
()
-
1
;
i
>=
0
;
i
--)
{
Date
now
=
new
Date
();
long
now
=
System
.
currentTimeMillis
();
RunPlanData
item
;
synchronized
(
this
.
lock
)
{
item
=
list
.
size
()
>
i
?
list
.
get
(
i
)
:
null
;
...
...
@@ -96,10 +97,10 @@ public class RunPlan {
// 在Window CE中时间相减可能会出错
try
{
// 处理非法改动时间
if
(
item
.
getDate
()
.
compareTo
(
now
)
>
0
)
{
if
(
item
.
getDate
()
>
now
)
{
item
.
setDate
(
now
);
}
millSeconds
=
(
now
.
getTime
()
-
item
.
getDate
().
getTim
e
());
millSeconds
=
(
now
-
item
.
getDat
e
());
}
catch
(
Exception
ex
)
{
ExceptionHelper
.
handleException
(
ThreadHelper
.
class
,
ex
);
}
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/thread/RunPlanData.java
View file @
02b4927f
...
...
@@ -10,7 +10,7 @@ public class RunPlanData {
/**
* 任务开始时间
*/
private
Date
date
;
private
long
date
;
/**
* 执行标记
*/
...
...
@@ -39,11 +39,11 @@ public class RunPlanData {
this
.
initDate
();
}
public
Date
getDate
()
{
public
long
getDate
()
{
return
date
;
}
public
void
setDate
(
Date
date
)
{
public
void
setDate
(
long
date
)
{
this
.
date
=
date
;
}
...
...
@@ -106,6 +106,6 @@ public class RunPlanData {
* 重置时间
*/
public
void
initDate
()
{
this
.
date
=
new
Date
();
this
.
date
=
System
.
currentTimeMillis
();
}
}
yzg-util-base/src/main/java/com/yanzuoguang/util/thread/RunnableListAuto.java
View file @
02b4927f
...
...
@@ -17,7 +17,7 @@ public final class RunnableListAuto {
/**
* 是否打印线程日志
*/
public
static
boolean
IsLog
=
false
;
public
final
static
boolean
IsLog
=
false
;
/**
* 缓存的执行对象的数据大小
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/thread/ThreadListData.java
View file @
02b4927f
...
...
@@ -13,18 +13,18 @@ public class ThreadListData<T> {
/**
* 执行时间
*/
private
Date
date
;
private
long
date
;
/**
* 执行的数据
*/
private
T
data
;
public
Date
getDate
()
{
public
long
getDate
()
{
return
date
;
}
public
void
setDate
(
Date
date
)
{
public
void
setDate
(
long
date
)
{
this
.
date
=
date
;
}
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/vo/Ref.java
View file @
02b4927f
...
...
@@ -8,6 +8,7 @@ package com.yanzuoguang.util.vo;
*/
public
class
Ref
<
T
>
{
public
T
value
;
public
Ref
(
T
value
)
{
this
.
value
=
value
;
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/code/CodePwdImpl.java
View file @
02b4927f
...
...
@@ -10,6 +10,7 @@ import java.util.Random;
/**
* 加密算法0版实现
*
* @author 颜佐光
*/
public
class
CodePwdImpl
implements
CodePwd
{
...
...
@@ -38,25 +39,26 @@ public class CodePwdImpl implements CodePwd {
*/
@Override
public
String
getCode
(
String
rand
,
String
day
,
String
index
,
String
pwd
)
{
String
ret
=
""
;
String
Builder
ret
=
new
StringBuilder
()
;
// 1. 将随即数和天数进行组合生成字符串
String
randDay
=
""
;
String
Builder
sb
=
new
StringBuilder
()
;
{
int
randSize
=
rand
.
length
();
int
daySize
=
day
.
length
();
int
maxLen
=
Math
.
max
(
rand
.
length
(),
day
.
length
());
for
(
int
i
=
0
;
i
<
maxLen
;
i
++)
{
if
(
i
<
daySize
)
{
randDay
+=
day
.
charAt
(
i
);
sb
.
append
(
day
.
charAt
(
i
)
);
}
if
(
i
<
randSize
)
{
randDay
+=
rand
.
charAt
(
i
);
sb
.
append
(
rand
.
charAt
(
i
)
);
}
}
}
// 2. 将组合后的数字进行交换
String
randDay
=
sb
.
toString
();
int
randDaySize
=
randDay
.
length
();
char
[]
dayChars
=
new
char
[
randDaySize
];
{
...
...
@@ -71,7 +73,7 @@ public class CodePwdImpl implements CodePwd {
}
}
for
(
int
i
=
0
;
i
<
randDaySize
;
i
++)
{
ret
+=
dayChars
[
i
]
;
ret
.
append
(
dayChars
[
i
])
;
}
}
...
...
@@ -121,10 +123,10 @@ public class CodePwdImpl implements CodePwd {
for
(
int
i
=
0
;
i
<
newSize
;
i
++)
{
newValue
[
i
]
=
(
newValue
[
i
]
%
10
+
10
)
%
10
;
ret
+=
newValue
[
i
]
;
ret
.
append
(
newValue
[
i
])
;
}
return
ret
;
return
ret
.
toString
()
;
}
public
static
void
test
(
String
[]
args
)
{
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
02b4927f
...
...
@@ -44,7 +44,7 @@ public abstract class BaseDaoSql {
/**
* 缓存的表结构和SQL语句
*/
protected
static
MemoryCache
<
TableSqlCache
>
cache
=
new
MemoryCache
<>();
protected
final
static
MemoryCache
<
TableSqlCache
>
cache
=
new
MemoryCache
<>();
/**
* 获取数据库执行类
...
...
@@ -416,16 +416,17 @@ public abstract class BaseDaoSql {
String
[]
lastCode
=
new
String
[]{
"{WHERE}"
,
"{GROUP}"
,
"{HAVING}"
,
"{ORDER}"
,
"{LIMIT}"
};
// 将SQL语句进行代码片段追加
String
sql
=
sqlData
.
getSql
(
);
String
Builder
sb
=
new
StringBuilder
(
sqlData
.
getSql
()
);
for
(
String
code
:
lastCode
)
{
if
(
s
ql
.
indexOf
(
code
)
==
-
1
)
{
s
ql
+=
code
;
if
(
s
b
.
indexOf
(
code
)
==
-
1
)
{
s
b
.
append
(
code
)
;
}
}
// 代码片段缓存
Map
<
String
,
List
<
String
>>
codeMap
=
new
HashMap
<>(
DaoConst
.
COLLECTION_INIT_SIZE
);
// 处理字段以及代码片段
String
sql
=
sb
.
toString
();
sql
=
handleCodeRelease
(
sql
,
sqlData
,
model
,
codeMap
);
sql
=
handleCodeReplace
(
sql
,
codeMap
);
...
...
@@ -682,7 +683,7 @@ public abstract class BaseDaoSql {
}
// 将对象转换为 Map 对象
Map
to
=
new
HashMap
<
String
,
Object
>(
DaoConst
.
COLLECTION_INIT_SIZE
);
Map
<
String
,
Object
>
to
=
new
HashMap
<
>(
DaoConst
.
COLLECTION_INIT_SIZE
);
if
(
from
instanceof
Map
)
{
to
=
(
Map
)
from
;
}
else
{
...
...
@@ -694,16 +695,16 @@ public abstract class BaseDaoSql {
sb
.
append
(
" SELECT "
);
// 处理列
for
(
Object
oItemKey
:
to
.
ke
ySet
())
{
for
(
Map
.
Entry
<
String
,
Object
>
oItemKey
:
to
.
entr
ySet
())
{
if
(
column
>
0
)
{
sb
.
append
(
","
);
}
String
itemKey
=
StringHelper
.
toString
(
oItemKey
);
String
itemKey
=
oItemKey
.
getKey
(
);
sb
.
append
(
"? AS "
+
itemKey
);
// 处理参数
Object
itemValue
=
to
.
get
(
oItemKey
);
Object
itemValue
=
oItemKey
.
getValue
(
);
itemValue
=
this
.
getParaValue
(
itemValue
);
paras
.
add
(
itemValue
);
column
++;
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/TableSqlCache.java
View file @
02b4927f
...
...
@@ -14,6 +14,7 @@ import java.util.regex.Pattern;
/**
* 缓存的SQL语句信息
*
* @author 颜佐光
*/
public
class
TableSqlCache
{
...
...
@@ -278,8 +279,8 @@ public class TableSqlCache {
}
private
String
replaceString
(
Map
<
String
,
StringBuilder
>
map
,
String
sql
)
{
for
(
String
key
:
map
.
ke
ySet
())
{
sql
=
sql
.
replace
(
key
,
map
.
get
(
key
).
toString
());
for
(
Map
.
Entry
<
String
,
StringBuilder
>
key
:
map
.
entr
ySet
())
{
sql
=
sql
.
replace
(
key
.
getKey
(),
key
.
getValue
(
).
toString
());
}
return
sql
;
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
View file @
02b4927f
...
...
@@ -95,20 +95,20 @@ public class TableStruct {
// 字段信息获取
MethodField
field
=
entry
.
getValue
();
if
(
field
.
field
==
null
&&
field
.
getMethod
==
null
)
{
if
(
field
.
getField
()
==
null
&&
field
.
getGetMethod
()
==
null
)
{
continue
;
}
String
fieldName
=
field
.
name
;
String
fieldInputName
=
field
.
name
;
String
fieldName
=
field
.
getName
()
;
String
fieldInputName
=
field
.
getName
()
;
Class
<?>
fieldType
=
String
.
class
;
TableAnnotation
annotation
=
null
;
if
(
field
.
field
!=
null
)
{
annotation
=
field
.
field
.
getAnnotation
(
TableAnnotation
.
class
);
fieldType
=
field
.
field
.
getType
();
}
else
if
(
field
.
get
Method
!=
null
)
{
annotation
=
field
.
get
Method
.
getAnnotation
(
TableAnnotation
.
class
);
fieldType
=
field
.
get
Method
.
getReturnType
();
if
(
field
.
getField
()
!=
null
)
{
annotation
=
field
.
getField
()
.
getAnnotation
(
TableAnnotation
.
class
);
fieldType
=
field
.
getField
()
.
getType
();
}
else
if
(
field
.
get
GetMethod
()
!=
null
)
{
annotation
=
field
.
get
GetMethod
()
.
getAnnotation
(
TableAnnotation
.
class
);
fieldType
=
field
.
get
GetMethod
()
.
getReturnType
();
}
if
(
annotation
!=
null
)
{
fieldName
=
annotation
.
value
();
...
...
yzg-util-db/src/main/java/com/yanzuoguang/db/impl/AllBeanRowMapper.java
View file @
02b4927f
...
...
@@ -25,6 +25,7 @@ import java.util.Map;
/**
* 将数据映射为结果
*
* @author 颜佐光
*/
public
class
AllBeanRowMapper
<
T
>
implements
RowMapper
<
T
>
{
...
...
@@ -138,8 +139,8 @@ public class AllBeanRowMapper<T> implements RowMapper<T> {
*/
public
static
MapRow
toLoweRow
(
MapRow
from
)
{
MapRow
to
=
new
MapRow
();
for
(
String
key
:
from
.
ke
ySet
())
{
to
.
put
(
underscoreNameBase
(
key
),
from
.
get
(
key
));
for
(
Map
.
Entry
<
String
,
Object
>
key
:
from
.
entr
ySet
())
{
to
.
put
(
underscoreNameBase
(
key
.
getKey
()),
key
.
getValue
(
));
}
return
to
;
}
...
...
@@ -152,9 +153,9 @@ public class AllBeanRowMapper<T> implements RowMapper<T> {
*/
public
static
Object
getLoweRowField
(
MapRow
from
,
String
field
)
{
field
=
underscoreNameBase
(
field
);
for
(
String
key
:
from
.
ke
ySet
())
{
if
(
underscoreNameBase
(
key
).
equals
(
field
))
{
return
from
.
get
(
key
);
for
(
Map
.
Entry
<
String
,
Object
>
key
:
from
.
entr
ySet
())
{
if
(
underscoreNameBase
(
key
.
getKey
()
).
equals
(
field
))
{
return
key
.
getValue
(
);
}
}
return
null
;
...
...
@@ -202,7 +203,7 @@ public class AllBeanRowMapper<T> implements RowMapper<T> {
Log
.
info
(
AllBeanRowMapper
.
class
,
"Intercepted TypeMismatchException for row %d and column '%s' with "
+
"value %s when setting property '%s' of type %s on object: %s"
,
rowNumber
,
column
,
value
,
pd
.
getName
(),
type
,
mappedObject
);
rowNumber
,
column
,
StringHelper
.
EMPTY
,
pd
.
getName
(),
type
,
mappedObject
);
}
else
{
throw
e
;
}
...
...
@@ -225,7 +226,7 @@ public class AllBeanRowMapper<T> implements RowMapper<T> {
Log
.
info
(
AllBeanRowMapper
.
class
,
"Intercepted TypeMismatchException for row %d and column '%s' with "
+
"value %s when setting property '%s' of type %s on object: %s"
,
rowNumber
,
column
,
value
,
pd
.
getName
(),
type
,
mappedObject
);
rowNumber
,
column
,
StringHelper
.
EMPTY
,
pd
.
getName
(),
type
,
mappedObject
);
}
else
{
throw
e
;
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExcelConsole.java
View file @
02b4927f
...
...
@@ -336,7 +336,10 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
workbook
=
null
;
}
File
file
=
new
File
(
this
.
getFileName
());
if
(
file
.
exists
()
&&
file
.
delete
())
{
if
(
file
.
exists
())
{
if
(!
file
.
delete
())
{
throw
new
CodeException
(
"文件删除失败"
);
}
}
return
this
;
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
View file @
02b4927f
...
...
@@ -40,7 +40,7 @@ public class TokenHelper {
/**
* 内存缓存
*/
protected
static
MemoryCache
<
TokenData
>
cache
=
new
MemoryCache
<>();
protected
final
static
MemoryCache
<
TokenData
>
cache
=
new
MemoryCache
<>();
/**
...
...
yzg-util-db/src/main/java/com/yanzuoguang/token/TokenLoad.java
View file @
02b4927f
package
com
.
yanzuoguang
.
token
;
import
com.yanzuoguang.util.vo.MapRow
;
/**
* 动态加载Token
*
...
...
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