潘志宝
2024-12-25 8a6b19bf5c50ebb54e965645a9366f6cfea02351
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.infra.dal.mysql.logger;
H 2
3 import com.iailab.framework.common.pojo.PageResult;
4 import com.iailab.framework.mybatis.core.mapper.BaseMapperX;
5 import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
6 import com.iailab.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
7 import com.iailab.module.infra.dal.dataobject.logger.ApiErrorLogDO;
8 import org.apache.ibatis.annotations.Delete;
9 import org.apache.ibatis.annotations.Mapper;
10 import org.apache.ibatis.annotations.Param;
11
12 import java.time.LocalDateTime;
13
14 /**
15  * API 错误日志 Mapper
16  *
17  * @author iailab
18  */
19 @Mapper
20 public interface ApiErrorLogMapper extends BaseMapperX<ApiErrorLogDO> {
21
22     default PageResult<ApiErrorLogDO> selectPage(ApiErrorLogPageReqVO reqVO) {
23         return selectPage(reqVO, new LambdaQueryWrapperX<ApiErrorLogDO>()
24                 .eqIfPresent(ApiErrorLogDO::getUserId, reqVO.getUserId())
25                 .eqIfPresent(ApiErrorLogDO::getUserType, reqVO.getUserType())
26                 .eqIfPresent(ApiErrorLogDO::getApplicationName, reqVO.getApplicationName())
27                 .likeIfPresent(ApiErrorLogDO::getRequestUrl, reqVO.getRequestUrl())
28                 .betweenIfPresent(ApiErrorLogDO::getExceptionTime, reqVO.getExceptionTime())
29                 .eqIfPresent(ApiErrorLogDO::getProcessStatus, reqVO.getProcessStatus())
30                 .orderByDesc(ApiErrorLogDO::getId)
31         );
32     }
33
34     /**
35      * 物理删除指定时间之前的日志
36      *
37      * @param createTime 最大时间
38      * @param limit 删除条数,防止一次删除太多
39      * @return 删除条数
40      */
41     @Delete("DELETE FROM infra_api_error_log WHERE create_time < #{createTime} LIMIT #{limit}")
42     Integer deleteByCreateTimeLt(@Param("createTime") LocalDateTime createTime, @Param("limit")Integer limit);
43
44 }