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
f35d1051
Commit
f35d1051
authored
May 13, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加对Android的支持
parent
21f1112c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
21 deletions
+86
-21
WebAspect.java
...ud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
+4
-5
TokenService.java
...main/java/com/yanzuoguang/cloud/service/TokenService.java
+11
-16
TokenServiceCall.java
.../java/com/yanzuoguang/cloud/service/TokenServiceCall.java
+71
-0
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
View file @
f35d1051
package
com
.
yanzuoguang
.
cloud
.
aop
;
package
com
.
yanzuoguang
.
cloud
.
aop
;
import
com.yanzuoguang.cloud.CloudContans
;
import
com.yanzuoguang.cloud.CloudContans
;
import
com.yanzuoguang.cloud.helper.CookiesHelper
;
import
com.yanzuoguang.cloud.service.TokenServiceCall
;
import
com.yanzuoguang.cloud.service.TokenService
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.contants.ResultConstants
;
import
com.yanzuoguang.util.contants.ResultConstants
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
...
@@ -40,7 +39,7 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -40,7 +39,7 @@ public class WebAspect extends BaseRequestAspect {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseRequestAspect
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseRequestAspect
.
class
);
@Autowired
@Autowired
private
TokenService
tokenService
;
private
TokenService
Call
tokenServiceCall
;
/**
/**
* exec aop point aspect
* exec aop point aspect
...
@@ -64,7 +63,7 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -64,7 +63,7 @@ public class WebAspect extends BaseRequestAspect {
String
name
=
joinPoint
.
getSignature
().
getName
();
String
name
=
joinPoint
.
getSignature
().
getName
();
try
{
try
{
logger
.
info
(
"[ {} ] request params is {}"
,
name
,
joinPoint
.
getArgs
());
logger
.
info
(
"[ {} ] request params is {}"
,
name
,
joinPoint
.
getArgs
());
tokenService
.
tokenInit
();
tokenService
Call
.
tokenInit
();
Object
result
=
executeMethod
(
joinPoint
,
name
);
Object
result
=
executeMethod
(
joinPoint
,
name
);
if
(
result
instanceof
ResponseResult
)
{
if
(
result
instanceof
ResponseResult
)
{
...
@@ -87,7 +86,7 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -87,7 +86,7 @@ public class WebAspect extends BaseRequestAspect {
throw
e
;
throw
e
;
}
}
}
finally
{
}
finally
{
tokenService
.
tokenFinish
();
tokenService
Call
.
tokenFinish
();
Log
.
threadCommit
();
Log
.
threadCommit
();
saveInterLogs
(
joinPoint
,
responseResult
);
saveInterLogs
(
joinPoint
,
responseResult
);
}
}
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/service/TokenService.java
View file @
f35d1051
package
com
.
yanzuoguang
.
cloud
.
service
;
package
com
.
yanzuoguang
.
cloud
.
service
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.yanzuoguang.token.TokenLoad
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Component
;
/**
/**
* Token服务
* Token服务
实现接口
*
*
* @author 颜佐光
* @author 颜佐光
*/
*/
@Component
public
interface
TokenService
extends
TokenLoad
{
public
class
TokenService
{
@Autowired
/**
private
ApplicationContext
context
;
* 初始化token
*/
public
void
tokenInit
()
{
void
tokenInit
();
}
public
void
tokenFinish
()
{
}
/**
* 结束token
*/
void
tokenFinish
();
}
}
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/service/TokenServiceCall.java
0 → 100644
View file @
f35d1051
package
com
.
yanzuoguang
.
cloud
.
service
;
import
com.yanzuoguang.token.TokenData
;
import
com.yanzuoguang.token.TokenLoad
;
import
com.yanzuoguang.util.log.Log
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Component
;
/**
* Token服务
*
* @author 颜佐光
*/
@Component
public
class
TokenServiceCall
implements
TokenLoad
{
@Autowired
private
ApplicationContext
context
;
private
TokenService
tokenService
=
null
;
private
boolean
initFlag
=
false
;
private
void
init
()
{
try
{
tokenService
=
context
.
getBean
(
TokenService
.
class
);
}
catch
(
Exception
ex
)
{
Log
.
error
(
TokenServiceCall
.
class
,
"获取登录服务失败:"
+
ex
.
getMessage
(),
ex
);
}
finally
{
initFlag
=
true
;
}
}
/**
* 请求时初始化token
*/
public
void
tokenInit
()
{
init
();
if
(
tokenService
==
null
)
{
return
;
}
tokenService
.
tokenInit
();
}
/**
* 请求时结束token
*/
public
void
tokenFinish
()
{
init
();
if
(
tokenService
==
null
)
{
return
;
}
tokenService
.
tokenFinish
();
}
/**
* 根据token标记加载
*
* @param token 加载标记
* @return
*/
@Override
public
TokenData
load
(
String
token
)
{
init
();
if
(
tokenService
==
null
)
{
return
null
;
}
return
tokenService
.
load
(
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