常熟吴彦祖 1 month ago
parent
commit
cbdca27eb3
  1. 21
      src/main/java/com/gaotao/modules/api/dao/SysErrorLogMapper.java
  2. 21
      src/main/java/com/gaotao/modules/api/service/impl/SysErrorLogServiceImpl.java
  3. 87
      src/main/resources/mapper/api/SysErrorLogMapper.xml

21
src/main/java/com/gaotao/modules/api/dao/SysErrorLogMapper.java

@ -1,13 +1,13 @@
package com.gaotao.modules.api.dao; package com.gaotao.modules.api.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gaotao.modules.api.entity.SysErrorLog; import com.gaotao.modules.api.entity.SysErrorLog;
import com.gaotao.modules.api.entity.SysErrorLogData; import com.gaotao.modules.api.entity.SysErrorLogData;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 系统错误日志Mapper * 系统错误日志Mapper
* *
@ -18,16 +18,11 @@ import java.util.List;
public interface SysErrorLogMapper extends BaseMapper<SysErrorLog> { public interface SysErrorLogMapper extends BaseMapper<SysErrorLog> {
/** /**
* 分页查询错误日志
* @param data 查询条件
* @return 错误日志列表
*/
List<SysErrorLog> queryList(@Param("data") SysErrorLogData data);
/**
* 查询总数
* @param data 查询条件
* @return 总数
* @Description 分页查询错误日志列表 - rqrq
* @param page 分页对象
* @param params 查询条件
* @return IPage<SysErrorLogData>
* @author rqrq
*/ */
int queryTotal(@Param("data") SysErrorLogData data);
IPage<SysErrorLogData> queryList(Page<SysErrorLogData> page, @Param("params") SysErrorLogData params);
} }

21
src/main/java/com/gaotao/modules/api/service/impl/SysErrorLogServiceImpl.java

@ -1,5 +1,7 @@
package com.gaotao.modules.api.service.impl; package com.gaotao.modules.api.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaotao.common.utils.PageUtils; import com.gaotao.common.utils.PageUtils;
import com.gaotao.modules.api.dao.SysErrorLogMapper; import com.gaotao.modules.api.dao.SysErrorLogMapper;
@ -8,8 +10,6 @@ import com.gaotao.modules.api.entity.SysErrorLogData;
import com.gaotao.modules.api.service.SysErrorLogService; import com.gaotao.modules.api.service.SysErrorLogService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* 系统错误日志Service实现类 * 系统错误日志Service实现类
* *
@ -22,19 +22,8 @@ public class SysErrorLogServiceImpl extends ServiceImpl<SysErrorLogMapper, SysEr
@Override @Override
public PageUtils queryPage(SysErrorLogData data) { public PageUtils queryPage(SysErrorLogData data) {
// 计算分页偏移量 - rqrq
if (data.getPage() != null && data.getLimit() != null) {
data.setOffset((data.getPage() - 1) * data.getLimit());
} else {
data.setPage(1);
data.setLimit(10);
data.setOffset(0);
}
// 查询数据 - rqrq
List<SysErrorLog> list = baseMapper.queryList(data);
int total = baseMapper.queryTotal(data);
return new PageUtils(list, total, data.getLimit(), data.getPage());
IPage<SysErrorLogData> page = baseMapper.queryList(
new Page<SysErrorLogData>(data.getPage(), data.getLimit()), data);
return new PageUtils(page);
} }
} }

87
src/main/resources/mapper/api/SysErrorLogMapper.xml

