Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-enterprise-base
Overview
Overview
Details
Activity
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
base_platform_enterprise
gic-enterprise-base
Commits
c0974ffd
Commit
c0974ffd
authored
Sep 15, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部分pmd
parent
d0a11c02
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
368 additions
and
151 deletions
+368
-151
EnterpriseInfo.java
...src/main/java/com/gic/enterprise/base/EnterpriseInfo.java
+7
-1
UserInfo.java
...e-api/src/main/java/com/gic/enterprise/base/UserInfo.java
+7
-1
Constants.java
...src/main/java/com/gic/enterprise/constants/Constants.java
+7
-1
RequestContext.java
.../main/java/com/gic/enterprise/context/RequestContext.java
+7
-1
UserContext.java
...src/main/java/com/gic/enterprise/context/UserContext.java
+7
-1
Error.java
...ase-api/src/main/java/com/gic/enterprise/error/Error.java
+21
-1
ServiceValidateFilter.java
...java/com/gic/enterprise/filter/ServiceValidateFilter.java
+7
-1
UserTokenFilter.java
.../main/java/com/gic/enterprise/filter/UserTokenFilter.java
+7
-1
EnterpriseServiceResponse.java
...om/gic/enterprise/response/EnterpriseServiceResponse.java
+7
-1
AutoCreatePasswordUtils.java
...ava/com/gic/enterprise/utils/AutoCreatePasswordUtils.java
+7
-1
TokenUtils.java
...pi/src/main/java/com/gic/enterprise/utils/TokenUtils.java
+7
-1
UserDetail.java
...pi/src/main/java/com/gic/enterprise/utils/UserDetail.java
+7
-1
UserDetailUtils.java
...c/main/java/com/gic/enterprise/utils/UserDetailUtils.java
+7
-1
CrossFilter.java
.../src/main/java/com/gic/enterprise/filter/CrossFilter.java
+10
-4
FilterConfig.java
...src/main/java/com/gic/enterprise/filter/FilterConfig.java
+7
-1
AuthInterceptor.java
.../java/com/gic/enterprise/interceptor/AuthInterceptor.java
+38
-28
AbstractJsonSerializer.java
.../gic/enterprise/jsonseralizer/AbstractJsonSerializer.java
+16
-2
EncryptJsonSerializer.java
...m/gic/enterprise/jsonseralizer/EncryptJsonSerializer.java
+8
-2
LongTypeConverter.java
...a/com/gic/enterprise/jsonseralizer/LongTypeConverter.java
+8
-2
ParameterRequestWrapper.java
...a/com/gic/enterprise/request/ParameterRequestWrapper.java
+29
-6
EnterpriseRestResponse.java
...a/com/gic/enterprise/response/EnterpriseRestResponse.java
+7
-1
QrcodeTypeEnum.java
.../main/java/com/gic/download/constants/QrcodeTypeEnum.java
+13
-1
DownloadReportTempDTO.java
...main/java/com/gic/download/dto/DownloadReportTempDTO.java
+5
-0
QrcodeContent.java
...load/src/main/java/com/gic/download/qo/QrcodeContent.java
+7
-1
QrcodeQO.java
...-download/src/main/java/com/gic/download/qo/QrcodeQO.java
+11
-2
DataDownloadUtils.java
...c/main/java/com/gic/download/utils/DataDownloadUtils.java
+10
-5
DownloadUtils.java
...d/src/main/java/com/gic/download/utils/DownloadUtils.java
+23
-4
ExcelUtils.java
...load/src/main/java/com/gic/download/utils/ExcelUtils.java
+12
-50
OperationResultUtils.java
...ain/java/com/gic/download/utils/OperationResultUtils.java
+7
-1
QrcodeDownload.java
.../src/main/java/com/gic/download/utils/QrcodeDownload.java
+45
-27
LogUtils.java
...ad/src/main/java/com/gic/download/utils/log/LogUtils.java
+7
-1
No files found.
gic-enterprise-base-api/src/main/java/com/gic/enterprise/base/EnterpriseInfo.java
View file @
c0974ffd
...
@@ -2,7 +2,13 @@ package com.gic.enterprise.base;
...
@@ -2,7 +2,13 @@ package com.gic.enterprise.base;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
/**
* 商户信息
* @ClassName: EnterpriseInfo
* @Description:
* @author guojuxing
* @date 2020/9/15 10:15 AM
*/
public
class
EnterpriseInfo
implements
Serializable
{
public
class
EnterpriseInfo
implements
Serializable
{
/**
/**
* 企业主键
* 企业主键
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/base/UserInfo.java
View file @
c0974ffd
...
@@ -2,7 +2,13 @@ package com.gic.enterprise.base;
...
@@ -2,7 +2,13 @@ package com.gic.enterprise.base;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
/**
* 登录用户信息
* @ClassName: UserInfo
* @Description:
* @author guojuxing
* @date 2020/9/15 10:15 AM
*/
public
class
UserInfo
implements
Serializable
{
public
class
UserInfo
implements
Serializable
{
/**
/**
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/constants/Constants.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
constants
;
package
com
.
gic
.
enterprise
.
constants
;
/**
* 常量
* @ClassName: Constants
* @Description:
* @author guojuxing
* @date 2020/9/15 10:13 AM
*/
public
class
Constants
{
public
class
Constants
{
public
static
String
INDEX_ENTERPRISEID
=
"test-enterprise-20190716"
;
public
static
String
INDEX_ENTERPRISEID
=
"test-enterprise-20190716"
;
public
static
String
STORE_SCENECODE
=
"store"
;
public
static
String
STORE_SCENECODE
=
"store"
;
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/context/RequestContext.java
View file @
c0974ffd
...
@@ -5,7 +5,13 @@ import org.apache.logging.log4j.Logger;
...
@@ -5,7 +5,13 @@ import org.apache.logging.log4j.Logger;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
/**
* session
* @ClassName: RequestContext
* @Description:
* @author guojuxing
* @date 2020/9/15 10:16 AM
*/
public
class
RequestContext
{
public
class
RequestContext
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
RequestContext
.
class
);
private
static
final
Logger
log
=
LogManager
.
getLogger
(
RequestContext
.
class
);
private
ThreadLocal
<
HttpServletRequest
>
requestThreadLocal
=
new
ThreadLocal
<>();
private
ThreadLocal
<
HttpServletRequest
>
requestThreadLocal
=
new
ThreadLocal
<>();
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/context/UserContext.java
View file @
c0974ffd
...
@@ -12,7 +12,13 @@ import javax.servlet.http.Cookie;
...
@@ -12,7 +12,13 @@ import javax.servlet.http.Cookie;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
* session
* @ClassName: UserContext
* @Description:
* @author guojuxing
* @date 2020/9/15 10:16 AM
*/
public
class
UserContext
{
public
class
UserContext
{
/**
/**
* 有效期4小时
* 有效期4小时
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/error/Error.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
error
;
package
com
.
gic
.
enterprise
.
error
;
/**
* 错误
* @ClassName: Error
* @Description:
* @author guojuxing
* @date 2020/9/15 10:04 AM
*/
public
interface
Error
{
public
interface
Error
{
/**
* 获取错误code
* @Title: getErrorCode
* @Description:
* @author guojuxing
* @return java.lang.String
*/
String
getErrorCode
();
String
getErrorCode
();
/**
* 获取错误信息
* @Title: getErrorMsg
* @Description:
* @author guojuxing
* @return java.lang.String
*/
String
getErrorMsg
();
String
getErrorMsg
();
}
}
gic-enterprise-base-api/src/main/java/com/gic/enterprise/filter/ServiceValidateFilter.java
View file @
c0974ffd
...
@@ -10,7 +10,13 @@ import org.apache.dubbo.rpc.*;
...
@@ -10,7 +10,13 @@ import org.apache.dubbo.rpc.*;
import
java.lang.annotation.Annotation
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
java.util.Map
;
/**
* 数据处理
* @ClassName: ServiceValidateFilter
* @Description:
* @author guojuxing
* @date 2020/9/15 10:11 AM
*/
@Activate
(
group
=
{
CommonConstants
.
PROVIDER
})
@Activate
(
group
=
{
CommonConstants
.
PROVIDER
})
public
class
ServiceValidateFilter
implements
Filter
{
public
class
ServiceValidateFilter
implements
Filter
{
@Override
@Override
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/filter/UserTokenFilter.java
View file @
c0974ffd
...
@@ -8,7 +8,13 @@ import org.apache.dubbo.common.extension.Activate;
...
@@ -8,7 +8,13 @@ import org.apache.dubbo.common.extension.Activate;
import
org.apache.dubbo.rpc.*
;
import
org.apache.dubbo.rpc.*
;
import
org.apache.dubbo.rpc.filter.ConsumerContextFilter
;
import
org.apache.dubbo.rpc.filter.ConsumerContextFilter
;
/**
* session
* @ClassName: UserTokenFilter
* @Description:
* @author guojuxing
* @date 2020/9/15 10:12 AM
*/
@Activate
(
group
=
{
CommonConstants
.
CONSUMER
},
order
=
-
1000
)
@Activate
(
group
=
{
CommonConstants
.
CONSUMER
},
order
=
-
1000
)
public
class
UserTokenFilter
implements
Filter
{
public
class
UserTokenFilter
implements
Filter
{
@Override
@Override
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/response/EnterpriseServiceResponse.java
View file @
c0974ffd
...
@@ -2,7 +2,13 @@ package com.gic.enterprise.response;
...
@@ -2,7 +2,13 @@ package com.gic.enterprise.response;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.enterprise.error.Error
;
import
com.gic.enterprise.error.Error
;
/**
* 包装类
* @ClassName: EnterpriseServiceResponse
* @Description:
* @author guojuxing
* @date 2020/9/15 10:13 AM
*/
public
class
EnterpriseServiceResponse
<
T
>
extends
ServiceResponse
<
T
>
{
public
class
EnterpriseServiceResponse
<
T
>
extends
ServiceResponse
<
T
>
{
public
static
ServiceResponse
failure
(
Error
error
)
{
public
static
ServiceResponse
failure
(
Error
error
)
{
return
ServiceResponse
.
failure
(
error
.
getErrorCode
(),
error
.
getErrorMsg
());
return
ServiceResponse
.
failure
(
error
.
getErrorCode
(),
error
.
getErrorMsg
());
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/utils/AutoCreatePasswordUtils.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
utils
;
package
com
.
gic
.
enterprise
.
utils
;
import
com.gic.commons.util.Md5Util
;
import
com.gic.commons.util.Md5Util
;
/**
* 自动产生密码
* @ClassName: AutoCreatePasswordUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:43 AM
*/
public
class
AutoCreatePasswordUtils
{
public
class
AutoCreatePasswordUtils
{
/**
/**
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/utils/TokenUtils.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
utils
;
package
com
.
gic
.
enterprise
.
utils
;
/**
* token
* @ClassName: TokenUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:13 AM
*/
public
class
TokenUtils
{
public
class
TokenUtils
{
private
static
ThreadLocal
<
String
>
tokenThreadLocal
=
new
ThreadLocal
<>();
private
static
ThreadLocal
<
String
>
tokenThreadLocal
=
new
ThreadLocal
<>();
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/utils/UserDetail.java
View file @
c0974ffd
...
@@ -8,7 +8,13 @@ import com.gic.enterprise.base.UserResourceInfo;
...
@@ -8,7 +8,13 @@ import com.gic.enterprise.base.UserResourceInfo;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
* session
* @ClassName: UserDetail
* @Description:
* @author guojuxing
* @date 2020/9/15 10:15 AM
*/
public
class
UserDetail
implements
Serializable
{
public
class
UserDetail
implements
Serializable
{
private
Integer
userId
=
2222
;
private
Integer
userId
=
2222
;
private
UserInfo
userInfo
;
private
UserInfo
userInfo
;
...
...
gic-enterprise-base-api/src/main/java/com/gic/enterprise/utils/UserDetailUtils.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
utils
;
package
com
.
gic
.
enterprise
.
utils
;
import
com.gic.enterprise.context.UserContext
;
import
com.gic.enterprise.context.UserContext
;
/**
* session
* @ClassName: UserDetailUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:14 AM
*/
public
class
UserDetailUtils
{
public
class
UserDetailUtils
{
public
static
UserDetail
getUserDetail
(){
public
static
UserDetail
getUserDetail
(){
return
UserContext
.
getContext
().
get
();
return
UserContext
.
getContext
().
get
();
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/filter/CrossFilter.java
View file @
c0974ffd
...
@@ -5,7 +5,13 @@ import java.io.IOException;
...
@@ -5,7 +5,13 @@ import java.io.IOException;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
/**
* 跨域处理
* @ClassName: CrossFilter
* @Description:
* @author guojuxing
* @date 2020/9/15 10:16 AM
*/
public
class
CrossFilter
implements
Filter
{
public
class
CrossFilter
implements
Filter
{
@Override
@Override
public
void
init
(
javax
.
servlet
.
FilterConfig
filterConfig
)
throws
ServletException
{
public
void
init
(
javax
.
servlet
.
FilterConfig
filterConfig
)
throws
ServletException
{
...
@@ -13,10 +19,10 @@ public class CrossFilter implements Filter{
...
@@ -13,10 +19,10 @@ public class CrossFilter implements Filter{
}
}
@Override
@Override
public
void
doFilter
(
ServletRequest
_request
,
ServletResponse
_response
,
FilterChain
chain
)
public
void
doFilter
(
ServletRequest
requestFrom
,
ServletResponse
responseFrom
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
throws
IOException
,
ServletException
{
HttpServletRequest
request
=
(
HttpServletRequest
)
_request
;
HttpServletRequest
request
=
(
HttpServletRequest
)
requestFrom
;
HttpServletResponse
response
=
(
HttpServletResponse
)
_response
;
HttpServletResponse
response
=
(
HttpServletResponse
)
responseFrom
;
String
origin
=
request
.
getHeader
(
"Origin"
);
String
origin
=
request
.
getHeader
(
"Origin"
);
if
(
null
!=
origin
)
{
if
(
null
!=
origin
)
{
response
.
addHeader
(
"Access-Control-Allow-Origin"
,
origin
);
response
.
addHeader
(
"Access-Control-Allow-Origin"
,
origin
);
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/filter/FilterConfig.java
View file @
c0974ffd
...
@@ -3,7 +3,13 @@ package com.gic.enterprise.filter;
...
@@ -3,7 +3,13 @@ package com.gic.enterprise.filter;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
/**
* 拦截
* @ClassName: FilterConfig
* @Description:
* @author guojuxing
* @date 2020/9/15 10:16 AM
*/
@Configuration
@Configuration
public
class
FilterConfig
{
public
class
FilterConfig
{
@Bean
@Bean
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/interceptor/AuthInterceptor.java
View file @
c0974ffd
...
@@ -22,7 +22,13 @@ import java.util.HashMap;
...
@@ -22,7 +22,13 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
* 权限拦截
* @ClassName: AuthInterceptor
* @Description:
* @author guojuxing
* @date 2020/9/15 10:15 AM
*/
public
class
AuthInterceptor
extends
HandlerInterceptorAdapter
{
public
class
AuthInterceptor
extends
HandlerInterceptorAdapter
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
AuthInterceptor
.
class
);
private
static
final
Logger
log
=
LogManager
.
getLogger
(
AuthInterceptor
.
class
);
...
@@ -93,6 +99,37 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
...
@@ -93,6 +99,37 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
}
}
//接口调用,操作项类型的操作,需要 获取操作模块,一级、二级的ID和名称
//接口调用,操作项类型的操作,需要 获取操作模块,一级、二级的ID和名称
if
(
isOperationItemRequest
)
{
if
(
isOperationItemRequest
)
{
setOperationModule
(
request
,
userDetail
);
}
//超级管理员不限制
if
(
userDetail
.
getUserInfo
().
getSuperAdmin
().
intValue
()
==
1
)
{
return
true
;
}
//判断是否有权限
Map
<
String
,
Object
>
menuUrlMap
=
userDetail
.
getMenuUrlMap
();
if
(
menuUrlMap
==
null
||
menuUrlMap
.
isEmpty
())
{
throw
new
CommonException
(
ErrorCode
.
SYSTEM_ERROR
.
getErrorCode
(),
"sorry,您无该页面的访问权限,请联系超级管理员!"
);
}
if
(
isOperationItemRequest
)
{
//说明是操作项
//如果匹配上了,说明是没权限
if
(
menuUrlMap
.
containsKey
(
uri
))
{
throw
new
CommonException
(
ErrorCode
.
SYSTEM_ERROR
.
getErrorCode
(),
"sorry,您无该页面的访问权限,请联系超级管理员!"
);
}
}
else
{
//说明是页面
//如果没有匹配上,说明没权限
if
(!
menuUrlMap
.
containsKey
(
uri
))
{
throw
new
CommonException
(
ErrorCode
.
SYSTEM_ERROR
.
getErrorCode
(),
"sorry,您无该页面的访问权限,请联系超级管理员!"
);
}
}
return
true
;
}
private
void
setOperationModule
(
HttpServletRequest
request
,
UserDetail
userDetail
)
{
List
<
MenuInfo
>
menuInfoList
=
userDetail
.
getMenuInfoList
();
List
<
MenuInfo
>
menuInfoList
=
userDetail
.
getMenuInfoList
();
Map
<
String
,
MenuInfo
>
moduleUrlMap
=
userDetail
.
getModuleUrlMap
();
Map
<
String
,
MenuInfo
>
moduleUrlMap
=
userDetail
.
getModuleUrlMap
();
//页面路径
//页面路径
...
@@ -144,33 +181,6 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
...
@@ -144,33 +181,6 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
}
}
}
}
//超级管理员不限制
if
(
userDetail
.
getUserInfo
().
getSuperAdmin
().
intValue
()
==
1
)
{
return
true
;
}
//判断是否有权限
Map
<
String
,
Object
>
menuUrlMap
=
userDetail
.
getMenuUrlMap
();
if
(
menuUrlMap
==
null
||
menuUrlMap
.
isEmpty
())
{
throw
new
CommonException
(
ErrorCode
.
SYSTEM_ERROR
.
getErrorCode
(),
"sorry,您无该页面的访问权限,请联系超级管理员!"
);
}
if
(
isOperationItemRequest
)
{
//说明是操作项
//如果匹配上了,说明是没权限
if
(
menuUrlMap
.
containsKey
(
uri
))
{
throw
new
CommonException
(
ErrorCode
.
SYSTEM_ERROR
.
getErrorCode
(),
"sorry,您无该页面的访问权限,请联系超级管理员!"
);
}
}
else
{
//说明是页面
//如果没有匹配上,说明没权限
if
(!
menuUrlMap
.
containsKey
(
uri
))
{
throw
new
CommonException
(
ErrorCode
.
SYSTEM_ERROR
.
getErrorCode
(),
"sorry,您无该页面的访问权限,请联系超级管理员!"
);
}
}
return
true
;
}
private
static
Integer
getOperationModule
(
Integer
menuId
,
Map
<
String
,
MenuInfo
>
tempMap
)
{
private
static
Integer
getOperationModule
(
Integer
menuId
,
Map
<
String
,
MenuInfo
>
tempMap
)
{
MenuInfo
temp
=
tempMap
.
get
(
menuId
.
toString
());
MenuInfo
temp
=
tempMap
.
get
(
menuId
.
toString
());
if
(
temp
!=
null
)
{
if
(
temp
!=
null
)
{
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/json
S
eralizer/AbstractJsonSerializer.java
→
gic-enterprise-common/src/main/java/com/gic/enterprise/json
s
eralizer/AbstractJsonSerializer.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
json
S
eralizer
;
package
com
.
gic
.
enterprise
.
json
s
eralizer
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
...
@@ -6,9 +6,23 @@ import com.fasterxml.jackson.databind.JsonSerializer;
...
@@ -6,9 +6,23 @@ import com.fasterxml.jackson.databind.JsonSerializer;
import
com.fasterxml.jackson.databind.SerializerProvider
;
import
com.fasterxml.jackson.databind.SerializerProvider
;
import
java.io.IOException
;
import
java.io.IOException
;
/**
* 数据处理
* @ClassName: AbstractJsonSerializer
* @Description:
* @author guojuxing
* @date 2020/9/15 10:11 AM
*/
public
abstract
class
AbstractJsonSerializer
extends
JsonSerializer
<
String
>
{
public
abstract
class
AbstractJsonSerializer
extends
JsonSerializer
<
String
>
{
/**
* 序列化数据
* @Title: serializerData
* @Description:
* @author guojuxing
* @param value
* @return java.lang.String
*/
protected
abstract
String
serializerData
(
String
value
);
protected
abstract
String
serializerData
(
String
value
);
@Override
@Override
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/json
S
eralizer/EncryptJsonSerializer.java
→
gic-enterprise-common/src/main/java/com/gic/enterprise/json
s
eralizer/EncryptJsonSerializer.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
json
S
eralizer
;
package
com
.
gic
.
enterprise
.
json
s
eralizer
;
import
com.gic.enterprise.utils.UserDetail
;
import
com.gic.enterprise.utils.UserDetail
;
...
@@ -7,7 +7,13 @@ import com.gic.redis.data.util.RedisUtil;
...
@@ -7,7 +7,13 @@ import com.gic.redis.data.util.RedisUtil;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.RedissonClient
;
/**
* 加密
* @ClassName: EncryptJsonSerializer
* @Description:
* @author guojuxing
* @date 2020/9/15 10:45 AM
*/
public
class
EncryptJsonSerializer
extends
AbstractJsonSerializer
{
public
class
EncryptJsonSerializer
extends
AbstractJsonSerializer
{
@Override
@Override
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/json
S
eralizer/LongTypeConverter.java
→
gic-enterprise-common/src/main/java/com/gic/enterprise/json
s
eralizer/LongTypeConverter.java
View file @
c0974ffd
package
com
.
gic
.
enterprise
.
json
S
eralizer
;
package
com
.
gic
.
enterprise
.
json
s
eralizer
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
@@ -7,7 +7,13 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
...
@@ -7,7 +7,13 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 登录
* @ClassName: LongTypeConverter
* @Description:
* @author guojuxing
* @date 2020/9/15 10:45 AM
*/
@Component
@Component
public
class
LongTypeConverter
{
public
class
LongTypeConverter
{
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/request/ParameterRequestWrapper.java
View file @
c0974ffd
...
@@ -24,13 +24,22 @@ public class ParameterRequestWrapper extends HttpServletRequestWrapper {
...
@@ -24,13 +24,22 @@ public class ParameterRequestWrapper extends HttpServletRequestWrapper {
this
.
params
.
putAll
(
request
.
getParameterMap
());
this
.
params
.
putAll
(
request
.
getParameterMap
());
this
.
modifyParameterValues
();
this
.
modifyParameterValues
();
}
}
//重载一个构造方法
/**
* 重载一个构造方法
* @param request
* @param extendParams
*/
public
ParameterRequestWrapper
(
HttpServletRequest
request
,
Map
<
String
,
Object
>
extendParams
)
{
public
ParameterRequestWrapper
(
HttpServletRequest
request
,
Map
<
String
,
Object
>
extendParams
)
{
this
(
request
);
this
(
request
);
addAllParameters
(
extendParams
);
//这里将扩展参数写入参数表
//这里将扩展参数写入参数表
addAllParameters
(
extendParams
);
}
}
public
void
modifyParameterValues
(){
//将parameter的值去除空格后重写回去
/**
* 将parameter的值去除空格后重写回去
*/
public
void
modifyParameterValues
(){
Set
<
String
>
set
=
params
.
keySet
();
Set
<
String
>
set
=
params
.
keySet
();
Iterator
<
String
>
it
=
set
.
iterator
();
Iterator
<
String
>
it
=
set
.
iterator
();
while
(
it
.
hasNext
()){
while
(
it
.
hasNext
()){
...
@@ -41,8 +50,13 @@ public class ParameterRequestWrapper extends HttpServletRequestWrapper {
...
@@ -41,8 +50,13 @@ public class ParameterRequestWrapper extends HttpServletRequestWrapper {
}
}
}
}
/**
* 重写getParameter,代表参数从当前类中的map获取
* @param name
* @return
*/
@Override
@Override
public
String
getParameter
(
String
name
)
{
//重写getParameter,代表参数从当前类中的map获取
public
String
getParameter
(
String
name
)
{
String
[]
values
=
params
.
get
(
name
);
String
[]
values
=
params
.
get
(
name
);
if
(
values
==
null
||
values
.
length
==
0
)
{
if
(
values
==
null
||
values
.
length
==
0
)
{
return
null
;
return
null
;
...
@@ -55,13 +69,22 @@ public class ParameterRequestWrapper extends HttpServletRequestWrapper {
...
@@ -55,13 +69,22 @@ public class ParameterRequestWrapper extends HttpServletRequestWrapper {
return
params
.
get
(
name
);
return
params
.
get
(
name
);
}
}
public
void
addAllParameters
(
Map
<
String
,
Object
>
otherParams
)
{
//增加多个参数
/**
* 增加多个参数
* @param otherParams
*/
public
void
addAllParameters
(
Map
<
String
,
Object
>
otherParams
)
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
otherParams
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
otherParams
.
entrySet
())
{
addParameter
(
entry
.
getKey
()
,
entry
.
getValue
());
addParameter
(
entry
.
getKey
()
,
entry
.
getValue
());
}
}
}
}
public
void
addParameter
(
String
name
,
Object
value
)
{
//增加参数
/**
* 增加参数
* @param name
* @param value
*/
public
void
addParameter
(
String
name
,
Object
value
)
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
if
(
value
instanceof
String
[])
{
if
(
value
instanceof
String
[])
{
params
.
put
(
name
,
(
String
[])
value
);
params
.
put
(
name
,
(
String
[])
value
);
...
...
gic-enterprise-common/src/main/java/com/gic/enterprise/response/EnterpriseRestResponse.java
View file @
c0974ffd
...
@@ -3,7 +3,13 @@ package com.gic.enterprise.response;
...
@@ -3,7 +3,13 @@ package com.gic.enterprise.response;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.error.Error
;
import
com.gic.enterprise.error.Error
;
/**
* 返回对象包装
* @ClassName: EnterpriseRestResponse
* @Description:
* @author guojuxing
* @date 2020/9/15 10:12 AM
*/
public
class
EnterpriseRestResponse
extends
RestResponse
{
public
class
EnterpriseRestResponse
extends
RestResponse
{
public
static
RestResponse
failure
(
ServiceResponse
serviceResponse
){
public
static
RestResponse
failure
(
ServiceResponse
serviceResponse
){
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
(),
serviceResponse
.
getResult
());
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
(),
serviceResponse
.
getResult
());
...
...
gic-enterprise-download/src/main/java/com/gic/download/constants/QrcodeTypeEnum.java
View file @
c0974ffd
package
com
.
gic
.
download
.
constants
;
package
com
.
gic
.
download
.
constants
;
/**
* 二维码
* @ClassName: QrcodeTypeEnum
* @Description:
* @author guojuxing
* @date 2020/9/15 10:44 AM
*/
public
enum
QrcodeTypeEnum
{
public
enum
QrcodeTypeEnum
{
/**
* 门店二维码
*/
STORE
(
1
,
"门店二维码"
),
STORE
(
1
,
"门店二维码"
),
/**
* 导购二维码
*/
CLERK
(
2
,
"导购二维码"
);
CLERK
(
2
,
"导购二维码"
);
QrcodeTypeEnum
(
Integer
type
,
String
desc
){
QrcodeTypeEnum
(
Integer
type
,
String
desc
){
...
...
gic-enterprise-download/src/main/java/com/gic/download/dto/DownloadReportTempDTO.java
View file @
c0974ffd
...
@@ -36,4 +36,9 @@ public class DownloadReportTempDTO implements Serializable{
...
@@ -36,4 +36,9 @@ public class DownloadReportTempDTO implements Serializable{
public
void
setDataCount
(
Integer
dataCount
)
{
public
void
setDataCount
(
Integer
dataCount
)
{
this
.
dataCount
=
dataCount
;
this
.
dataCount
=
dataCount
;
}
}
@Override
public
String
toString
()
{
return
super
.
toString
();
}
}
}
gic-enterprise-download/src/main/java/com/gic/download/qo/QrcodeContent.java
View file @
c0974ffd
package
com
.
gic
.
download
.
qo
;
package
com
.
gic
.
download
.
qo
;
import
java.io.Serializable
;
import
java.io.Serializable
;
/**
* 二维码
* @ClassName: QrcodeContent
* @Description:
* @author guojuxing
* @date 2020/9/15 10:44 AM
*/
public
class
QrcodeContent
implements
Serializable
{
public
class
QrcodeContent
implements
Serializable
{
private
String
customParams
;
private
String
customParams
;
private
String
content
;
private
String
content
;
...
...
gic-enterprise-download/src/main/java/com/gic/download/qo/QrcodeQO.java
View file @
c0974ffd
...
@@ -5,13 +5,22 @@ import org.apache.commons.lang.StringUtils;
...
@@ -5,13 +5,22 @@ import org.apache.commons.lang.StringUtils;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
* 二维码
* @ClassName: QrcodeQO
* @Description:
* @author guojuxing
* @date 2020/9/15 10:44 AM
*/
public
class
QrcodeQO
implements
Serializable
{
public
class
QrcodeQO
implements
Serializable
{
private
Integer
h5
=
0
;
private
Integer
h5
=
0
;
private
String
appletIds
;
private
String
appletIds
;
private
String
fwhIds
;
private
String
fwhIds
;
private
String
scenesValueIds
;
private
String
scenesValueIds
;
private
Integer
type
;
//1临时二维码 2永久二维码
/**
* 1临时二维码 2永久二维码
*/
private
Integer
type
;
private
Date
endTime
;
private
Date
endTime
;
private
List
<
QrcodeContent
>
content
;
private
List
<
QrcodeContent
>
content
;
private
String
callBackService
;
private
String
callBackService
;
...
...
gic-enterprise-download/src/main/java/com/gic/download/utils/DataDownloadUtils.java
View file @
c0974ffd
...
@@ -27,7 +27,13 @@ import com.gic.enterprise.exception.CommonException;
...
@@ -27,7 +27,13 @@ import com.gic.enterprise.exception.CommonException;
import
com.gic.enterprise.service.DownloadReportApiService
;
import
com.gic.enterprise.service.DownloadReportApiService
;
import
com.gic.thirdparty.BucketNameEnum
;
import
com.gic.thirdparty.BucketNameEnum
;
import
com.gic.thirdparty.FileOperateUtils
;
import
com.gic.thirdparty.FileOperateUtils
;
/**
* 下载
* @ClassName: DataDownloadUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:43 AM
*/
@Component
@Component
public
class
DataDownloadUtils
{
public
class
DataDownloadUtils
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
DataDownloadUtils
.
class
);
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
DataDownloadUtils
.
class
);
...
@@ -37,6 +43,8 @@ public class DataDownloadUtils {
...
@@ -37,6 +43,8 @@ public class DataDownloadUtils {
@Autowired
@Autowired
private
DownloadReportApiService
downloadReportApiService
;
private
DownloadReportApiService
downloadReportApiService
;
private
static
Pattern
NUMBER_PATTERN
=
Pattern
.
compile
(
"[0-9]*"
);
@PostConstruct
@PostConstruct
public
void
init
()
{
public
void
init
()
{
dataDownloadUtils
=
this
;
dataDownloadUtils
=
this
;
...
@@ -216,8 +224,6 @@ public class DataDownloadUtils {
...
@@ -216,8 +224,6 @@ public class DataDownloadUtils {
Object
o
=
DataDownloadUtils
.
getFieldValue
(
dataList
.
get
(
i
),
fieldName
);
Object
o
=
DataDownloadUtils
.
getFieldValue
(
dataList
.
get
(
i
),
fieldName
);
if
(
o
==
null
)
{
if
(
o
==
null
)
{
sb
.
append
(
","
);
sb
.
append
(
","
);
}
else
if
(
o
.
toString
().
equals
(
"-1"
))
{
sb
.
append
(
","
);
}
else
if
(
o
instanceof
Double
)
{
}
else
if
(
o
instanceof
Double
)
{
DecimalFormat
format
=
new
DecimalFormat
(
"0.00"
);
DecimalFormat
format
=
new
DecimalFormat
(
"0.00"
);
sb
.
append
(
format
.
format
(
o
)
+
","
);
sb
.
append
(
format
.
format
(
o
)
+
","
);
...
@@ -226,8 +232,7 @@ public class DataDownloadUtils {
...
@@ -226,8 +232,7 @@ public class DataDownloadUtils {
}
else
if
(
o
instanceof
Date
)
{
}
else
if
(
o
instanceof
Date
)
{
sb
.
append
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
o
)
+
"\t,"
);
sb
.
append
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
o
)
+
"\t,"
);
}
else
{
}
else
{
Pattern
pattern
=
Pattern
.
compile
(
"[0-9]*"
);
Matcher
isNum
=
NUMBER_PATTERN
.
matcher
(
o
.
toString
());
Matcher
isNum
=
pattern
.
matcher
(
o
.
toString
());
if
(
isNum
.
matches
())
{
if
(
isNum
.
matches
())
{
if
(
o
.
toString
().
length
()
>=
12
)
{
if
(
o
.
toString
().
length
()
>=
12
)
{
sb
.
append
(
o
+
"\t,"
);
sb
.
append
(
o
+
"\t,"
);
...
...
gic-enterprise-download/src/main/java/com/gic/download/utils/DownloadUtils.java
View file @
c0974ffd
...
@@ -28,7 +28,13 @@ import java.io.IOException;
...
@@ -28,7 +28,13 @@ import java.io.IOException;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
/**
* 下载工具
* @ClassName: DownloadUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:43 AM
*/
public
class
DownloadUtils
{
public
class
DownloadUtils
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
DownloadUtils
.
class
);
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
DownloadUtils
.
class
);
...
@@ -144,6 +150,15 @@ public class DownloadUtils {
...
@@ -144,6 +150,15 @@ public class DownloadUtils {
protected
static
interface
Writer
{
protected
static
interface
Writer
{
/**
* 写数据
* @Title: write
* @Description:
* @author guojuxing
* @param row
* @return void
* @throws IOException
*/
public
void
write
(
Collection
<
String
>
row
)
throws
IOException
;
public
void
write
(
Collection
<
String
>
row
)
throws
IOException
;
}
}
...
@@ -239,7 +254,8 @@ public class DownloadUtils {
...
@@ -239,7 +254,8 @@ public class DownloadUtils {
DataDownloadUtils
.
mkDir
(
new
File
(
tempPath
));
DataDownloadUtils
.
mkDir
(
new
File
(
tempPath
));
File
file
=
new
File
(
tempPath
);
File
file
=
new
File
(
tempPath
);
//初始化数据
//初始化数据
if
(
fileName
.
length
()
<
3
)
{
int
leastPrefixStringLength
=
3
;
if
(
fileName
.
length
()
<
leastPrefixStringLength
)
{
//如果长度太短
//如果长度太短
fileName
=
fileName
+
"__"
;
fileName
=
fileName
+
"__"
;
}
}
...
@@ -509,9 +525,12 @@ public class DownloadUtils {
...
@@ -509,9 +525,12 @@ public class DownloadUtils {
}
}
//手机号或者会员卡号 第5-8位用*代替
//手机号或者会员卡号 第5-8位用*代替
int
length
=
data
.
length
();
int
length
=
data
.
length
();
if
(
length
>
8
)
{
boolean
isGreaterThanEight
=
length
>
8
;
boolean
isGreaterThanFour
=
length
>
4
;
if
(
isGreaterThanEight
)
{
return
data
.
substring
(
0
,
4
)
+
"****"
+
data
.
substring
(
8
);
return
data
.
substring
(
0
,
4
)
+
"****"
+
data
.
substring
(
8
);
}
else
if
(
length
>
4
)
{
}
else
if
(
isGreaterThanFour
)
{
return
data
.
substring
(
0
,
4
)
+
"****"
;
return
data
.
substring
(
0
,
4
)
+
"****"
;
}
else
{
}
else
{
return
"****"
;
return
"****"
;
...
...
gic-enterprise-download/src/main/java/com/gic/download/utils/ExcelUtils.java
View file @
c0974ffd
...
@@ -16,7 +16,13 @@ import org.apache.logging.log4j.Logger;
...
@@ -16,7 +16,13 @@ import org.apache.logging.log4j.Logger;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddress
;
/**
* excel
* @ClassName: ExcelUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:59 AM
*/
public
class
ExcelUtils
{
public
class
ExcelUtils
{
/**
/**
* logger
* logger
...
@@ -437,18 +443,18 @@ public class ExcelUtils {
...
@@ -437,18 +443,18 @@ public class ExcelUtils {
* @throws FileNotFoundException
* @throws FileNotFoundException
*/
*/
public
static
HSSFWorkbook
readWorkbook
(
InputStream
ins
)
throws
IOException
,
FileNotFoundException
{
public
static
HSSFWorkbook
readWorkbook
(
InputStream
ins
)
throws
IOException
,
FileNotFoundException
{
ByteArrayOutputStream
byteO
S
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
byteO
outputStream
=
new
ByteArrayOutputStream
();
BufferedInputStream
bis
=
new
BufferedInputStream
(
ins
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
ins
);
byte
[]
by
=
new
byte
[
512
];
byte
[]
by
=
new
byte
[
512
];
int
t
=
bis
.
read
(
by
,
0
,
by
.
length
);
int
t
=
bis
.
read
(
by
,
0
,
by
.
length
);
while
(
t
>
0
)
{
while
(
t
>
0
)
{
// read 512
// read 512
byteO
S
.
write
(
by
,
0
,
512
);
byteO
outputStream
.
write
(
by
,
0
,
512
);
t
=
bis
.
read
(
by
,
0
,
by
.
length
);
t
=
bis
.
read
(
by
,
0
,
by
.
length
);
}
}
byteO
S
.
close
();
byteO
outputStream
.
close
();
InputStream
byteI
S
=
new
ByteArrayInputStream
(
byteOS
.
toByteArray
());
InputStream
byteI
nputStream
=
new
ByteArrayInputStream
(
byteOoutputStream
.
toByteArray
());
HSSFWorkbook
wbDest
=
new
HSSFWorkbook
(
byteI
S
);
HSSFWorkbook
wbDest
=
new
HSSFWorkbook
(
byteI
nputStream
);
return
wbDest
;
return
wbDest
;
}
}
...
@@ -463,50 +469,6 @@ public class ExcelUtils {
...
@@ -463,50 +469,6 @@ public class ExcelUtils {
}
}
/**
/**
* 判断单元格的格式
*
* @param cell
* 单元格
* @return String 将excel各种单元格的类型转换为String类型
*/
public
static
String
getCellStringValue
(
HSSFCell
cell
)
{
// 转换后单元格的值
String
value
=
""
;
if
(
cell
!=
null
)
{
switch
(
cell
.
getCellType
())
{
case
HSSFCell
.
CELL_TYPE_STRING
:
value
=
cell
.
getRichStringCellValue
().
getString
();
break
;
case
HSSFCell
.
CELL_TYPE_NUMERIC
:
if
(
HSSFDateUtil
.
isCellDateFormatted
(
cell
))
{
Date
date
=
HSSFDateUtil
.
getJavaDate
(
cell
.
getNumericCellValue
());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
value
=
sdf
.
format
(
date
);
}
else
{
DecimalFormat
formatter
=
new
DecimalFormat
(
"########"
);
value
=
formatter
.
format
(
cell
.
getNumericCellValue
());
}
break
;
case
HSSFCell
.
CELL_TYPE_FORMULA
:
cell
.
setCellType
(
HSSFCell
.
CELL_TYPE_NUMERIC
);
value
=
String
.
valueOf
(
cell
.
getNumericCellValue
());
break
;
case
HSSFCell
.
CELL_TYPE_BLANK
:
break
;
case
HSSFCell
.
CELL_TYPE_BOOLEAN
:
break
;
case
HSSFCell
.
CELL_TYPE_ERROR
:
break
;
default
:
break
;
}
}
return
value
;
}
/**
* 到出excel的Helper类
* 到出excel的Helper类
*
*
* @author Administrator
* @author Administrator
...
...
gic-enterprise-download/src/main/java/com/gic/download/utils/OperationResultUtils.java
View file @
c0974ffd
...
@@ -3,7 +3,13 @@ package com.gic.download.utils;
...
@@ -3,7 +3,13 @@ package com.gic.download.utils;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.download.utils.log.LogUtils
;
import
com.gic.download.utils.log.LogUtils
;
/**
* controller添加日志
* @ClassName: OperationResultUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:43 AM
*/
public
class
OperationResultUtils
{
public
class
OperationResultUtils
{
public
static
final
String
LOG_NEW
=
"新增"
;
public
static
final
String
LOG_NEW
=
"新增"
;
...
...
gic-enterprise-download/src/main/java/com/gic/download/utils/QrcodeDownload.java
View file @
c0974ffd
...
@@ -40,14 +40,26 @@ import java.util.List;
...
@@ -40,14 +40,26 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
/**
* 二维码下载
* @ClassName: QrcodeDownload
* @Description:
* @author guojuxing
* @date 2020/9/15 10:45 AM
*/
public
abstract
class
QrcodeDownload
{
public
abstract
class
QrcodeDownload
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
QrcodeDownload
.
class
);
private
static
final
Logger
log
=
LogManager
.
getLogger
(
QrcodeDownload
.
class
);
private
static
final
int
width
=
1280
;
private
static
final
int
WIDTH
=
1280
;
private
static
final
int
height
=
1280
;
private
static
final
int
HEIGHT
=
1280
;
private
static
final
int
QRCOLOR
=
0xFF000000
;
// 默认是黑色
/**
private
static
final
int
BGWHITE
=
0xFFFFFFFF
;
// 背景颜色
* 默认是黑色
private
static
final
int
pageSize
=
1000
;
*/
private
static
final
int
QRCOLOR
=
0xFF000000
;
/**
* 背景颜色
*/
private
static
final
int
BGWHITE
=
0xFFFFFFFF
;
private
static
final
int
PAGE_SIZE
=
1000
;
private
QrcodeQO
qrcodeQO
=
null
;
private
QrcodeQO
qrcodeQO
=
null
;
private
Integer
total
;
private
Integer
total
;
...
@@ -87,9 +99,9 @@ public abstract class QrcodeDownload {
...
@@ -87,9 +99,9 @@ public abstract class QrcodeDownload {
file
.
createNewFile
();
file
.
createNewFile
();
}
}
ZipOutputStream
zipOutputStream
=
new
ZipOutputStream
(
new
FileOutputStream
(
file
));
ZipOutputStream
zipOutputStream
=
new
ZipOutputStream
(
new
FileOutputStream
(
file
));
int
pages
=
total
%
pageSize
>
0
?
total
/
pageSize
+
1
:
total
/
pageSize
;
int
pages
=
total
%
PAGE_SIZE
>
0
?
total
/
PAGE_SIZE
+
1
:
total
/
PAGE_SIZE
;
for
(
int
i
=
1
;
i
<=
pages
;
i
++){
for
(
int
i
=
1
;
i
<=
pages
;
i
++){
List
<
QrcodeContent
>
contentList
=
getContent
(
i
,
pageSize
);
List
<
QrcodeContent
>
contentList
=
getContent
(
i
,
PAGE_SIZE
);
if
(
CollectionUtils
.
isEmpty
(
contentList
)){
if
(
CollectionUtils
.
isEmpty
(
contentList
)){
break
;
break
;
}
}
...
@@ -173,15 +185,15 @@ public abstract class QrcodeDownload {
...
@@ -173,15 +185,15 @@ public abstract class QrcodeDownload {
}
}
private
byte
[]
createFwhQrcode
(
Integer
qrCodeId
,
int
type
,
String
appkey
,
Date
endTime
,
String
title
,
UserDetail
userDetail
){
private
byte
[]
createFwhQrcode
(
Integer
qrCodeId
,
int
type
,
String
appkey
,
Date
endTime
,
String
title
,
UserDetail
userDetail
){
ServiceResponse
<
String
>
qRcodeU
RL
=
null
;
ServiceResponse
<
String
>
qRcodeU
rl
=
null
;
if
(
type
==
1
){
if
(
type
==
1
){
int
expireSecond
=
Integer
.
valueOf
((
endTime
.
getTime
()
-
System
.
currentTimeMillis
())/
1000
+
""
);
int
expireSecond
=
Integer
.
valueOf
((
endTime
.
getTime
()
-
System
.
currentTimeMillis
())/
1000
+
""
);
qRcodeU
RL
=
this
.
weixinBaseFunService
.
getTemporaryQRcodeURL
(
appkey
,
qrCodeId
+
""
,
expireSecond
);
qRcodeU
rl
=
this
.
weixinBaseFunService
.
getTemporaryQRcodeURL
(
appkey
,
qrCodeId
+
""
,
expireSecond
);
}
else
{
}
else
{
qRcodeU
RL
=
this
.
weixinBaseFunService
.
getQRcodeURL
(
appkey
,
qrCodeId
+
""
);
qRcodeU
rl
=
this
.
weixinBaseFunService
.
getQRcodeURL
(
appkey
,
qrCodeId
+
""
);
}
}
if
(
qRcodeU
RL
.
isSuccess
()){
if
(
qRcodeU
rl
.
isSuccess
()){
return
createQrcode
(
qRcodeU
RL
.
getResult
(),
userDetail
.
getEnterpriseInfo
().
getLogo
(),
title
);
return
createQrcode
(
qRcodeU
rl
.
getResult
(),
userDetail
.
getEnterpriseInfo
().
getLogo
(),
title
);
}
}
return
null
;
return
null
;
}
}
...
@@ -198,17 +210,26 @@ public abstract class QrcodeDownload {
...
@@ -198,17 +210,26 @@ public abstract class QrcodeDownload {
return
createQrcode
(
content
,
userDetail
.
getEnterpriseInfo
().
getLogo
(),
title
);
return
createQrcode
(
content
,
userDetail
.
getEnterpriseInfo
().
getLogo
(),
title
);
}
}
/**
* 获取数据
* @Title: getContent
* @Description:
* @author guojuxing
* @param pageSize
* @param pageNum
* @return java.util.List<com.gic.download.qo.QrcodeContent>
*/
protected
abstract
List
<
QrcodeContent
>
getContent
(
int
pageSize
,
int
pageNum
);
protected
abstract
List
<
QrcodeContent
>
getContent
(
int
pageSize
,
int
pageNum
);
private
byte
[]
createQrcode
(
String
url
,
String
logoPic
,
String
logoName
)
{
private
byte
[]
createQrcode
(
String
url
,
String
logoPic
,
String
logoName
)
{
byte
[]
imageByte
=
null
;
byte
[]
imageByte
=
null
;
String
format
=
"png"
;
// 图像类型
// 图像类型
String
format
=
"png"
;
Map
<
EncodeHintType
,
Object
>
hints
=
new
HashMap
<
EncodeHintType
,
Object
>();
Map
<
EncodeHintType
,
Object
>
hints
=
new
HashMap
<
EncodeHintType
,
Object
>();
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
try
{
try
{
BufferedImage
bim
=
getQ
R_CODEBufferedImage
(
url
,
BarcodeFormat
.
QR_CODE
,
width
,
height
,
hints
);
BufferedImage
bim
=
getQ
rCodeBufferedImage
(
url
,
BarcodeFormat
.
QR_CODE
,
WIDTH
,
HEIGHT
,
hints
);
imageByte
=
addLogo
_QR
Code
(
bim
,
getPicByte
(
logoPic
),
logoName
,
format
);
imageByte
=
addLogo
Qr
Code
(
bim
,
getPicByte
(
logoPic
),
logoName
,
format
);
return
imageByte
;
return
imageByte
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"创建二维码失败"
,
e
);
log
.
error
(
"创建二维码失败"
,
e
);
...
@@ -251,7 +272,7 @@ public abstract class QrcodeDownload {
...
@@ -251,7 +272,7 @@ public abstract class QrcodeDownload {
* 图片后缀名
* 图片后缀名
* @return
* @return
*/
*/
private
byte
[]
addLogo
_QR
Code
(
BufferedImage
bim
,
byte
[]
logoPic
,
String
logoName
,
String
format
)
{
private
byte
[]
addLogo
Qr
Code
(
BufferedImage
bim
,
byte
[]
logoPic
,
String
logoName
,
String
format
)
{
try
{
try
{
/**
/**
* 读取二维码图片,并构建绘图对象
* 读取二维码图片,并构建绘图对象
...
@@ -260,16 +281,15 @@ public abstract class QrcodeDownload {
...
@@ -260,16 +281,15 @@ public abstract class QrcodeDownload {
Graphics2D
g
=
image
.
createGraphics
();
Graphics2D
g
=
image
.
createGraphics
();
if
(
StringUtils
.
isNotEmpty
(
logoName
))
{
if
(
StringUtils
.
isNotEmpty
(
logoName
))
{
g
.
setColor
(
Color
.
BLACK
);
g
.
setColor
(
Color
.
BLACK
);
g
.
setFont
(
new
Font
(
"宋体"
,
Font
.
BOLD
,
50
));
// 字体、字型、字号
// 字体、字型、字号
g
.
setFont
(
new
Font
(
"宋体"
,
Font
.
BOLD
,
50
));
// int _height=outg.getFontMetrics().getHeight();
log
.
info
(
"logoName1:"
+
logoName
);
log
.
info
(
"logoName1:"
+
logoName
);
int
_width
=
g
.
getFontMetrics
().
stringWidth
(
logoName
);
int
widthTemp
=
g
.
getFontMetrics
().
stringWidth
(
logoName
);
log
.
info
(
"logoName2:"
+
logoName
);
log
.
info
(
"logoName2:"
+
logoName
);
g
.
drawString
(
logoName
,
(
width
-
_width
)
/
2
,
height
-
60
);
// 画文字
// 画文字
// outg.dispose(
);
g
.
drawString
(
logoName
,
(
WIDTH
-
widthTemp
)
/
2
,
HEIGHT
-
60
);
image
.
flush
();
image
.
flush
();
// image = outImage;
}
}
if
(
logoPic
!=
null
)
{
if
(
logoPic
!=
null
)
{
...
@@ -296,14 +316,12 @@ public abstract class QrcodeDownload {
...
@@ -296,14 +316,12 @@ public abstract class QrcodeDownload {
// 开始绘制图片
// 开始绘制图片
g
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
g
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
g
.
drawImage
(
logo
,
x
,
y
,
widthLogo
,
heightLogo
,
null
);
g
.
drawImage
(
logo
,
x
,
y
,
widthLogo
,
heightLogo
,
null
);
// g.drawRoundRect(x,y,widthLogo,heightLogo,15,15);
g
.
drawRect
(
x
,
y
,
widthLogo
,
heightLogo
);
g
.
drawRect
(
x
,
y
,
widthLogo
,
heightLogo
);
// logo边框大小
// logo边框大小
g
.
setStroke
(
new
BasicStroke
(
2
));
g
.
setStroke
(
new
BasicStroke
(
2
));
// logo边框颜色
// logo边框颜色
g
.
setColor
(
Color
.
WHITE
);
g
.
setColor
(
Color
.
WHITE
);
g
.
drawRect
(
x
,
y
,
widthLogo
,
heightLogo
);
g
.
drawRect
(
x
,
y
,
widthLogo
,
heightLogo
);
// g.dispose();
logo
.
flush
();
logo
.
flush
();
image
.
flush
();
image
.
flush
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -338,7 +356,7 @@ public abstract class QrcodeDownload {
...
@@ -338,7 +356,7 @@ public abstract class QrcodeDownload {
* 设置参数
* 设置参数
* @return
* @return
*/
*/
private
BufferedImage
getQ
R_CODE
BufferedImage
(
String
content
,
BarcodeFormat
barcodeFormat
,
int
width
,
int
height
,
private
BufferedImage
getQ
rCode
BufferedImage
(
String
content
,
BarcodeFormat
barcodeFormat
,
int
width
,
int
height
,
Map
<
EncodeHintType
,
?>
hints
)
{
Map
<
EncodeHintType
,
?>
hints
)
{
MultiFormatWriter
multiFormatWriter
=
null
;
MultiFormatWriter
multiFormatWriter
=
null
;
BitMatrix
bm
=
null
;
BitMatrix
bm
=
null
;
...
...
gic-enterprise-download/src/main/java/com/gic/download/utils/log/LogUtils.java
View file @
c0974ffd
...
@@ -13,7 +13,13 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -13,7 +13,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
java.util.Date
;
/**
* 日志工具
* @ClassName: LogUtils
* @Description:
* @author guojuxing
* @date 2020/9/15 10:43 AM
*/
@Component
@Component
public
class
LogUtils
{
public
class
LogUtils
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
LogUtils
.
class
);
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
LogUtils
.
class
);
...
...
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