Finish SysLogController
This commit is contained in:
@@ -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
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -15,5 +16,13 @@ import org.apache.ibatis.annotations.Mapper
|
||||
*/
|
||||
@Mapper
|
||||
interface SysLogMapper : BaseMapper<SysLog> {
|
||||
fun selectPage(page: IPage<SysLog>, logType: List<String>?, requestMethod: List<String>?): IPage<SysLog>
|
||||
fun selectPage(
|
||||
page: IPage<SysLog>,
|
||||
logType: List<String>?,
|
||||
requestMethod: List<String>?,
|
||||
searchRequestUrl: String?,
|
||||
searchRegex: Boolean,
|
||||
searchStartTime: LocalDateTime?,
|
||||
searchEndTime: LocalDateTime?
|
||||
): IPage<SysLog>
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
@@ -39,6 +39,14 @@ class SysLogServiceImpl : ServiceImpl<SysLogMapper, SysLog>(), 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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,22 @@
|
||||
separator="," close=")" nullable="true">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="searchRequestUrl != null">
|
||||
<choose>
|
||||
<when test="searchRegex == true">
|
||||
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}
|
||||
</when>
|
||||
<otherwise>
|
||||
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}, '%')
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="searchStartTime != null and searchEndTime != null">
|
||||
and t_sys_log.start_time between #{searchStartTime} and #{searchEndTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user