Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
72409013
Commit
72409013
authored
Jun 25, 2018
by
eddie.woo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
95b91dbd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
472 additions
and
209 deletions
+472
-209
AuthUserHelperImpl.java
...main/java/pwc/taxtech/atms/common/AuthUserHelperImpl.java
+1
-1
BaseController.java
...main/java/pwc/taxtech/atms/controller/BaseController.java
+13
-1
ApiCacheMapper.java
...pi/src/main/java/pwc/taxtech/atms/dao/ApiCacheMapper.java
+109
-0
ApiCache.java
...-api/src/main/java/pwc/taxtech/atms/entitiy/ApiCache.java
+215
-0
ApiCacheExample.java
...c/main/java/pwc/taxtech/atms/entitiy/ApiCacheExample.java
+0
-0
BaseEntity.java
...pi/src/main/java/pwc/taxtech/atms/entitiy/BaseEntity.java
+7
-1
JwtAuthenticationFilter.java
...va/pwc/taxtech/atms/security/JwtAuthenticationFilter.java
+41
-7
JwtAuthenticationProvider.java
.../pwc/taxtech/atms/security/JwtAuthenticationProvider.java
+9
-1
JwtUser.java
...-api/src/main/java/pwc/taxtech/atms/security/JwtUser.java
+12
-1
JwtUtil.java
...-api/src/main/java/pwc/taxtech/atms/security/JwtUtil.java
+10
-18
conf.properties
atms-api/src/main/resources/conf/conf.properties
+2
-0
conf_profile_dev.properties
atms-api/src/main/resources/conf/conf_profile_dev.properties
+2
-0
conf_profile_pub.properties
atms-api/src/main/resources/conf/conf_profile_pub.properties
+2
-0
conf_profile_staging.properties
...i/src/main/resources/conf/conf_profile_staging.properties
+2
-0
CommonIT.java
atms-api/src/test/java/pwc/taxtech/atms/CommonIT.java
+6
-66
CacheControllerTest.java
...java/pwc/taxtech/atms/controller/CacheControllerTest.java
+0
-29
CacheServiceIT.java
...st/java/pwc/taxtech/atms/service/impl/CacheServiceIT.java
+0
-48
generatorConfig.xml
atms-api/src/test/resources/generatorConfig.xml
+41
-36
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/AuthUserHelperImpl.java
View file @
72409013
...
...
@@ -57,7 +57,7 @@ public class AuthUserHelperImpl implements AuditorAware<String>, AuthUserHelper
@Override
public
String
getCurrentUserID
()
{
String
userName
=
getCurrentAuditor
();
User
user
=
userMapper
.
selectByUserNameIgnoreCase
(
userName
);
User
user
=
userMapper
.
selectByUserNameIgnoreCase
(
userName
);
//todo 加缓存
if
(
user
==
null
)
{
return
""
;
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/controller/BaseController.java
View file @
72409013
...
...
@@ -2,8 +2,20 @@ package pwc.taxtech.atms.controller;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
public
class
BaseController
{
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
protected
HttpServletRequest
request
;
protected
HttpServletResponse
response
;
@ModelAttribute
public
void
setReqAndRes
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
this
.
request
=
request
;
this
.
response
=
response
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/dao/ApiCacheMapper.java
0 → 100644
View file @
72409013
package
pwc
.
taxtech
.
atms
.
dao
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.session.RowBounds
;
import
pwc.taxtech.atms.MyMapper
;
import
pwc.taxtech.atms.entitiy.ApiCache
;
import
pwc.taxtech.atms.entitiy.ApiCacheExample
;
@Mapper
public
interface
ApiCacheMapper
extends
MyMapper
{
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
long
countByExample
(
ApiCacheExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
deleteByExample
(
ApiCacheExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
deleteByPrimaryKey
(
Long
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
insert
(
ApiCache
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
insertSelective
(
ApiCache
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
List
<
ApiCache
>
selectByExampleWithRowbounds
(
ApiCacheExample
example
,
RowBounds
rowBounds
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
List
<
ApiCache
>
selectByExample
(
ApiCacheExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
ApiCache
selectByPrimaryKey
(
Long
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
ApiCache
record
,
@Param
(
"example"
)
ApiCacheExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
updateByExample
(
@Param
(
"record"
)
ApiCache
record
,
@Param
(
"example"
)
ApiCacheExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
updateByPrimaryKeySelective
(
ApiCache
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
int
updateByPrimaryKey
(
ApiCache
record
);
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/entitiy/ApiCache.java
0 → 100644
View file @
72409013
package
pwc
.
taxtech
.
atms
.
entitiy
;
import
java.io.Serializable
;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table api_cache
*
* @mbg.generated do_not_delete_during_merge
*/
public
class
ApiCache
extends
BaseEntity
implements
Serializable
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_cache.id
*
* @mbg.generated
*/
private
Long
id
;
/**
* Database Column Remarks:
* 业务数据类型
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_cache.source_type
*
* @mbg.generated
*/
private
Integer
sourceType
;
/**
* Database Column Remarks:
* 业务唯一键
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_cache.source_key
*
* @mbg.generated
*/
private
String
sourceKey
;
/**
* Database Column Remarks:
* 更新时间
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_cache.last_modify_time
*
* @mbg.generated
*/
private
Long
lastModifyTime
;
/**
* Database Column Remarks:
* 更新人
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_cache.modify_by
*
* @mbg.generated
*/
private
String
modifyBy
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table api_cache
*
* @mbg.generated
*/
private
static
final
long
serialVersionUID
=
1L
;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column api_cache.id
*
* @return the value of api_cache.id
*
* @mbg.generated
*/
public
Long
getId
()
{
return
id
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column api_cache.id
*
* @param id the value for api_cache.id
*
* @mbg.generated
*/
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column api_cache.source_type
*
* @return the value of api_cache.source_type
*
* @mbg.generated
*/
public
Integer
getSourceType
()
{
return
sourceType
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column api_cache.source_type
*
* @param sourceType the value for api_cache.source_type
*
* @mbg.generated
*/
public
void
setSourceType
(
Integer
sourceType
)
{
this
.
sourceType
=
sourceType
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column api_cache.source_key
*
* @return the value of api_cache.source_key
*
* @mbg.generated
*/
public
String
getSourceKey
()
{
return
sourceKey
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column api_cache.source_key
*
* @param sourceKey the value for api_cache.source_key
*
* @mbg.generated
*/
public
void
setSourceKey
(
String
sourceKey
)
{
this
.
sourceKey
=
sourceKey
==
null
?
null
:
sourceKey
.
trim
();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column api_cache.last_modify_time
*
* @return the value of api_cache.last_modify_time
*
* @mbg.generated
*/
public
Long
getLastModifyTime
()
{
return
lastModifyTime
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column api_cache.last_modify_time
*
* @param lastModifyTime the value for api_cache.last_modify_time
*
* @mbg.generated
*/
public
void
setLastModifyTime
(
Long
lastModifyTime
)
{
this
.
lastModifyTime
=
lastModifyTime
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column api_cache.modify_by
*
* @return the value of api_cache.modify_by
*
* @mbg.generated
*/
public
String
getModifyBy
()
{
return
modifyBy
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column api_cache.modify_by
*
* @param modifyBy the value for api_cache.modify_by
*
* @mbg.generated
*/
public
void
setModifyBy
(
String
modifyBy
)
{
this
.
modifyBy
=
modifyBy
==
null
?
null
:
modifyBy
.
trim
();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_cache
*
* @mbg.generated
*/
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", sourceType="
).
append
(
sourceType
);
sb
.
append
(
", sourceKey="
).
append
(
sourceKey
);
sb
.
append
(
", lastModifyTime="
).
append
(
lastModifyTime
);
sb
.
append
(
", modifyBy="
).
append
(
modifyBy
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/entitiy/ApiCacheExample.java
0 → 100644
View file @
72409013
This diff is collapsed.
Click to expand it.
atms-api/src/main/java/pwc/taxtech/atms/entitiy/BaseEntity.java
View file @
72409013
...
...
@@ -8,6 +8,12 @@ public class BaseEntity {
private
Date
createTime
;
private
Date
updateTime
;
public
BaseEntity
()
{
Date
now
=
new
Date
();
this
.
createTime
=
now
;
this
.
updateTime
=
now
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
...
...
@@ -33,7 +39,7 @@ public class BaseEntity {
}
public
Date
getUpdateTime
()
{
return
updateTime
;
return
updateTime
==
null
?
new
Date
()
:
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/security/JwtAuthenticationFilter.java
View file @
72409013
package
pwc
.
taxtech
.
atms
.
security
;
import
java.io.IOException
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
io.jsonwebtoken.impl.DefaultClaims
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.authentication.AuthenticationCredentialsNotFoundException
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
@Component
public
class
JwtAuthenticationFilter
extends
AbstractAuthenticationProcessingFilter
{
@Value
(
"${jwt.expireSecond}"
)
private
Integer
jwtExpireSecond
;
@Value
(
"${jwt.refreshSecond}"
)
private
Integer
jwtRefreshSecond
;
@Autowired
private
JwtUtil
jwtUtil
;
public
JwtAuthenticationFilter
()
{
super
(
"/**"
);
}
...
...
@@ -58,6 +70,27 @@ public class JwtAuthenticationFilter extends AbstractAuthenticationProcessingFil
// As this authentication is in HTTP header, after success we need to continue
// the request normally
// and return the response as if the resource was not secured at all
try
{
JwtUser
jwtUser
=
(
JwtUser
)
authResult
.
getPrincipal
();
if
(
null
!=
jwtUser
)
{
DefaultClaims
claims
=
jwtUser
.
getDefaultClaims
();
if
(
claims
.
getExpiration
().
getTime
()
-
System
.
currentTimeMillis
()
<=
jwtRefreshSecond
*
1000
)
{
String
newToken
=
jwtUtil
.
generateToken
(
jwtUser
.
getUsername
(),
jwtUser
.
getDatabaseUsername
(),
jwtUser
.
getUserid
());
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"refreshToken"
);
response
.
setHeader
(
"refreshToken"
,
newToken
);
logger
.
debug
(
"refreshToken: "
+
newToken
);
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
""
,
e
);
}
chain
.
doFilter
(
request
,
response
);
}
@Override
protected
void
unsuccessfulAuthentication
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AuthenticationException
failed
)
throws
IOException
,
ServletException
{
super
.
unsuccessfulAuthentication
(
request
,
response
,
failed
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
}
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/security/JwtAuthenticationProvider.java
View file @
72409013
package
pwc
.
taxtech
.
atms
.
security
;
import
io.jsonwebtoken.ExpiredJwtException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
...
...
@@ -31,7 +32,14 @@ public class JwtAuthenticationProvider extends AbstractUserDetailsAuthentication
JwtAuthenticationToken
jwtAuthenticationToken
=
(
JwtAuthenticationToken
)
authentication
;
String
token
=
jwtAuthenticationToken
.
getToken
();
JwtUser
parsedUser
=
jwtUtil
.
parseToken
(
token
);
JwtUser
parsedUser
;
try
{
parsedUser
=
jwtUtil
.
parseToken
(
token
);
}
catch
(
ExpiredJwtException
e
)
{
throw
new
BadCredentialsException
(
"Expired jwt token"
);
}
catch
(
Exception
e
)
{
throw
new
BadCredentialsException
(
"Bad jwt token"
,
e
);
}
if
(
parsedUser
==
null
)
{
throw
new
BadCredentialsException
(
"JWT token is not valid"
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/security/JwtUser.java
View file @
72409013
...
...
@@ -2,6 +2,7 @@ package pwc.taxtech.atms.security;
import
java.util.Collection
;
import
io.jsonwebtoken.impl.DefaultClaims
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
...
...
@@ -14,12 +15,15 @@ public class JwtUser implements UserDetails {
private
final
String
databaseUsername
;
private
final
Collection
<?
extends
GrantedAuthority
>
authorities
;
private
DefaultClaims
defaultClaims
;
public
JwtUser
(
String
userid
,
String
username
,
String
databaseUsername
,
Collection
<?
extends
GrantedAuthority
>
authorities
)
{
DefaultClaims
defaultClaims
,
Collection
<?
extends
GrantedAuthority
>
authorities
)
{
this
.
userid
=
userid
;
this
.
username
=
username
;
this
.
databaseUsername
=
databaseUsername
;
this
.
authorities
=
authorities
;
this
.
defaultClaims
=
defaultClaims
;
}
@Override
...
...
@@ -65,4 +69,11 @@ public class JwtUser implements UserDetails {
return
databaseUsername
;
}
public
DefaultClaims
getDefaultClaims
()
{
return
defaultClaims
;
}
public
void
setDefaultClaims
(
DefaultClaims
defaultClaims
)
{
this
.
defaultClaims
=
defaultClaims
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/security/JwtUtil.java
View file @
72409013
...
...
@@ -4,21 +4,18 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.List
;
import
io.jsonwebtoken.*
;
import
org.nutz.lang.Times
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
io.jsonwebtoken.Jwt
;
import
io.jsonwebtoken.JwtBuilder
;
import
io.jsonwebtoken.JwtParser
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
io.jsonwebtoken.impl.DefaultClaims
;
import
io.jsonwebtoken.impl.DefaultJws
;
import
io.jsonwebtoken.lang.Assert
;
...
...
@@ -31,6 +28,8 @@ public class JwtUtil implements InitializingBean {
@Autowired
private
AtmsApiSettings
atmsApiSettings
;
@Value
(
"${jwt.expireSecond}"
)
private
Integer
jwtExpireSecond
;
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
...
...
@@ -51,24 +50,17 @@ public class JwtUtil implements InitializingBean {
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
JwtUser
parseToken
(
String
token
)
{
if
(
StringUtils
.
hasText
(
jwtPowerToken
)
&&
jwtPowerToken
.
equals
(
token
))
{
return
new
JwtUser
(
"test_userid"
,
"admin"
,
"Admin"
,
getAuthorities
());
return
new
JwtUser
(
"test_userid"
,
"admin"
,
"Admin"
,
null
,
getAuthorities
());
}
JwtParser
parser
=
Jwts
.
parser
().
setSigningKey
(
jwtBase64Secret
);
Jwt
jwt
=
null
;
DefaultJws
<
DefaultClaims
>
defaultJws
=
null
;
try
{
jwt
=
parser
.
parseClaimsJws
(
token
);
defaultJws
=
(
DefaultJws
<
DefaultClaims
>)
jwt
;
}
catch
(
Exception
e
)
{
logger
.
warn
(
"Bad jwt token"
,
e
);
throw
new
BadCredentialsException
(
"invalid token:"
+
e
.
getMessage
());
}
Jwt
jwt
=
parser
.
parseClaimsJws
(
token
);
DefaultJws
<
DefaultClaims
>
defaultJws
=
(
DefaultJws
<
DefaultClaims
>)
jwt
;
DefaultClaims
defaultClaims
=
defaultJws
.
getBody
();
String
databaseUsername
=
String
.
valueOf
(
defaultClaims
.
get
(
"databaseUsername"
));
String
username
=
String
.
valueOf
(
defaultClaims
.
get
(
"username"
));
String
userid
=
String
.
valueOf
(
defaultClaims
.
get
(
"userid"
));
return
new
JwtUser
(
userid
,
username
,
databaseUsername
,
getAuthorities
());
return
new
JwtUser
(
userid
,
username
,
databaseUsername
,
defaultClaims
,
getAuthorities
());
}
private
List
<
SimpleGrantedAuthority
>
getAuthorities
()
{
...
...
@@ -81,7 +73,7 @@ public class JwtUtil implements InitializingBean {
/***
* @param username
* 登录名,大小写不限,可以是全大写或全小写,如:admin, ADMIN
* @param
login
name
* @param
databaseUser
name
* 数据库用户名, 比如Admin
* @param userid
* 用户ID
...
...
@@ -97,7 +89,7 @@ public class JwtUtil implements InitializingBean {
Date
now
=
new
Date
();
// 过期时间设置为2天
int
expireSecond
=
3600
*
24
*
2
;
int
expireSecond
=
jwtExpireSecond
;
Date
expiration
=
Times
.
nextSecond
(
now
,
expireSecond
);
JwtBuilder
jwtBuilder
=
Jwts
.
builder
();
// 设置Subject为登录用户名
...
...
atms-api/src/main/resources/conf/conf.properties
View file @
72409013
...
...
@@ -13,6 +13,8 @@ web.url=${web.url}
jwt.base64Secret
=
${jwt.base64Secret}
jwt.powerToken
=
${jwt.powerToken}
jwt.expireSecond
=
${jwt.expireSecond}
jwt.refreshSecond
=
${jwt.refreshSecond}
#FTP Config
ftp.host
=
${ftp.host}
...
...
atms-api/src/main/resources/conf/conf_profile_dev.properties
View file @
72409013
...
...
@@ -13,6 +13,8 @@ web.url=http://localhost:8080
#web.url=*
jwt.base64Secret
=
TXppQjFlZFBSbnJzMHc0Tg==
jwt.powerToken
=
xxxx
jwt.expireSecond
=
180000
jwt.refreshSecond
=
600
ftp.host
=
cnshaappulv004.asia.pwcinternal.com
ftp.port
=
21
...
...
atms-api/src/main/resources/conf/conf_profile_pub.properties
View file @
72409013
...
...
@@ -13,6 +13,8 @@ web.url=http://192.168.1.102:10000
jwt.base64Secret
=
TXppQjFlZFBSbnJzMHc0Tg==
jwt.powerToken
=
jwt.expireSecond
=
1800
jwt.refreshSecond
=
900
ftp.host
=
cnshaappulv004.asia.pwcinternal.com
ftp.port
=
21
...
...
atms-api/src/main/resources/conf/conf_profile_staging.properties
View file @
72409013
...
...
@@ -13,6 +13,8 @@ web.url=http://cnshaappulv004:8080
jwt.base64Secret
=
TXppQjFlZFBSbnJzMHc0Tg==
jwt.powerToken
=
xxxx
jwt.expireSecond
=
1800
jwt.refreshSecond
=
900
ftp.host
=
cnshaappulv004.asia.pwcinternal.com
ftp.port
=
21
...
...
atms-api/src/test/java/pwc/taxtech/atms/CommonIT.java
View file @
72409013
package
pwc
.
taxtech
.
atms
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.sql.Connection
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.ibatis.jdbc.ScriptRunner
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.junit.runner.RunWith
;
...
...
@@ -13,67 +10,12 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
pwc.taxtech.atms.dao.*
;
import
pwc.taxtech.atms.entitiy.*
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
pwc.taxtech.atms.dao.AccountMappingMapper
;
import
pwc.taxtech.atms.dao.AreaMapper
;
import
pwc.taxtech.atms.dao.AreaRegionMapper
;
import
pwc.taxtech.atms.dao.BusinessUnitMapper
;
import
pwc.taxtech.atms.dao.CacheMapper
;
import
pwc.taxtech.atms.dao.CustomerMapper
;
import
pwc.taxtech.atms.dao.DictionaryMapper
;
import
pwc.taxtech.atms.dao.DimensionMapper
;
import
pwc.taxtech.atms.dao.DimensionValueMapper
;
import
pwc.taxtech.atms.dao.DimensionValueOrgMapper
;
import
pwc.taxtech.atms.dao.EnterpriseAccountMapper
;
import
pwc.taxtech.atms.dao.EnterpriseAccountSetMapper
;
import
pwc.taxtech.atms.dao.EnterpriseAccountSetOrgMapper
;
import
pwc.taxtech.atms.dao.IndustryMapper
;
import
pwc.taxtech.atms.dao.MailQueueMapper
;
import
pwc.taxtech.atms.dao.MenuMapper
;
import
pwc.taxtech.atms.dao.OperationLogBasicDataMapper
;
import
pwc.taxtech.atms.dao.OperationLogEnterPriseMapper
;
import
pwc.taxtech.atms.dao.OperationLogOrganizationMapper
;
import
pwc.taxtech.atms.dao.OperationLogRoleMapper
;
import
pwc.taxtech.atms.dao.OperationLogUserMapper
;
import
pwc.taxtech.atms.dao.OrganizationMapper
;
import
pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper
;
import
pwc.taxtech.atms.dao.OrganizationStructureMapper
;
import
pwc.taxtech.atms.dao.PermissionMapper
;
import
pwc.taxtech.atms.dao.ProjectClientMapper
;
import
pwc.taxtech.atms.dao.RegionMapper
;
import
pwc.taxtech.atms.dao.RoleCategoryMapper
;
import
pwc.taxtech.atms.dao.RoleMapper
;
import
pwc.taxtech.atms.dao.RolePermissionMapper
;
import
pwc.taxtech.atms.dao.ServiceTypeMapper
;
import
pwc.taxtech.atms.dao.StandardAccountMapper
;
import
pwc.taxtech.atms.dao.StatisticAttributeDimensionMapper
;
import
pwc.taxtech.atms.dao.StatisticAttributeMapper
;
import
pwc.taxtech.atms.dao.TemplateGroupMapper
;
import
pwc.taxtech.atms.dao.UserDimensionValueMapper
;
import
pwc.taxtech.atms.dao.UserDimensionValueOrgMapper
;
import
pwc.taxtech.atms.dao.UserDimensionValueRoleMapper
;
import
pwc.taxtech.atms.dao.UserMapper
;
import
pwc.taxtech.atms.dao.UserOrganizationMapper
;
import
pwc.taxtech.atms.dao.UserOrganizationRoleMapper
;
import
pwc.taxtech.atms.dao.UserRoleMapper
;
import
pwc.taxtech.atms.entitiy.AreaExample
;
import
pwc.taxtech.atms.entitiy.AreaRegionExample
;
import
pwc.taxtech.atms.entitiy.CustomerExample
;
import
pwc.taxtech.atms.entitiy.EnterpriseAccountExample
;
import
pwc.taxtech.atms.entitiy.EnterpriseAccountSetExample
;
import
pwc.taxtech.atms.entitiy.EnterpriseAccountSetOrgExample
;
import
pwc.taxtech.atms.entitiy.IndustryExample
;
import
pwc.taxtech.atms.entitiy.MenuExample
;
import
pwc.taxtech.atms.entitiy.OperationLogBasicDataExample
;
import
pwc.taxtech.atms.entitiy.OperationLogEnterPriseExample
;
import
pwc.taxtech.atms.entitiy.OrganizationExample
;
import
pwc.taxtech.atms.entitiy.ProjectClientExample
;
import
pwc.taxtech.atms.entitiy.RegionExample
;
import
pwc.taxtech.atms.entitiy.ServiceTypeExample
;
import
pwc.taxtech.atms.entitiy.StandardAccountExample
;
import
pwc.taxtech.atms.entitiy.TemplateGroupExample
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.sql.Connection
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath:applicationContext.xml"
})
...
...
@@ -159,8 +101,6 @@ public abstract class CommonIT {
@Autowired
protected
OrganizationStructureMapper
organizationStructureMapper
;
@Autowired
protected
CacheMapper
cacheMapper
;
@Autowired
protected
StatisticAttributeDimensionMapper
statisticAttributeDimensionMapper
;
@Autowired
protected
StatisticAttributeMapper
statisticAttributeMapper
;
...
...
atms-api/src/test/java/pwc/taxtech/atms/controller/CacheControllerTest.java
deleted
100644 → 0
View file @
95b91dbd
package
pwc
.
taxtech
.
atms
.
controller
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.*;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
pwc.taxtech.atms.service.CacheService
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
CacheControllerTest
{
@Mock
private
CacheService
cacheService
;
@InjectMocks
private
CacheController
cacheController
;
@Test
public
void
getCacheByKey
()
{
assertThat
(
cacheController
.
getCacheByKey
(
"cacheKey1"
)).
isNull
();
}
@Test
public
void
getAllCache
()
{
assertThat
(
cacheController
.
getAllCache
()).
isEmpty
();
}
}
atms-api/src/test/java/pwc/taxtech/atms/service/impl/CacheServiceIT.java
deleted
100644 → 0
View file @
95b91dbd
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.*;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
pwc.taxtech.atms.CommonIT
;
import
pwc.taxtech.atms.common.CommonUtils
;
import
pwc.taxtech.atms.entitiy.Cache
;
import
pwc.taxtech.atms.service.CacheService
;
public
class
CacheServiceIT
extends
CommonIT
{
@Autowired
private
CacheService
cacheService
;
@Before
public
void
setUp
()
{
cacheMapper
.
deleteByExample
(
null
);
}
@Test
public
void
getAllCache
()
{
insertData
();
// see assertj document
// http://joel-costigliola.github.io/assertj/assertj-core-quick-start.html
assertThat
(
cacheService
.
getAllCache
()).
isNotEmpty
().
filteredOn
(
x
->
x
.
getCacheKey
().
equals
(
"cachekey1"
))
.
isNotEmpty
().
extracting
(
"lastModifyTime"
).
contains
(
"2017-10-18T14:11:01.840+08:00"
);
}
@Test
public
void
shoudWork
()
{
insertData
();
assertThat
(
cacheService
.
getCacheByKey
(
"cachekey1"
)).
isNotNull
().
extracting
(
"lastModifyTime"
)
.
contains
(
"2017-10-18T14:11:01.840+08:00"
);
}
private
void
insertData
()
{
Cache
record
=
new
Cache
();
record
.
setID
(
CommonUtils
.
getUUID
());
record
.
setCacheKey
(
"cachekey1"
);
record
.
setLastModifyTime
(
"2017-10-18T14:11:01.840+08:00"
);
cacheMapper
.
insert
(
record
);
}
}
atms-api/src/test/resources/generatorConfig.xml
View file @
72409013
...
...
@@ -53,48 +53,53 @@
<!--<columnOverride column="is_red_invoice" javaType="java.lang.Boolean"/>-->
<!--</table>-->
<
table
tableName=
"input_invoice_additional"
domainObjectName=
"InputInvoiceAdditional"
>
<
property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/
>
<
columnOverride
column=
"type"
javaType=
"java.lang.Integer"
/
>
<
/table
>
<
!--<table tableName="input_invoice_additional" domainObjectName="InputInvoiceAdditional">--
>
<
!--<property name="ignoreQualifiersAtRuntime" value="true"/>--
>
<
!--<columnOverride column="type" javaType="java.lang.Integer"/>--
>
<
!--</table>--
>
<
table
tableName=
"input_invoice_file"
domainObjectName=
"InputInvoiceFile"
>
<
property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/
>
<
/table
>
<
!--<table tableName="input_invoice_file" domainObjectName="InputInvoiceFile">--
>
<
!--<property name="ignoreQualifiersAtRuntime" value="true"/>--
>
<
!--</table>--
>
<
table
tableName=
"input_invoice_item"
domainObjectName=
"InputInvoiceItem"
>
<
property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/
>
<
/table
>
<
!--<table tableName="input_invoice_item" domainObjectName="InputInvoiceItem">--
>
<
!--<property name="ignoreQualifiersAtRuntime" value="true"/>--
>
<
!--</table>--
>
<
table
tableName=
"input_invoice_item_original"
domainObjectName=
"InputInvoiceItemOriginal"
>
<
property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/
>
<
/table
>
<
!--<table tableName="input_invoice_item_original" domainObjectName="InputInvoiceItemOriginal">--
>
<
!--<property name="ignoreQualifiersAtRuntime" value="true"/>--
>
<
!--</table>--
>
<table
tableName=
"input_invoice_not_received"
domainObjectName=
"InputInvoiceNotReceived"
>
<property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/>
<columnOverride
column=
"invoice_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"upload_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"invoice_entity_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"invoice_source_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"status"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"deductible"
javaType=
"java.lang.Boolean"
/>
<columnOverride
column=
"has_down_file"
javaType=
"java.lang.Boolean"
/>
<columnOverride
column=
"verify_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"deductible_result"
javaType=
"java.lang.Integer"
/>
</table>
<!--<table tableName="input_invoice_not_received" domainObjectName="InputInvoiceNotReceived">-->
<!--<property name="ignoreQualifiersAtRuntime" value="true"/>-->
<!--<columnOverride column="invoice_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="upload_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="invoice_entity_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="invoice_source_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="status" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="deductible" javaType="java.lang.Boolean"/>-->
<!--<columnOverride column="has_down_file" javaType="java.lang.Boolean"/>-->
<!--<columnOverride column="verify_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="deductible_result" javaType="java.lang.Integer"/>-->
<!--</table>-->
<!--<table tableName="input_invoice_original" domainObjectName="InputInvoiceOriginal">-->
<!--<property name="ignoreQualifiersAtRuntime" value="true"/>-->
<!--<columnOverride column="invoice_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="upload_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="invoice_entity_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="invoice_source_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="status" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="deductible" javaType="java.lang.Boolean"/>-->
<!--<columnOverride column="has_down_file" javaType="java.lang.Boolean"/>-->
<!--<columnOverride column="verify_type" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="deductible_result" javaType="java.lang.Integer"/>-->
<!--<columnOverride column="is_red_invoice" javaType="java.lang.Boolean"/>-->
<!--</table>-->
<table
tableName=
"
input_invoice_original"
domainObjectName=
"InputInvoiceOriginal
"
>
<table
tableName=
"
api_cache"
domainObjectName=
"ApiCache
"
>
<property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/>
<columnOverride
column=
"invoice_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"upload_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"invoice_entity_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"invoice_source_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"status"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"deductible"
javaType=
"java.lang.Boolean"
/>
<columnOverride
column=
"has_down_file"
javaType=
"java.lang.Boolean"
/>
<columnOverride
column=
"verify_type"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"deductible_result"
javaType=
"java.lang.Integer"
/>
<columnOverride
column=
"is_red_invoice"
javaType=
"java.lang.Boolean"
/>
<columnOverride
column=
"source_type"
javaType=
"java.lang.Integer"
/>
</table>
</context>
...
...
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