Showing
5 changed files
with
126 additions
and
2 deletions
@@ -10,10 +10,18 @@ import java.io.Serializable; | @@ -10,10 +10,18 @@ import java.io.Serializable; | ||
10 | @Data | 10 | @Data |
11 | public class UserOperate implements Serializable{ | 11 | public class UserOperate implements Serializable{ |
12 | 12 | ||
13 | + //用户名 | ||
13 | private String user; | 14 | private String user; |
14 | - | 15 | + //操作uri |
15 | private String operate; | 16 | private String operate; |
17 | + //操作uri名称 | ||
18 | + private String operateDesc; | ||
16 | 19 | ||
20 | + //操作参数 | ||
21 | + private String params; | ||
22 | + //操作时间 | ||
17 | private String time; | 23 | private String time; |
24 | + private java.util.Date ts; | ||
25 | + | ||
18 | 26 | ||
19 | } | 27 | } |
1 | +package com.model; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by craig.qin on 2018/1/29. | ||
7 | + */ | ||
8 | +@Data | ||
9 | +public class UserOperateLog { | ||
10 | + | ||
11 | + private int id; | ||
12 | + | ||
13 | + //用户名 | ||
14 | + private String userName; | ||
15 | + //操作uri | ||
16 | + private String operate; | ||
17 | + //操作uri名称 | ||
18 | + private String operateDesc; | ||
19 | + | ||
20 | + //操作参数 | ||
21 | + private String params; | ||
22 | + | ||
23 | + //操作时间 | ||
24 | + private java.util.Date createTime; | ||
25 | + | ||
26 | +} |
1 | +package com.monitor.mysql.mapper; | ||
2 | + | ||
3 | +import com.model.UserOperateLog; | ||
4 | +import com.monitor.model.domain.PageBean; | ||
5 | +import com.monitor.model.domain.UserOperate; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by craig.qin 2018/1/29 | ||
11 | + */ | ||
12 | +public interface UserOperateLogMapper { | ||
13 | + | ||
14 | + int selectCount(PageBean page);//查询总数量 | ||
15 | + | ||
16 | + List<UserOperate> selectByPage(PageBean page); | ||
17 | + | ||
18 | + int insert(UserOperateLog userOperateLog); | ||
19 | + | ||
20 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.monitor.mysql.mapper.UserOperateLogMapper" > | ||
4 | + <resultMap id="BaseResultMap" type="com.model.UserOperateLog" > | ||
5 | + <id column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="user_name" property="userName" jdbcType="VARCHAR" /> | ||
7 | + <result column="operate" property="operate" jdbcType="VARCHAR" /> | ||
8 | + <result column="operate_desc" property="operateDesc" jdbcType="VARCHAR" /> | ||
9 | + <result column="params" property="params" jdbcType="VARCHAR" /> | ||
10 | + <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> | ||
11 | + </resultMap> | ||
12 | + | ||
13 | + <sql id="Base_Column_List" > | ||
14 | + id, user_name, operate,operate_desc,params,create_time | ||
15 | + </sql> | ||
16 | + | ||
17 | + | ||
18 | + <select id="selectCount" resultType="java.lang.Integer"> | ||
19 | + select | ||
20 | + count(1) | ||
21 | + from user_operate_logs | ||
22 | + where | ||
23 | + 1=1 | ||
24 | + where 1=1 | ||
25 | + <if test="params.beginTime !=null && params.beginTime !=''"> | ||
26 | + and create_time >= #{params.beginTime,jdbcType=TIMESTAMP} | ||
27 | + </if> | ||
28 | + <if test="params.endTime !=null && params.endTime !=''"> | ||
29 | + and create_time <= #{params.endTime,jdbcType=TIMESTAMP} | ||
30 | + </if> | ||
31 | + </select> | ||
32 | + | ||
33 | + <select id="selectByPage" resultMap="BaseResultMap"> | ||
34 | + select | ||
35 | + <include refid="Base_Column_List" /> | ||
36 | + from user_operate_logs | ||
37 | + where 1=1 | ||
38 | + <if test="params.beginTime !=null && params.beginTime !=''"> | ||
39 | + and create_time >= #{params.beginTime,jdbcType=TIMESTAMP} | ||
40 | + </if> | ||
41 | + <if test="params.endTime !=null && params.endTime !=''"> | ||
42 | + and create_time <= #{params.endTime,jdbcType=TIMESTAMP} | ||
43 | + </if> | ||
44 | + order by id desc | ||
45 | + limit #{startIndex},#{pageSize} | ||
46 | + </select> | ||
47 | + | ||
48 | + <insert id="insert" parameterType="com.model.UserOperateLog" > | ||
49 | + insert into user_operate_logs | ||
50 | + (user_name, operate,operate_desc,params,create_time) | ||
51 | + values | ||
52 | + (#{userName,jdbcType=VARCHAR},#{operate,jdbcType=VARCHAR},#{operateDesc,jdbcType=VARCHAR}, | ||
53 | + #{params,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}) | ||
54 | + </insert> | ||
55 | + | ||
56 | +</mapper> |
1 | package com.monitor.user.ctrl; | 1 | package com.monitor.user.ctrl; |
2 | 2 | ||
3 | import com.model.User; | 3 | import com.model.User; |
4 | +import com.model.UserOperateLog; | ||
4 | import com.monitor.common.service.AppRedisService; | 5 | import com.monitor.common.service.AppRedisService; |
5 | import com.monitor.common.service.MailService; | 6 | import com.monitor.common.service.MailService; |
6 | import com.monitor.common.util.MD5Util; | 7 | import com.monitor.common.util.MD5Util; |
@@ -13,6 +14,7 @@ import com.monitor.model.page.PageResponse; | @@ -13,6 +14,7 @@ import com.monitor.model.page.PageResponse; | ||
13 | import com.monitor.model.request.UserOperateReq; | 14 | import com.monitor.model.request.UserOperateReq; |
14 | import com.monitor.model.response.BaseResponse; | 15 | import com.monitor.model.response.BaseResponse; |
15 | import com.monitor.mysql.mapper.UserMapper; | 16 | import com.monitor.mysql.mapper.UserMapper; |
17 | +import com.monitor.mysql.mapper.UserOperateLogMapper; | ||
16 | import com.util.GetUsersInfoUtil; | 18 | import com.util.GetUsersInfoUtil; |
17 | import org.slf4j.Logger; | 19 | import org.slf4j.Logger; |
18 | import org.slf4j.LoggerFactory; | 20 | import org.slf4j.LoggerFactory; |
@@ -35,8 +37,13 @@ public class UserCtrl { | @@ -35,8 +37,13 @@ public class UserCtrl { | ||
35 | @Autowired | 37 | @Autowired |
36 | UserMapper userMapper; | 38 | UserMapper userMapper; |
37 | 39 | ||
40 | +/* | ||
38 | @Autowired | 41 | @Autowired |
39 | UserOperateMapper userOperateMapper; | 42 | UserOperateMapper userOperateMapper; |
43 | +*/ | ||
44 | + | ||
45 | + @Autowired | ||
46 | + private UserOperateLogMapper userOperateLogMapper; | ||
40 | 47 | ||
41 | @Autowired | 48 | @Autowired |
42 | private MailService mailService; | 49 | private MailService mailService; |
@@ -211,7 +218,14 @@ public class UserCtrl { | @@ -211,7 +218,14 @@ public class UserCtrl { | ||
211 | public String operate(@RequestBody UserOperateReq userOperateReq) { | 218 | public String operate(@RequestBody UserOperateReq userOperateReq) { |
212 | List<UserOperate> list = userOperateReq.getList(); | 219 | List<UserOperate> list = userOperateReq.getList(); |
213 | for (UserOperate userOperate : list) { | 220 | for (UserOperate userOperate : list) { |
214 | - userOperateMapper.insert(userOperate); | 221 | + // userOperateMapper.insert(userOperate); |
222 | + UserOperateLog userOperateLog=new UserOperateLog(); | ||
223 | + userOperateLog.setUserName(userOperate.getUser()); | ||
224 | + userOperateLog.setOperate(userOperate.getOperate()); | ||
225 | + userOperateLog.setOperateDesc(userOperate.getOperateDesc()); | ||
226 | + userOperateLog.setParams(userOperate.getParams()); | ||
227 | + userOperateLog.setCreateTime(userOperate.getTs()); | ||
228 | + userOperateLogMapper.insert(userOperateLog); | ||
215 | } | 229 | } |
216 | return ""; | 230 | return ""; |
217 | } | 231 | } |
-
Please register or login to post a comment