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
0ceb925b
Commit
0ceb925b
authored
Jan 20, 2019
by
季圣华
Browse files
完善记录日志的功能
parent
249961ab
Changes
4
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/log.html
View file @
0ceb925b
...
@@ -122,7 +122,9 @@
...
@@ -122,7 +122,9 @@
{
title
:
'
操作IP
'
,
field
:
'
clientip
'
,
width
:
90
,
align
:
"
center
"
},
{
title
:
'
操作IP
'
,
field
:
'
clientip
'
,
width
:
90
,
align
:
"
center
"
},
{
title
:
'
操作时间
'
,
field
:
'
createtime
'
,
width
:
130
,
align
:
"
center
"
},
{
title
:
'
操作时间
'
,
field
:
'
createtime
'
,
width
:
130
,
align
:
"
center
"
},
{
title
:
'
操作详情
'
,
field
:
'
remark
'
,
width
:
380
},
{
title
:
'
操作详情
'
,
field
:
'
remark
'
,
width
:
380
},
{
title
:
'
操作状态
'
,
field
:
'
status
'
,
width
:
70
},
{
title
:
'
操作状态
'
,
field
:
'
status
'
,
width
:
70
,
align
:
"
center
"
,
formatter
:
function
(
value
){
return
value
?
"
失败
"
:
"
成功
"
;
}},
{
title
:
'
备注
'
,
field
:
'
remark
'
,
width
:
180
}
{
title
:
'
备注
'
,
field
:
'
remark
'
,
width
:
180
}
]],
]],
onLoadError
:
function
()
{
onLoadError
:
function
()
{
...
...
src/main/java/com/jsh/erp/controller/ResourceController.java
View file @
0ceb925b
...
@@ -74,7 +74,7 @@ public class ResourceController {
...
@@ -74,7 +74,7 @@ public class ResourceController {
@RequestParam
(
"info"
)
String
beanJson
,
@RequestParam
(
"info"
)
String
beanJson
,
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
{
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
update
=
configResourceManager
.
update
(
apiName
,
beanJson
,
id
);
int
update
=
configResourceManager
.
update
(
apiName
,
beanJson
,
id
,
request
);
if
(
update
>
0
)
{
if
(
update
>
0
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
else
{
}
else
{
...
@@ -86,7 +86,7 @@ public class ResourceController {
...
@@ -86,7 +86,7 @@ public class ResourceController {
public
String
deleteResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
public
String
deleteResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
@PathVariable
Long
id
,
HttpServletRequest
request
)
{
@PathVariable
Long
id
,
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
delete
=
configResourceManager
.
delete
(
apiName
,
id
);
int
delete
=
configResourceManager
.
delete
(
apiName
,
id
,
request
);
if
(
delete
>
0
)
{
if
(
delete
>
0
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
else
{
}
else
{
...
@@ -98,7 +98,7 @@ public class ResourceController {
...
@@ -98,7 +98,7 @@ public class ResourceController {
public
String
batchDeleteResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
public
String
batchDeleteResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
@RequestParam
(
"ids"
)
String
ids
,
HttpServletRequest
request
)
{
@RequestParam
(
"ids"
)
String
ids
,
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
delete
=
configResourceManager
.
batchDelete
(
apiName
,
ids
);
int
delete
=
configResourceManager
.
batchDelete
(
apiName
,
ids
,
request
);
if
(
delete
>
0
)
{
if
(
delete
>
0
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
else
{
}
else
{
...
...
src/main/java/com/jsh/erp/service/CommonQueryManager.java
View file @
0ceb925b
package
com.jsh.erp.service
;
package
com.jsh.erp.service
;
import
com.jsh.erp.datasource.entities.Log
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.LogMapper
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -7,9 +10,12 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -7,9 +10,12 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
static
com
.
jsh
.
erp
.
utils
.
Tools
.
getLocalIp
;
/**
/**
* @author jishenghua 752718920 2018-10-7 15:25:58
* @author jishenghua 752718920 2018-10-7 15:25:58
*/
*/
...
@@ -19,6 +25,9 @@ public class CommonQueryManager {
...
@@ -19,6 +25,9 @@ public class CommonQueryManager {
@Resource
@Resource
private
InterfaceContainer
container
;
private
InterfaceContainer
container
;
@Resource
private
LogMapper
logMapper
;
/**
/**
* 查询单条
* 查询单条
*
*
...
@@ -67,6 +76,7 @@ public class CommonQueryManager {
...
@@ -67,6 +76,7 @@ public class CommonQueryManager {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insert
(
String
apiName
,
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insert
(
String
apiName
,
String
beanJson
,
HttpServletRequest
request
)
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
insertLog
(
apiName
,
"新增"
,
request
);
return
container
.
getCommonQuery
(
apiName
).
insert
(
beanJson
,
request
);
return
container
.
getCommonQuery
(
apiName
).
insert
(
beanJson
,
request
);
}
}
return
0
;
return
0
;
...
@@ -80,8 +90,9 @@ public class CommonQueryManager {
...
@@ -80,8 +90,9 @@ public class CommonQueryManager {
* @return
* @return
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
update
(
String
apiName
,
String
beanJson
,
Long
id
)
{
public
int
update
(
String
apiName
,
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
insertLog
(
apiName
,
"更新,id:"
+
id
,
request
);
return
container
.
getCommonQuery
(
apiName
).
update
(
beanJson
,
id
);
return
container
.
getCommonQuery
(
apiName
).
update
(
beanJson
,
id
);
}
}
return
0
;
return
0
;
...
@@ -94,8 +105,9 @@ public class CommonQueryManager {
...
@@ -94,8 +105,9 @@ public class CommonQueryManager {
* @return
* @return
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
delete
(
String
apiName
,
Long
id
)
{
public
int
delete
(
String
apiName
,
Long
id
,
HttpServletRequest
request
)
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
insertLog
(
apiName
,
"删除,id:"
+
id
,
request
);
return
container
.
getCommonQuery
(
apiName
).
delete
(
id
);
return
container
.
getCommonQuery
(
apiName
).
delete
(
id
);
}
}
return
0
;
return
0
;
...
@@ -108,8 +120,9 @@ public class CommonQueryManager {
...
@@ -108,8 +120,9 @@ public class CommonQueryManager {
* @return
* @return
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDelete
(
String
apiName
,
String
ids
)
{
public
int
batchDelete
(
String
apiName
,
String
ids
,
HttpServletRequest
request
)
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
insertLog
(
apiName
,
"批量删除,id集:"
+
ids
,
request
);
return
container
.
getCommonQuery
(
apiName
).
batchDelete
(
ids
);
return
container
.
getCommonQuery
(
apiName
).
batchDelete
(
ids
);
}
}
return
0
;
return
0
;
...
@@ -129,4 +142,78 @@ public class CommonQueryManager {
...
@@ -129,4 +142,78 @@ public class CommonQueryManager {
return
0
;
return
0
;
}
}
/**
* 获取用户id
* @param request
* @return
*/
public
Long
getUserId
(
HttpServletRequest
request
)
{
Object
userInfo
=
request
.
getSession
().
getAttribute
(
"user"
);
if
(
userInfo
!=
null
)
{
User
user
=
(
User
)
userInfo
;
return
user
.
getId
();
}
else
{
return
null
;
}
}
public
String
getModule
(
String
apiName
){
String
moduleName
=
null
;
switch
(
apiName
)
{
case
"user"
:
moduleName
=
"用户"
;
break
;
case
"role"
:
moduleName
=
"角色"
;
break
;
case
"app"
:
moduleName
=
"应用"
;
break
;
case
"depot"
:
moduleName
=
"仓库"
;
break
;
case
"functions"
:
moduleName
=
"功能"
;
break
;
case
"inOutItem"
:
moduleName
=
"收支项目"
;
break
;
case
"unit"
:
moduleName
=
"计量单位"
;
break
;
case
"person"
:
moduleName
=
"经手人"
;
break
;
case
"userBusiness"
:
moduleName
=
"关联关系"
;
break
;
case
"systemConfig"
:
moduleName
=
"系统配置"
;
break
;
case
"materialProperty"
:
moduleName
=
"商品属性"
;
break
;
case
"account"
:
moduleName
=
"账户"
;
break
;
case
"supplier"
:
moduleName
=
"商家"
;
break
;
case
"materialCategory"
:
moduleName
=
"商品类型"
;
break
;
case
"material"
:
moduleName
=
"商品"
;
break
;
case
"depotHead"
:
moduleName
=
"单据表头"
;
break
;
case
"depotItem"
:
moduleName
=
"单据明细"
;
break
;
case
"accountHead"
:
moduleName
=
"财务表头"
;
break
;
case
"accountItem"
:
moduleName
=
"财务明细"
;
break
;
}
return
moduleName
;
}
public
void
insertLog
(
String
apiName
,
String
type
,
HttpServletRequest
request
){
Log
log
=
new
Log
();
log
.
setUserid
(
getUserId
(
request
));
log
.
setOperation
(
getModule
(
apiName
));
log
.
setClientip
(
getLocalIp
(
request
));
log
.
setCreatetime
(
new
Date
());
Byte
status
=
0
;
log
.
setStatus
(
status
);
log
.
setContentdetails
(
type
+
getModule
(
apiName
));
log
.
setRemark
(
type
+
getModule
(
apiName
));
logMapper
.
insertSelective
(
log
);
}
}
}
\ No newline at end of file
src/main/java/com/jsh/erp/utils/Tools.java
View file @
0ceb925b
package
com.jsh.erp.utils
;
package
com.jsh.erp.utils
;
import
com.alibaba.druid.util.StringUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
...
...
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