Commit 6f2bcf7f authored by 季圣华's avatar 季圣华
Browse files

优化日志查询接口

parent 6c92337f
...@@ -11,7 +11,7 @@ public interface LogMapperEx { ...@@ -11,7 +11,7 @@ public interface LogMapperEx {
List<LogVo4List> selectByConditionLog( List<LogVo4List> selectByConditionLog(
@Param("operation") String operation, @Param("operation") String operation,
@Param("userId") Integer userId, @Param("userInfo") String userInfo,
@Param("clientIp") String clientIp, @Param("clientIp") String clientIp,
@Param("status") Integer status, @Param("status") Integer status,
@Param("beginTime") String beginTime, @Param("beginTime") String beginTime,
...@@ -22,7 +22,7 @@ public interface LogMapperEx { ...@@ -22,7 +22,7 @@ public interface LogMapperEx {
Long countsByLog( Long countsByLog(
@Param("operation") String operation, @Param("operation") String operation,
@Param("userId") Integer userId, @Param("userInfo") String userInfo,
@Param("clientIp") String clientIp, @Param("clientIp") String clientIp,
@Param("status") Integer status, @Param("status") Integer status,
@Param("beginTime") String beginTime, @Param("beginTime") String beginTime,
......
...@@ -4,10 +4,20 @@ import com.jsh.erp.datasource.entities.Log; ...@@ -4,10 +4,20 @@ import com.jsh.erp.datasource.entities.Log;
public class LogVo4List extends Log { public class LogVo4List extends Log {
private String loginName;
private String userName; private String userName;
private String createTimeStr; private String createTimeStr;
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getUserName() { public String getUserName() {
return userName; return userName;
} }
......
...@@ -32,13 +32,13 @@ public class LogComponent implements ICommonQuery { ...@@ -32,13 +32,13 @@ public class LogComponent implements ICommonQuery {
private List<?> getLogList(Map<String, String> map)throws Exception { private List<?> getLogList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String operation = StringUtil.getInfo(search, "operation"); String operation = StringUtil.getInfo(search, "operation");
Integer userId = StringUtil.parseInteger(StringUtil.getInfo(search, "userId")); String userInfo = StringUtil.getInfo(search, "userInfo");
String clientIp = StringUtil.getInfo(search, "clientIp"); String clientIp = StringUtil.getInfo(search, "clientIp");
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status")); Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
String beginTime = StringUtil.getInfo(search, "beginTime"); String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime"); String endTime = StringUtil.getInfo(search, "endTime");
String content = StringUtil.getInfo(search, "content"); String content = StringUtil.getInfo(search, "content");
return logService.select(operation, userId, clientIp, status, beginTime, endTime, content, return logService.select(operation, userInfo, clientIp, status, beginTime, endTime, content,
QueryUtils.offset(map), QueryUtils.rows(map)); QueryUtils.offset(map), QueryUtils.rows(map));
} }
...@@ -46,13 +46,13 @@ public class LogComponent implements ICommonQuery { ...@@ -46,13 +46,13 @@ public class LogComponent implements ICommonQuery {
public Long counts(Map<String, String> map)throws Exception { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String operation = StringUtil.getInfo(search, "operation"); String operation = StringUtil.getInfo(search, "operation");
Integer userId = StringUtil.parseInteger(StringUtil.getInfo(search, "userId")); String userInfo = StringUtil.getInfo(search, "userInfo");
String clientIp = StringUtil.getInfo(search, "clientIp"); String clientIp = StringUtil.getInfo(search, "clientIp");
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status")); Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
String beginTime = StringUtil.getInfo(search, "beginTime"); String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime"); String endTime = StringUtil.getInfo(search, "endTime");
String content = StringUtil.getInfo(search, "content"); String content = StringUtil.getInfo(search, "content");
return logService.countLog(operation, userId, clientIp, status, beginTime, endTime, content); return logService.countLog(operation, userInfo, clientIp, status, beginTime, endTime, content);
} }
@Override @Override
......
...@@ -63,13 +63,13 @@ public class LogService { ...@@ -63,13 +63,13 @@ public class LogService {
return list; return list;
} }
public List<LogVo4List> select(String operation, Integer userId, String clientIp, Integer status, String beginTime, String endTime, public List<LogVo4List> select(String operation, String userInfo, String clientIp, Integer status, String beginTime, String endTime,
String content, int offset, int rows)throws Exception { String content, int offset, int rows)throws Exception {
List<LogVo4List> list=null; List<LogVo4List> list=null;
try{ try{
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME); beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME); endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
list=logMapperEx.selectByConditionLog(operation, userId, clientIp, status, beginTime, endTime, list=logMapperEx.selectByConditionLog(operation, userInfo, clientIp, status, beginTime, endTime,
content, offset, rows); content, offset, rows);
if (null != list) { if (null != list) {
for (LogVo4List log : list) { for (LogVo4List log : list) {
...@@ -82,13 +82,13 @@ public class LogService { ...@@ -82,13 +82,13 @@ public class LogService {
return list; return list;
} }
public Long countLog(String operation, Integer userId, String clientIp, Integer status, String beginTime, String endTime, public Long countLog(String operation, String userInfo, String clientIp, Integer status, String beginTime, String endTime,
String content)throws Exception { String content)throws Exception {
Long result=null; Long result=null;
try{ try{
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME); beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME); endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
result=logMapperEx.countsByLog(operation, userId, clientIp, status, beginTime, endTime, content); result=logMapperEx.countsByLog(operation, userInfo, clientIp, status, beginTime, endTime, content);
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
<mapper namespace="com.jsh.erp.datasource.mappers.LogMapperEx"> <mapper namespace="com.jsh.erp.datasource.mappers.LogMapperEx">
<resultMap extends="com.jsh.erp.datasource.mappers.LogMapper.BaseResultMap" id="ResultExMap" type="com.jsh.erp.datasource.vo.LogVo4List"> <resultMap extends="com.jsh.erp.datasource.mappers.LogMapper.BaseResultMap" id="ResultExMap" type="com.jsh.erp.datasource.vo.LogVo4List">
<result column="userName" jdbcType="VARCHAR" property="userName" /> <result column="userName" jdbcType="VARCHAR" property="userName" />
<result column="login_name" jdbcType="VARCHAR" property="loginName" />
</resultMap> </resultMap>
<select id="selectByConditionLog" parameterType="com.jsh.erp.datasource.entities.LogExample" resultMap="ResultExMap"> <select id="selectByConditionLog" parameterType="com.jsh.erp.datasource.entities.LogExample" resultMap="ResultExMap">
select l.*,u.username userName select l.*,u.login_name,u.username userName
FROM jsh_log l FROM jsh_log l
left join jsh_user u on l.user_id = u.id and ifnull(u.Status,'0') !='1' left join jsh_user u on l.user_id = u.id and ifnull(u.Status,'0') !='1'
where 1=1 where 1=1
...@@ -14,8 +15,9 @@ ...@@ -14,8 +15,9 @@
<bind name="bindOperation" value="'%'+operation+'%'"/> <bind name="bindOperation" value="'%'+operation+'%'"/>
and l.operation like #{bindOperation} and l.operation like #{bindOperation}
</if> </if>
<if test="userId != null"> <if test="userInfo != null">
and l.user_id=#{userId} <bind name="bindUserInfo" value="'%'+userInfo+'%'"/>
and (u.username like #{bindUserInfo} or u.login_name like #{bindUserInfo})
</if> </if>
<if test="clientIp != null"> <if test="clientIp != null">
<bind name="bindClientIp" value="'%'+clientIp+'%'"/> <bind name="bindClientIp" value="'%'+clientIp+'%'"/>
...@@ -49,8 +51,9 @@ ...@@ -49,8 +51,9 @@
<bind name="bindOperation" value="'%'+operation+'%'"/> <bind name="bindOperation" value="'%'+operation+'%'"/>
and l.operation like #{bindOperation} and l.operation like #{bindOperation}
</if> </if>
<if test="userId != null"> <if test="userInfo != null">
and l.user_id=#{userId} <bind name="bindUserInfo" value="'%'+userInfo+'%'"/>
and (u.username like #{bindUserInfo} or u.login_name like #{bindUserInfo})
</if> </if>
<if test="clientIp != null"> <if test="clientIp != null">
<bind name="bindClientIp" value="'%'+clientIp+'%'"/> <bind name="bindClientIp" value="'%'+clientIp+'%'"/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment