Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
630394c7
Commit
630394c7
authored
Aug 15, 2019
by
季圣华
Browse files
优化日志模块,增加登录日志
parent
4a6a4b4e
Changes
5
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/log.html
View file @
630394c7
...
...
@@ -120,12 +120,11 @@
{
title
:
'
操作模块
'
,
field
:
'
operation
'
,
width
:
120
},
{
title
:
'
操作人员
'
,
field
:
'
username
'
,
width
:
80
,
align
:
"
center
"
},
{
title
:
'
操作IP
'
,
field
:
'
clientip
'
,
width
:
90
,
align
:
"
center
"
},
{
title
:
'
操作时间
'
,
field
:
'
create
t
ime
'
,
width
:
130
,
align
:
"
center
"
},
{
title
:
'
操作详情
'
,
field
:
'
remark
'
,
width
:
26
0
},
{
title
:
'
操作时间
'
,
field
:
'
create
T
ime
Str
'
,
width
:
130
,
align
:
"
center
"
},
{
title
:
'
操作详情
'
,
field
:
'
remark
'
,
width
:
35
0
},
{
title
:
'
操作状态
'
,
field
:
'
status
'
,
width
:
70
,
align
:
"
center
"
,
formatter
:
function
(
value
){
return
value
?
"
失败
"
:
"
成功
"
;
}},
{
title
:
'
备注
'
,
field
:
'
remark
'
,
width
:
150
}
}}
]],
onLoadError
:
function
()
{
$
.
messager
.
alert
(
'
页面加载提示
'
,
'
页面加载异常,请稍后再试!
'
,
'
error
'
);
...
...
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
630394c7
...
...
@@ -137,12 +137,13 @@ public class BusinessConstants {
public
static
final
byte
USER_STATUS_BANNED
=
2
;
/**
* 日志操作
* 新增、修改、删除
* 新增、修改、删除
、登录、导入
* */
public
static
final
String
LOG_OPERATION_TYPE_ADD
=
"新增"
;
public
static
final
String
LOG_OPERATION_TYPE_BATCH_ADD
=
"批量新增"
;
public
static
final
String
LOG_OPERATION_TYPE_EDIT
=
"修改,id:"
;
public
static
final
String
LOG_OPERATION_TYPE_DELETE
=
"删除,id:"
;
public
static
final
String
LOG_OPERATION_TYPE_LOGIN
=
"登录,id:"
;
public
static
final
String
LOG_OPERATION_TYPE_IMPORT
=
"导入"
;
/**
...
...
src/main/java/com/jsh/erp/controller/UserController.java
View file @
630394c7
...
...
@@ -12,6 +12,7 @@ import com.jsh.erp.datasource.entities.User;
import
com.jsh.erp.datasource.entities.UserEx
;
import
com.jsh.erp.datasource.vo.TreeNodeEx
;
import
com.jsh.erp.exception.BusinessParamCheckingException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.tenant.TenantService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.*
;
...
...
@@ -19,6 +20,8 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -51,6 +54,9 @@ public class UserController {
@Resource
private
TenantService
tenantService
;
@Resource
private
LogService
logService
;
private
static
String
message
=
"成功"
;
private
static
final
String
HTTP
=
"http://"
;
private
static
final
String
CODE_OK
=
"200"
;
...
...
@@ -100,11 +106,9 @@ public class UserController {
break
;
default
:
try
{
msgTip
=
"user can login"
;
//验证通过 ,可以登录,放入session,记录登录日志
user
=
userService
.
getUserByUserName
(
username
);
// logService.create(new Logdetails(user, "登录系统", model.getClientIp(),
// new Timestamp(System.currentTimeMillis()), (short) 0, "管理用户:" + username + " 登录系统", username + " 登录系统"));
msgTip
=
"user can login"
;
request
.
getSession
().
setAttribute
(
"user"
,
user
);
if
((
"open"
).
equals
(
mybatisPlusStatus
))
{
if
(
user
.
getTenantId
()!=
null
)
{
...
...
@@ -122,6 +126,9 @@ public class UserController {
}
}
request
.
getSession
().
setAttribute
(
"mybatisPlusStatus"
,
mybatisPlusStatus
);
//开启状态
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_USER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_LOGIN
).
append
(
user
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
">>>>>>>>>>>>>>>查询用户名为:"
+
username
+
" ,用户信息异常"
,
e
);
...
...
src/main/java/com/jsh/erp/datasource/vo/LogVo4List.java
View file @
630394c7
...
...
@@ -6,6 +6,8 @@ public class LogVo4List extends Log {
private
String
username
;
private
String
createTimeStr
;
public
String
getUsername
()
{
return
username
;
}
...
...
@@ -13,4 +15,12 @@ public class LogVo4List extends Log {
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getCreateTimeStr
()
{
return
createTimeStr
;
}
public
void
setCreateTimeStr
(
String
createTimeStr
)
{
this
.
createTimeStr
=
createTimeStr
;
}
}
\ No newline at end of file
src/main/java/com/jsh/erp/service/log/LogService.java
View file @
630394c7
...
...
@@ -11,6 +11,7 @@ import com.jsh.erp.datasource.mappers.LogMapperEx;
import
com.jsh.erp.datasource.vo.LogVo4List
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.Tools
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
...
...
@@ -65,6 +66,11 @@ public class LogService {
try
{
list
=
logMapperEx
.
selectByConditionLog
(
operation
,
usernameID
,
clientIp
,
status
,
beginTime
,
endTime
,
contentdetails
,
offset
,
rows
);
if
(
null
!=
list
)
{
for
(
LogVo4List
log
:
list
)
{
log
.
setCreateTimeStr
(
Tools
.
getCenternTime
(
log
.
getCreatetime
()));
}
}
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
...
...
Write
Preview
Supports
Markdown
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