ApiMetricsMapper.xml 2.47 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.diligrp.xtrade.core.repository.dao.ApiMetricsDao">

    <resultMap type="com.diligrp.xtrade.core.repository.entity.ApiMetricsInfoEntity" id="ApiMetricsMap">
        <result property="id" column="id"/>
        <result property="code" column="code"/>
        <result property="message" column="message"/>
        <result property="serviceId" column="service_id"/>
        <result property="url" column="url"/>
        <result property="clientIp" column="client_ip"/>
        <result property="requestHeader" column="request_header"/>
        <result property="requestBody" column="request_body"/>
        <result property="stackTrace" column="stack_trace"/>
        <result property="executeTime" column="execute_time"/>
        <result property="createdTime" column="created_time"/>
        <result property="modifiedTime" column="modified_time"/>
    </resultMap>
    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO t_api_metrics(code,
                                  message,
                                  service_id,
                                  url,
                                  client_ip,
                                  request_header,
                                  request_body,
                                  stack_trace,
                                  execute_time,
                                  created_time,
                                  modified_time)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.code},
            #{item.message},
            #{item.serviceId},
            #{item.url},
            #{item.clientIp},
            #{item.requestHeader},
            #{item.requestBody},
            #{item.stackTrace},
            #{item.executeTime},
            #{item.createdTime},
             now()
            )
        </foreach>
    </insert>

    <!--查询单个-->
    <select id="queryById" resultMap="ApiMetricsMap">
        select id,
               code,
               message,
               service_id,
               url,
               request_header,
               request_body,
               stack_trace,
               execute_time,
               created_time,
               modified_time
        from xtrade_gateway.t_api_metrics
        where id = #{id}
    </select>


</mapper>