完善日志监控 对参数的监控

This commit is contained in:
zxm 2018-01-04 22:04:10 +08:00
parent facedfd3ea
commit cd0a00736f
5 changed files with 40 additions and 55 deletions

View File

@ -124,7 +124,7 @@ public class UserController extends BaseController{
}
@ApiOperation(value = "/updateUser", httpMethod = "POST", notes = "更新用户")
@Log(desc = "更新用户")
@Log(desc = "更新用户",type = LOG_TYPE.UPDATE)
@PostMapping(value = "updateUser")
@ResponseBody
public JsonUtil updateUser(SysUser user,String role[]) {

View File

@ -1,5 +1,6 @@
package com.len.core.annotation;
import com.alibaba.fastjson.JSON;
import com.len.base.CurrentUser;
import com.len.core.shiro.ShiroUtil;
import com.len.entity.SysLog;
@ -53,6 +54,17 @@ public class LogAspect {
log.setCreateTime(new Date());
log.setType(type.toString());
log.setText(text);
Object[] obj= jp.getArgs();
StringBuffer buffer=new StringBuffer();
if(obj!=null){
for(int i=0;i<obj.length;i++){
buffer.append("[参数"+(i+1)+":");
buffer.append(JSON.toJSONString(obj[i]));
buffer.append("]");
}
}
log.setParam(buffer.toString());
if(currentUser!=null){
log.setUserName(currentUser.getUsername());
logMapper.insert(log);

View File

@ -2,7 +2,13 @@ package com.len.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class SysLog implements Serializable {
private Integer id;
@ -14,55 +20,9 @@ public class SysLog implements Serializable {
private String text;
private String param;
private Date createTime;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName == null ? null : userName.trim();
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip == null ? null : ip.trim();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text == null ? null : text.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -123,9 +123,10 @@
, cols: [[
{checkbox: true, fixed: true, width: '5%'}
, {field: 'userName', title: '操作人', width: '10%', sort: true}
, {field: 'type', title: '操作类型', width: '10%', sort: true}
, {field: 'text', title: '描述内容', width: '30%', sort: true}
, {field: 'createTime', title: '操作时间', width: '25%',templet: '<div>{{ layui.laytpl.toDateString(d.createTime,"yyyy-MM-dd HH:mm:ss") }}</div>'}
, {field: 'type', title: '操作类型', width: '5%', sort: true}
, {field: 'text', title: '描述内容', width: '10%', sort: true}
, {field: 'param', title: '参数', width: '45%', sort: true}
, {field: 'createTime', title: '操作时间', width: '10%',templet: '<div>{{ layui.laytpl.toDateString(d.createTime,"yyyy-MM-dd HH:mm:ss") }}</div>'}
, {field: 'text', title: '操作', width: '20%', toolbar:'#toolBar'}
]]

View File

@ -7,10 +7,11 @@
<result column="ip" jdbcType="VARCHAR" property="ip" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="text" jdbcType="VARCHAR" property="text" />
<result column="param" jdbcType="VARCHAR" property="param" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_name, ip, type, text, create_time
id, user_name, ip, type, text, param, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@ -24,10 +25,11 @@
</delete>
<insert id="insert" parameterType="com.len.entity.SysLog">
insert into sys_log (id, user_name, ip,
type, text, create_time
type, text,param,create_time
)
values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{text,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
#{type,jdbcType=VARCHAR}, #{text,jdbcType=VARCHAR},#{param,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.len.entity.SysLog">
@ -48,6 +50,9 @@
<if test="text != null">
text,
</if>
<if test="text != null">
param,
</if>
<if test="createTime != null">
create_time,
</if>
@ -68,6 +73,9 @@
<if test="text != null">
#{text,jdbcType=VARCHAR},
</if>
<if test="param != null">
#{param,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
@ -88,6 +96,9 @@
<if test="text != null">
text = #{text,jdbcType=VARCHAR},
</if>
<if test="param != null">
param = #{param,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
@ -100,6 +111,7 @@
ip = #{ip,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
text = #{text,jdbcType=VARCHAR},
param = #{param,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>