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
d491b855
Commit
d491b855
authored
May 08, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excel导出功能
parent
0946be07
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
13 deletions
+25
-13
MemoryCacheItem.java
...main/java/com/yanzuoguang/util/cache/MemoryCacheItem.java
+5
-4
RequestCacheResult.java
...in/java/com/yanzuoguang/cloud/aop/RequestCacheResult.java
+8
-0
HttpUploadHelper.java
...n/java/com/yanzuoguang/cloud/helper/HttpUploadHelper.java
+3
-3
WebFileHelper.java
...main/java/com/yanzuoguang/cloud/helper/WebFileHelper.java
+6
-3
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+3
-3
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/cache/MemoryCacheItem.java
View file @
d491b855
...
...
@@ -5,6 +5,7 @@ import java.util.Date;
/**
* 内存缓存值
*
* @param <T>
* @author 颜佐光
*/
...
...
@@ -13,7 +14,7 @@ public class MemoryCacheItem<T> {
/**
* 时间
*/
private
Date
date
=
new
Date
();
private
long
date
=
System
.
currentTimeMillis
();
/**
* 名称
...
...
@@ -29,15 +30,15 @@ public class MemoryCacheItem<T> {
* 激活数据
*/
public
void
active
()
{
date
=
new
Date
();
date
=
System
.
currentTimeMillis
();
}
public
Date
getDate
()
{
return
date
;
return
new
Date
(
date
)
;
}
public
void
setDate
(
Date
date
)
{
this
.
date
=
date
;
this
.
date
=
date
.
getTime
()
;
}
public
String
getName
()
{
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/RequestCacheResult.java
View file @
d491b855
...
...
@@ -41,6 +41,14 @@ public class RequestCacheResult {
return
System
.
currentTimeMillis
()
-
date
.
getTime
();
}
/**
* 请求编号
* @return
*/
public
String
getReqID
()
{
return
reqID
;
}
/**
* 获取结果
*
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/helper/HttpUploadHelper.java
View file @
d491b855
...
...
@@ -28,7 +28,7 @@ public final class HttpUploadHelper {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HttpUploadHelper
.
class
);
public
static
final
String
tagName
=
"file"
;
public
static
final
String
TAG_NAME
=
"file"
;
public
static
final
int
CONNECT_TIME_OUT
=
200000
;
...
...
@@ -53,9 +53,9 @@ public final class HttpUploadHelper {
if
(
responseEntity
!=
null
)
{
String
result
=
EntityUtils
.
toString
(
closeableHttpResponse
.
getEntity
());
logger
.
debug
(
"response result: {}"
,
result
);
EntityUtils
.
consume
(
responseEntity
);
return
result
;
}
EntityUtils
.
consume
(
responseEntity
);
closeableHttpResponse
.
close
();
return
JSON
.
toJSONString
(
initResponseError
());
}
catch
(
ClientProtocolException
e
)
{
...
...
@@ -96,7 +96,7 @@ public final class HttpUploadHelper {
private
static
HttpEntity
initRequestEntity
(
String
filePath
)
{
FileBody
fileBody
=
new
FileBody
(
new
File
(
filePath
));
StringBody
stringBody
=
new
StringBody
(
"This is comment"
,
ContentType
.
TEXT_PLAIN
);
return
MultipartEntityBuilder
.
create
().
addPart
(
tagName
,
fileBody
).
addPart
(
"comment"
,
stringBody
).
build
();
return
MultipartEntityBuilder
.
create
().
addPart
(
TAG_NAME
,
fileBody
).
addPart
(
"comment"
,
stringBody
).
build
();
}
/**
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/helper/WebFileHelper.java
View file @
d491b855
package
com
.
yanzuoguang
.
cloud
.
helper
;
import
com.yanzuoguang.cloud.vo.WebFileVo
;
import
com.yanzuoguang.util.contants.SystemContants
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.io.FileSystemResource
;
...
...
@@ -22,6 +24,7 @@ import java.util.UUID;
/**
* 上传文件,下载文件操作类
*
* @author 颜佐光
*/
public
final
class
WebFileHelper
{
...
...
@@ -147,8 +150,8 @@ public final class WebFileHelper {
public
static
WebFileVo
upload
(
MultipartFile
multipartFile
,
String
savePath
)
{
String
fileName
=
multipartFile
.
getOriginalFilename
();
if
(!
savePath
.
endsWith
(
"/"
)
||
!
savePath
.
endsWith
(
"\\"
))
{
savePath
+=
"/"
;
if
(!
savePath
.
endsWith
(
SystemContants
.
SLASH
)
||
!
savePath
.
endsWith
(
SystemContants
.
UNSLASH
))
{
savePath
+=
SystemContants
.
SLASH
;
}
webFileVo
=
new
WebFileVo
();
...
...
@@ -210,7 +213,7 @@ public final class WebFileHelper {
private
static
String
generateUUID
()
{
String
str
=
String
.
valueOf
(
UUID
.
randomUUID
());
while
(
str
.
indexOf
(
SEPARATE_HR
)
>=
0
)
{
str
=
str
.
replace
(
SEPARATE_HR
,
""
);
str
=
str
.
replace
(
SEPARATE_HR
,
StringHelper
.
EMPTY
);
}
return
str
;
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
d491b855
...
...
@@ -43,7 +43,7 @@ public abstract class BaseDaoSql {
/**
* 缓存的表结构和SQL语句
*/
protected
static
MemoryCache
<
TableSqlCache
>
C
ache
=
new
MemoryCache
<>();
protected
static
MemoryCache
<
TableSqlCache
>
c
ache
=
new
MemoryCache
<>();
/**
* 获取数据库执行类
...
...
@@ -67,11 +67,11 @@ public abstract class BaseDaoSql {
private
void
initTable
()
{
String
cls
=
this
.
getClass
().
getName
();
// 外检测,防止锁影响性能
this
.
table
=
C
ache
.
get
(
cls
);
this
.
table
=
c
ache
.
get
(
cls
);
// 判断是否已经取到对象
if
(
this
.
table
==
null
)
{
this
.
table
=
new
TableSqlCache
();
C
ache
.
put
(
cls
,
this
.
table
);
c
ache
.
put
(
cls
,
this
.
table
);
this
.
init
();
}
}
...
...
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