diff --git a/src/main/kotlin/top/fatweb/api/mapper/system/SysLogMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/system/SysLogMapper.kt index 5b2f979..d66e2d8 100644 --- a/src/main/kotlin/top/fatweb/api/mapper/system/SysLogMapper.kt +++ b/src/main/kotlin/top/fatweb/api/mapper/system/SysLogMapper.kt @@ -1,9 +1,10 @@ package top.fatweb.api.mapper.system -import top.fatweb.api.entity.system.SysLog import com.baomidou.mybatisplus.core.mapper.BaseMapper import com.baomidou.mybatisplus.core.metadata.IPage import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.system.SysLog +import java.time.LocalDateTime /** *

@@ -15,5 +16,13 @@ import org.apache.ibatis.annotations.Mapper */ @Mapper interface SysLogMapper : BaseMapper { - fun selectPage(page: IPage, logType: List?, requestMethod: List?): IPage + fun selectPage( + page: IPage, + logType: List?, + requestMethod: List?, + searchRequestUrl: String?, + searchRegex: Boolean, + searchStartTime: LocalDateTime?, + searchEndTime: LocalDateTime? + ): IPage } diff --git a/src/main/kotlin/top/fatweb/api/param/system/SysLogGetParam.kt b/src/main/kotlin/top/fatweb/api/param/system/SysLogGetParam.kt index c0fb4c2..929f2ae 100644 --- a/src/main/kotlin/top/fatweb/api/param/system/SysLogGetParam.kt +++ b/src/main/kotlin/top/fatweb/api/param/system/SysLogGetParam.kt @@ -1,7 +1,9 @@ package top.fatweb.api.param.system import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.format.annotation.DateTimeFormat import top.fatweb.api.param.PageParam +import java.time.LocalDateTime @Schema(description = "获取系统日志请求参数") data class SysLogGetParam( @@ -19,5 +21,19 @@ data class SysLogGetParam( example = "GET,POST", allowableValues = ["GET", "POST", "PUT", "PATCH", "DELETE", "DELETE", "OPTIONS"] ) - val requestMethod: String? = null + val requestMethod: String? = null, + + @Schema(description = "查询请求 Url") + val searchRequestUrl: String? = null, + + @Schema(description = "查询使用正则表达式") + val searchRegex: Boolean = false, + + @Schema(description = "查询开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + val searchStartTime: LocalDateTime? = null, + + @Schema(description = "查询结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + val searchEndTime: LocalDateTime? = null ) : PageParam() \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/api/service/system/impl/SysLogServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/system/impl/SysLogServiceImpl.kt index cc1c891..403b6a5 100644 --- a/src/main/kotlin/top/fatweb/api/service/system/impl/SysLogServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/system/impl/SysLogServiceImpl.kt @@ -39,6 +39,14 @@ class SysLogServiceImpl : ServiceImpl(), ISysLogService { ) } - return baseMapper.selectPage(sysLogPage, sysLogGetParam?.logType?.split(","), sysLogGetParam?.requestMethod?.split(",")) + return baseMapper.selectPage( + sysLogPage, + sysLogGetParam?.logType?.split(","), + sysLogGetParam?.requestMethod?.split(","), + sysLogGetParam?.searchRequestUrl, + sysLogGetParam?.searchRegex ?: false, + sysLogGetParam?.searchStartTime, + sysLogGetParam?.searchEndTime + ) } } diff --git a/src/main/resources/mapper/system/SysLogMapper.xml b/src/main/resources/mapper/system/SysLogMapper.xml index 70c9c22..5bde6d8 100644 --- a/src/main/resources/mapper/system/SysLogMapper.xml +++ b/src/main/resources/mapper/system/SysLogMapper.xml @@ -29,6 +29,22 @@ separator="," close=")" nullable="true"> #{item} + + + + and concat_ws('?', concat(t_sys_log.request_server_address, t_sys_log.request_uri), + if(length(t_sys_log.request_params) != 0, t_sys_log.request_params, null)) regexp #{searchRequestUrl} + + + and concat_ws('?', concat(t_sys_log.request_server_address, t_sys_log.request_uri), + if(length(t_sys_log.request_params) != 0, t_sys_log.request_params, null)) like concat('%', + #{searchRequestUrl}, '%') + + + + + and t_sys_log.start_time between #{searchStartTime} and #{searchEndTime} +