@ -4,66 +4,63 @@
<!-- rqrq - 系统错误日志Mapper XML --> <!-- rqrq - 系统错误日志Mapper XML -->
<mapper namespace="com.gaotao.modules.api.dao.SysErrorLogMapper"> <mapper namespace="com.gaotao.modules.api.dao.SysErrorLogMapper">
<!-- 通用查询条件 - rqrq -->
<sql id="queryCondition">
<!-- rqrq - 分页查询错误日志列表 -->
<select id="queryList" resultType="SysErrorLogData">
SELECT
id,
site,
module_name AS moduleName,
function_name AS functionName,
business_key AS businessKey,
is_interface AS isInterface,
interface_type AS interfaceType,
interface_name AS interfaceName,
request_data AS requestData,
method_name AS methodName,
error_message AS errorMessage,
error_detail AS errorDetail,
username,
created_time AS createdTime
FROM sys_error_log WITH (NOLOCK)
<where> <where>
<if test="data.site != null and data.site != ''">
AND site = #{data.site}
<if test="params.site != null and params.site != ''">
AND site = #{params.site}
</if> </if>
<if test="data.moduleName != null and data.moduleName != ''">
AND module_name = #{data.moduleName}
<if test="params.moduleName != null and params.moduleName != ''">
AND module_name = #{params.moduleName}
</if> </if>
<if test="data.functionName != null and data.functionName != ''">
AND function_name = #{data.functionName}
<if test="params.functionName != null and params.functionName != ''">
AND function_name = #{params.functionName}
</if> </if>
<if test="data.businessKey != null and data.businessKey != ''">
AND business_key LIKE '%' + #{data.businessKey} + '%'
<if test="params.businessKey != null and params.businessKey != ''">
AND business_key LIKE '%' + #{params.businessKey} + '%'
</if> </if>
<if test="data.isInterface != null and data.isInterface != ''">
AND is_interface = #{data.isInterface}
<if test="params.isInterface != null and params.isInterface != ''">
AND is_interface = #{params.isInterface}
</if> </if>
<if test="data.interfaceType != null and data.interfaceType != ''">
AND interface_type = #{data.interfaceType}
<if test="params.interfaceType != null and params.interfaceType != ''">
AND interface_type = #{params.interfaceType}
</if> </if>
<if test="data.interfaceName != null and data.interfaceName != ''">
AND interface_name LIKE '%' + #{data.interfaceName} + '%'
<if test="params.interfaceName != null and params.interfaceName != ''">
AND interface_name LIKE '%' + #{params.interfaceName} + '%'
</if> </if>
<if test="data.username != null and data.username != ''">
AND username LIKE '%' + #{data.username} + '%'
<if test="params.username != null and params.username != ''">
AND username LIKE '%' + #{params.username} + '%'
</if> </if>
<if test="data.searchErrorMessage != null and data.searchErrorMessage != ''">
AND error_message LIKE '%' + #{data.searchErrorMessage} + '%'
<if test="params.searchErrorMessage != null and params.searchErrorMessage != ''">
AND error_message LIKE '%' + #{params.searchErrorMessage} + '%'
</if> </if>
<if test="data.searchErrorDetail != null and data.searchErrorDetail != ''">
AND error_detail LIKE '%' + #{data.searchErrorDetail} + '%'
<if test="params.searchErrorDetail != null and params.searchErrorDetail != ''">
AND error_detail LIKE '%' + #{params.searchErrorDetail} + '%'
</if> </if>
<if test="data.startTime != null and data.startTime != ''">
AND created_time &gt;= #{data.startTime}
<if test="params.startTime != null and params.startTime != ''">
AND created_time &gt;= #{params.startTime}
</if> </if>
<if test="data.endTime != null and data.endTime != ''">
AND created_time &lt;= #{data.endTime}
<if test="params.endTime != null and params.endTime != ''">
AND created_time &lt;= #{params.endTime}
</if> </if>
</where> </where>
</sql>
<!-- 分页查询错误日志 - rqrq -->
<select id="queryList" resultType="SysErrorLog">
SELECT
id, site, module_name, function_name, business_key,
is_interface, interface_type, interface_name, request_data,
method_name, error_message, error_detail,
username, created_time
FROM sys_error_log
<include refid="queryCondition"/>
ORDER BY created_time DESC ORDER BY created_time DESC
OFFSET #{data.offset} ROWS FETCH NEXT #{data.limit} ROWS ONLY
</select>
<!-- 查询总数 - rqrq -->
<select id="queryTotal" resultType="int">
SELECT COUNT(1)
FROM sys_error_log
<include refid="queryCondition"/>
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save