ApiLogMapper.xml 2.74 KB
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huaheng.pc.monitor.apilog.mapper.ApiLogMapper">

    <resultMap type="com.huaheng.pc.monitor.apilog.domain.ApiLog" id="apiLogResult">
        <result property="id" column="id"/>
        <result property="apiName" column="apiName"/>
        <result property="apiMethod" column="apiMethod"/>
        <result property="ip" column="ip"/>
        <result property="requestFrom" column="requestFrom"/>
        <result property="responseBy" column="responseBy"/>
        <result property="url" column="url"/>
        <result property="requestTime" column="requestTime"/>
        <result property="responseTime" column="responseTime"/>
        <result property="requestHeader" column="requestHeader"/>
        <result property="requestBody" column="requestBody"/>
        <result property="responseHeader" column="responseHeader"/>
        <result property="responseBody" column="responseBody"/>
        <result property="duration" column="duration"/>
        <result property="httpCode" column="httpCode"/>
        <result property="retCode" column="retCode"/>
        <result property="exception" column="exception"/>
    </resultMap>
    <sql id="selectapiLogVo">
        select id,
               apiName,
               apiMethod,
               ip,
               requestFrom,
               responseBy,
               url,
               requestTime,
               responseTime,
               requestHeader,
               requestBody,
               responseHeader,
               responseBody,
               duration,
               httpCode,
               retCode,
               `exception`
        from api_log
    </sql>
    <select id="getRequestFromList" resultType="java.lang.String">
        select distinct(requestFrom)
        from api_log
        order by requestFrom asc
    </select>
    <select id="getResponseByList" resultType="java.lang.String">
        select distinct(responseBy)
        from api_log
        order by responseBy asc
    </select>
    <select id="getHttpCodeList" resultType="java.lang.String">
        select distinct(httpCode)
        from api_log
        order by httpCode asc
    </select>
    <select id="getApiNameList" resultType="java.lang.String">
        select distinct(apiName)
        from api_log
        order by apiName asc
    </select>
    <select id="getRetCodeList" resultType="java.lang.String">
        select distinct(retCode)
        from api_log
        order by retCode asc
    </select>
    
    <delete id="truncateTable">
        DELETE
        FROM api_log
        WHERE requestTime &lt; DATE_SUB(CURDATE(), INTERVAL 15 DAY)
    </delete>
</mapper>