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

优化日志查询接口

parent 6c92337f
......@@ -11,7 +11,7 @@ public interface LogMapperEx {
List<LogVo4List> selectByConditionLog(
@Param("operation") String operation,
@Param("userId") Integer userId,
@Param("userInfo") String userInfo,
@Param("clientIp") String clientIp,
@Param("status") Integer status,
@Param("beginTime") String beginTime,
......@@ -22,7 +22,7 @@ public interface LogMapperEx {
Long countsByLog(
@Param("operation") String operation,
@Param("userId") Integer userId,
@Param("userInfo") String userInfo,
@Param("clientIp") String clientIp,
@Param("status") Integer status,
@Param("beginTime") String beginTime,
......
......@@ -4,10 +4,20 @@ import com.jsh.erp.datasource.entities.Log;
public class LogVo4List extends Log {
private String loginName;
private String userName;
private String createTimeStr;
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getUserName() {
return userName;
}
......
......@@ -32,13 +32,13 @@ public class LogComponent implements ICommonQuery {
private List<?> getLogList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
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");
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
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));
}
......@@ -46,13 +46,13 @@ public class LogComponent implements ICommonQuery {
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
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");
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
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
......
......@@ -63,13 +63,13 @@ public class LogService {
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 {
List<LogVo4List> list=null;
try{
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_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);
if (null != list) {
for (LogVo4List log : list) {
......@@ -82,13 +82,13 @@ public class LogService {
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 {
Long result=null;
try{
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_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){
JshException.readFail(logger, e);
}
......
......@@ -3,10 +3,11 @@
<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">
<result column="userName" jdbcType="VARCHAR" property="userName" />
<result column="login_name" jdbcType="VARCHAR" property="loginName" />
</resultMap>
<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
left join jsh_user u on l.user_id = u.id and ifnull(u.Status,'0') !='1'
where 1=1
......@@ -14,8 +15,9 @@
<bind name="bindOperation" value="'%'+operation+'%'"/>
and l.operation like #{bindOperation}
</if>
<if test="userId != null">
and l.user_id=#{userId}
<if test="userInfo != null">
<bind name="bindUserInfo" value="'%'+userInfo+'%'"/>
and (u.username like #{bindUserInfo} or u.login_name like #{bindUserInfo})
</if>
<if test="clientIp != null">
<bind name="bindClientIp" value="'%'+clientIp+'%'"/>
......@@ -49,8 +51,9 @@
<bind name="bindOperation" value="'%'+operation+'%'"/>
and l.operation like #{bindOperation}
</if>
<if test="userId != null">
and l.user_id=#{userId}
<if test="userInfo != null">
<bind name="bindUserInfo" value="'%'+userInfo+'%'"/>
and (u.username like #{bindUserInfo} or u.login_name like #{bindUserInfo})
</if>
<if test="clientIp != null">
<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