Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
JAVA小学生-王铁柱
eladmin
提交
e245296c
E
eladmin
项目概览
JAVA小学生-王铁柱
/
eladmin
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
eladmin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e245296c
编写于
10月 26, 2019
作者:
D
dqjdda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
日志加入浏览器字段
上级
0c738b1e
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
76 addition
and
30 deletion
+76
-30
eladmin-common/pom.xml
eladmin-common/pom.xml
+0
-1
eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java
...n-common/src/main/java/me/zhengjie/utils/StringUtils.java
+8
-0
eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java
...n-logging/src/main/java/me/zhengjie/aspect/LogAspect.java
+6
-2
eladmin-logging/src/main/java/me/zhengjie/domain/Log.java
eladmin-logging/src/main/java/me/zhengjie/domain/Log.java
+2
-0
eladmin-logging/src/main/java/me/zhengjie/service/LogService.java
...logging/src/main/java/me/zhengjie/service/LogService.java
+1
-1
eladmin-logging/src/main/java/me/zhengjie/service/dto/LogErrorDTO.java
...ng/src/main/java/me/zhengjie/service/dto/LogErrorDTO.java
+2
-0
eladmin-logging/src/main/java/me/zhengjie/service/dto/LogSmallDTO.java
...ng/src/main/java/me/zhengjie/service/dto/LogSmallDTO.java
+2
-0
eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
...rc/main/java/me/zhengjie/service/impl/LogServiceImpl.java
+2
-1
eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/OnlineUser.java
...ava/me/zhengjie/modules/monitor/domain/vo/OnlineUser.java
+24
-0
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java
...ngjie/modules/security/rest/AuthenticationController.java
+4
-4
eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthInfo.java
.../java/me/zhengjie/modules/security/security/AuthInfo.java
+19
-19
eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthUser.java
.../java/me/zhengjie/modules/security/security/AuthUser.java
+1
-1
eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAuthorizationTokenFilter.java
...odules/security/security/JwtAuthorizationTokenFilter.java
+0
-1
pom.xml
pom.xml
+5
-0
未找到文件。
eladmin-common/pom.xml
浏览文件 @
e245296c
...
...
@@ -11,5 +11,4 @@
<artifactId>
eladmin-common
</artifactId>
<name>
公共模块
</name>
</project>
\ No newline at end of file
eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java
浏览文件 @
e245296c
package
me.zhengjie.utils
;
import
cn.hutool.core.io.resource.ClassPathResource
;
import
eu.bitwalker.useragentutils.Browser
;
import
eu.bitwalker.useragentutils.UserAgent
;
import
org.lionsoul.ip2region.DataBlock
;
import
org.lionsoul.ip2region.DbConfig
;
import
org.lionsoul.ip2region.DbSearcher
;
...
...
@@ -157,6 +159,12 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return
""
;
}
public
static
String
getBrowser
(
HttpServletRequest
request
){
UserAgent
userAgent
=
UserAgent
.
parseUserAgentString
(
request
.
getHeader
(
"User-Agent"
));
Browser
browser
=
userAgent
.
getBrowser
();
return
browser
.
getName
();
}
/**
* 获得当天是周几
*/
...
...
eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java
浏览文件 @
e245296c
...
...
@@ -15,6 +15,8 @@ import org.aspectj.lang.annotation.Aspect;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @author Zheng Jie
* @date 2018-11-24
...
...
@@ -51,7 +53,8 @@ public class LogAspect {
currentTime
=
System
.
currentTimeMillis
();
result
=
joinPoint
.
proceed
();
Log
log
=
new
Log
(
"INFO"
,
System
.
currentTimeMillis
()
-
currentTime
);
logService
.
save
(
getUsername
(),
StringUtils
.
getIp
(
RequestHolder
.
getHttpServletRequest
()),
joinPoint
,
log
);
HttpServletRequest
request
=
RequestHolder
.
getHttpServletRequest
();
logService
.
save
(
getUsername
(),
StringUtils
.
getBrowser
(
request
),
StringUtils
.
getIp
(
request
),
joinPoint
,
log
);
return
result
;
}
...
...
@@ -65,7 +68,8 @@ public class LogAspect {
public
void
logAfterThrowing
(
JoinPoint
joinPoint
,
Throwable
e
)
{
Log
log
=
new
Log
(
"ERROR"
,
System
.
currentTimeMillis
()
-
currentTime
);
log
.
setExceptionDetail
(
ThrowableUtil
.
getStackTrace
(
e
).
getBytes
());
logService
.
save
(
getUsername
(),
StringUtils
.
getIp
(
RequestHolder
.
getHttpServletRequest
()),
(
ProceedingJoinPoint
)
joinPoint
,
log
);
HttpServletRequest
request
=
RequestHolder
.
getHttpServletRequest
();
logService
.
save
(
getUsername
(),
StringUtils
.
getBrowser
(
request
),
StringUtils
.
getIp
(
request
),
(
ProceedingJoinPoint
)
joinPoint
,
log
);
}
public
String
getUsername
()
{
...
...
eladmin-logging/src/main/java/me/zhengjie/domain/Log.java
浏览文件 @
e245296c
...
...
@@ -45,6 +45,8 @@ public class Log implements Serializable {
@Column
(
name
=
"address"
)
private
String
address
;
private
String
browser
;
// 请求耗时
private
Long
time
;
...
...
eladmin-logging/src/main/java/me/zhengjie/service/LogService.java
浏览文件 @
e245296c
...
...
@@ -17,7 +17,7 @@ public interface LogService {
Object
queryAllByUser
(
LogQueryCriteria
criteria
,
Pageable
pageable
);
@Async
void
save
(
String
username
,
String
ip
,
ProceedingJoinPoint
joinPoint
,
Log
log
);
void
save
(
String
username
,
String
browser
,
String
ip
,
ProceedingJoinPoint
joinPoint
,
Log
log
);
/**
* 查询异常详情
...
...
eladmin-logging/src/main/java/me/zhengjie/service/dto/LogErrorDTO.java
浏览文件 @
e245296c
...
...
@@ -25,6 +25,8 @@ public class LogErrorDTO implements Serializable {
// 参数
private
String
params
;
private
String
browser
;
// 请求ip
private
String
requestIp
;
...
...
eladmin-logging/src/main/java/me/zhengjie/service/dto/LogSmallDTO.java
浏览文件 @
e245296c
...
...
@@ -22,6 +22,8 @@ public class LogSmallDTO implements Serializable {
private
String
address
;
private
String
browser
;
// 创建日期
private
Timestamp
createTime
;
}
eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
浏览文件 @
e245296c
...
...
@@ -57,7 +57,7 @@ public class LogServiceImpl implements LogService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
save
(
String
username
,
String
ip
,
ProceedingJoinPoint
joinPoint
,
Log
log
){
public
void
save
(
String
username
,
String
browser
,
String
ip
,
ProceedingJoinPoint
joinPoint
,
Log
log
){
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
Method
method
=
signature
.
getMethod
();
...
...
@@ -96,6 +96,7 @@ public class LogServiceImpl implements LogService {
log
.
setMethod
(
methodName
);
log
.
setUsername
(
username
);
log
.
setParams
(
params
.
toString
()
+
" }"
);
log
.
setBrowser
(
browser
);
logRepository
.
save
(
log
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/OnlineUser.java
0 → 100644
浏览文件 @
e245296c
package
me.zhengjie.modules.monitor.domain.vo
;
import
lombok.Data
;
import
java.sql.Timestamp
;
import
java.util.Date
;
/**
* @author Zheng Jie
*/
@Data
public
class
OnlineUser
{
private
String
userName
;
private
String
browser
;
private
String
ip
;
private
String
address
;
private
Date
createTime
;
private
Date
lastAccessTime
;
}
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java
浏览文件 @
e245296c
...
...
@@ -8,8 +8,8 @@ import lombok.extern.slf4j.Slf4j;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.monitor.service.RedisService
;
import
me.zhengjie.modules.security.security.Auth
entication
Info
;
import
me.zhengjie.modules.security.security.Auth
orization
User
;
import
me.zhengjie.modules.security.security.AuthInfo
;
import
me.zhengjie.modules.security.security.AuthUser
;
import
me.zhengjie.modules.security.security.ImgResult
;
import
me.zhengjie.modules.security.security.JwtUser
;
import
me.zhengjie.utils.EncryptUtils
;
...
...
@@ -53,7 +53,7 @@ public class AuthenticationController {
@Log
(
"用户登录"
)
@ApiOperation
(
"登录授权"
)
@PostMapping
(
value
=
"/login"
)
public
ResponseEntity
login
(
@Validated
@RequestBody
Auth
orization
User
authorizationUser
){
public
ResponseEntity
login
(
@Validated
@RequestBody
AuthUser
authorizationUser
){
// 查询验证码
String
code
=
redisService
.
getCodeVal
(
authorizationUser
.
getUuid
());
...
...
@@ -79,7 +79,7 @@ public class AuthenticationController {
final
String
token
=
jwtTokenUtil
.
generateToken
(
jwtUser
);
// 返回 token
return
ResponseEntity
.
ok
(
new
Auth
entication
Info
(
token
,
jwtUser
));
return
ResponseEntity
.
ok
(
new
AuthInfo
(
token
,
jwtUser
));
}
@ApiOperation
(
"获取用户信息"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/security/Auth
entication
Info.java
→
eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthInfo.java
浏览文件 @
e245296c
package
me.zhengjie.modules.security.security
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
java.io.Serializable
;
/**
* @author Zheng Jie
* @date 2018-11-23
* 返回token
*/
@Getter
@AllArgsConstructor
public
class
Auth
enticationInfo
implements
Serializable
{
private
final
String
token
;
private
final
JwtUser
user
;
}
package
me.zhengjie.modules.security.security
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
java.io.Serializable
;
/**
* @author Zheng Jie
* @date 2018-11-23
* 返回token
*/
@Getter
@AllArgsConstructor
public
class
Auth
Info
implements
Serializable
{
private
final
String
token
;
private
final
JwtUser
user
;
}
eladmin-system/src/main/java/me/zhengjie/modules/security/security/Auth
orization
User.java
→
eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthUser.java
浏览文件 @
e245296c
...
...
@@ -11,7 +11,7 @@ import javax.validation.constraints.NotBlank;
*/
@Getter
@Setter
public
class
Auth
orization
User
{
public
class
AuthUser
{
@NotBlank
private
String
username
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAuthorizationTokenFilter.java
浏览文件 @
e245296c
...
...
@@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.web.authentication.WebAuthenticationDetailsSource
;
import
org.springframework.stereotype.Component
;
...
...
pom.xml
浏览文件 @
e245296c
...
...
@@ -200,6 +200,11 @@
<artifactId>
easy-captcha
</artifactId>
<version>
1.6.2
</version>
</dependency>
<dependency>
<groupId>
eu.bitwalker
</groupId>
<artifactId>
UserAgentUtils
</artifactId>
<version>
1.20
</version>
</dependency>
</dependencies>
<build>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录