| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?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.fs.comm.mapper.CommGatewayApiLogMapper">
- <resultMap id="CommGatewayApiLogResult" type="com.fs.comm.domain.CommGatewayApiLog">
- <result property="logId" column="log_id"/>
- <result property="tenantId" column="tenant_id"/>
- <result property="companyId" column="company_id"/>
- <result property="companyUserId" column="company_user_id"/>
- <result property="callerAccount" column="caller_account"/>
- <result property="apiType" column="api_type"/>
- <result property="apiPath" column="api_path"/>
- <result property="requestBody" column="request_body"/>
- <result property="responseBody" column="response_body"/>
- <result property="resultCode" column="result_code"/>
- <result property="resultMsg" column="result_msg"/>
- <result property="success" column="success"/>
- <result property="limitHit" column="limit_hit"/>
- <result property="limitReason" column="limit_reason"/>
- <result property="calleePhone" column="callee_phone"/>
- <result property="callerPhone" column="caller_phone"/>
- <result property="gatewayId" column="gateway_id"/>
- <result property="billingAmount" column="billing_amount"/>
- <result property="costPrice" column="cost_price"/>
- <result property="calcPrice" column="calc_price"/>
- <result property="billingQuantity" column="billing_quantity"/>
- <result property="billingUnit" column="billing_unit"/>
- <result property="clientIp" column="client_ip"/>
- <result property="authScope" column="auth_scope"/>
- <result property="durationMs" column="duration_ms"/>
- <result property="createTime" column="create_time"/>
- <result property="companyName" column="company_name"/>
- </resultMap>
- <sql id="selectCommGatewayApiLogVo">
- select l.log_id, l.tenant_id, l.company_id, l.company_user_id, l.caller_account,
- l.api_type, l.api_path, l.request_body, l.response_body, l.result_code, l.result_msg,
- l.success, l.limit_hit, l.limit_reason, l.callee_phone, l.caller_phone, l.gateway_id,
- l.billing_amount, l.cost_price, l.calc_price, l.billing_quantity, l.billing_unit,
- l.client_ip, l.auth_scope, l.duration_ms, l.create_time,
- c.company_name
- from comm_gateway_api_log l
- left join company c on c.company_id = l.company_id
- </sql>
- <select id="selectCommGatewayApiLogList" resultMap="CommGatewayApiLogResult">
- <include refid="selectCommGatewayApiLogVo"/>
- <where>
- <if test="tenantId != null">and l.tenant_id = #{tenantId}</if>
- <if test="companyId != null">and l.company_id = #{companyId}</if>
- <if test="apiType != null and apiType != ''">and l.api_type = #{apiType}</if>
- <if test="success != null">and l.success = #{success}</if>
- <if test="limitHit != null">and l.limit_hit = #{limitHit}</if>
- <if test="calleePhone != null and calleePhone != ''">and l.callee_phone like concat('%', #{calleePhone}, '%')</if>
- <if test="callerAccount != null and callerAccount != ''">and l.caller_account like concat('%', #{callerAccount}, '%')</if>
- <if test="params.beginTime != null and params.beginTime != ''">
- and l.create_time >= #{params.beginTime}
- </if>
- <if test="params.endTime != null and params.endTime != ''">
- and l.create_time <= #{params.endTime}
- </if>
- </where>
- order by l.log_id desc
- </select>
- <select id="selectCommGatewayApiLogById" resultMap="CommGatewayApiLogResult">
- <include refid="selectCommGatewayApiLogVo"/>
- where l.log_id = #{logId}
- </select>
- <insert id="insertCommGatewayApiLog" useGeneratedKeys="true" keyProperty="logId">
- insert into comm_gateway_api_log
- (tenant_id, company_id, company_user_id, caller_account, api_type, api_path,
- request_body, response_body, result_code, result_msg, success, limit_hit, limit_reason,
- callee_phone, caller_phone, gateway_id, billing_amount, cost_price, calc_price, billing_quantity,
- billing_unit, client_ip, auth_scope, duration_ms, create_time)
- values
- (#{tenantId}, #{companyId}, #{companyUserId}, #{callerAccount}, #{apiType}, #{apiPath},
- #{requestBody}, #{responseBody}, #{resultCode}, #{resultMsg}, #{success}, #{limitHit}, #{limitReason},
- #{calleePhone}, #{callerPhone}, #{gatewayId}, #{billingAmount}, #{costPrice}, #{calcPrice}, #{billingQuantity},
- #{billingUnit}, #{clientIp}, #{authScope}, #{durationMs}, #{createTime})
- </insert>
- <select id="countByCalleePhone" resultType="java.lang.Integer">
- select count(1) from comm_gateway_api_log
- where company_id = #{companyId}
- and callee_phone = #{calleePhone}
- and limit_hit = 0
- <if test="type != null and type == 1">and timestampdiff(MINUTE, create_time, now()) < 1</if>
- <if test="type != null and type == 2">and timestampdiff(HOUR, create_time, now()) < 1</if>
- <if test="type != null and type == 3">and timestampdiff(DAY, create_time, now()) < 1</if>
- <if test="type != null and type == 4">and timestampdiff(WEEK, create_time, now()) < 1</if>
- <if test="type != null and type == 5">and timestampdiff(MONTH, create_time, now()) < 1</if>
- </select>
- <select id="countByCallerPhone" resultType="java.lang.Integer">
- select count(1) from comm_gateway_api_log
- where company_id = #{companyId}
- and caller_phone = #{callerPhone}
- and limit_hit = 0
- <if test="type != null and type == 1">and timestampdiff(MINUTE, create_time, now()) < 1</if>
- <if test="type != null and type == 2">and timestampdiff(HOUR, create_time, now()) < 1</if>
- <if test="type != null and type == 3">and timestampdiff(DAY, create_time, now()) < 1</if>
- <if test="type != null and type == 4">and timestampdiff(WEEK, create_time, now()) < 1</if>
- <if test="type != null and type == 5">and timestampdiff(MONTH, create_time, now()) < 1</if>
- </select>
- <select id="countByCompanyCall" resultType="java.lang.Integer">
- select count(1) from comm_gateway_api_log
- where company_id = #{companyId}
- and api_type = #{apiType}
- and limit_hit = 0
- <if test="type != null and type == 1">and timestampdiff(MINUTE, create_time, now()) < 1</if>
- <if test="type != null and type == 2">and timestampdiff(HOUR, create_time, now()) < 1</if>
- <if test="type != null and type == 3">and timestampdiff(DAY, create_time, now()) < 1</if>
- <if test="type != null and type == 4">and timestampdiff(WEEK, create_time, now()) < 1</if>
- <if test="type != null and type == 5">and timestampdiff(MONTH, create_time, now()) < 1</if>
- </select>
- </mapper>
|