123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?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.pj.project4sp.apilog.SpApilogMapper">
-
- <!-- 保存入库 -->
- <insert id="saveObj">
- insert into
- sp_apilog (
- id, req_ip, req_api, req_parame, req_type, req_token, req_header, user_id, admin_id, start_time,
- res_code, res_msg, res_string, end_time, cost_time)
- values (
- #{id}, #{reqIp}, #{reqApi}, #{reqParame}, #{reqType}, #{reqToken}, #{reqHeader}, #{userId}, #{adminId}, #{startTime},
- #{resCode}, #{resMsg}, #{resString}, #{endTime}, #{costTime})
- </insert>
-
-
- <!-- 增 -->
- <insert id="add">
- insert into
- sp_apilog (id, req_ip, req_api, req_parame, req_token, user_id, admin_id, start_time)
- values (#{id}, #{reqIp}, #{reqApi}, #{reqParame}, #{reqToken}, #{userId}, #{adminId}, now(3))
- </insert>
- <!-- 删 -->
- <delete id="delete">
- delete from sp_apilog
- where id = #{id}
- </delete>
- <!-- 删 -->
- <delete id="deleteByStartEnd">
- delete from sp_apilog
- where start_time BETWEEN #{startTime} AND #{endTime}
- </delete>
-
- <!-- 改 -->
- <update id="update">
- update sp_apilog set
- res_code = #{resCode},
- res_msg = #{resMsg},
- res_string = #{resString},
- end_time = now(3),
- cost_time = #{costTime}
- where id = #{id}
- </update>
-
- <!-- ================================== 查询相关 ================================== -->
-
- <!-- 通用映射 -->
- <resultMap id="model" type="com.pj.project4sp.apilog.SpApilog">
- <result property="id" column="id" />
- <result property="reqIp" column="req_ip" />
- <result property="reqApi" column="req_api" />
- <result property="reqParame" column="req_parame" />
- <result property="reqType" column="req_type" />
- <result property="reqToken" column="req_token" />
- <result property="reqHeader" column="req_header" />
- <result property="resCode" column="res_code" />
- <result property="resMsg" column="res_msg" />
- <result property="resString" column="res_string" />
- <result property="userId" column="user_id" />
- <result property="adminId" column="admin_id" />
- <result property="startTime" column="start_time" />
- <result property="endTime" column="end_time" />
- <result property="costTime" column="cost_time" />
- </resultMap>
-
- <!-- 公共查询sql片段 -->
- <sql id="select_sql">
- select * from sp_apilog
- </sql>
-
- <!-- 查询,根据条件(参数为null或0时默认忽略此条件) -->
- <select id="getList" resultMap="model" >
- <include refid="select_sql"></include>
- where 1 = 1
- <if test=' this.has("id") '>and id = #{id} </if>
- <if test=' this.has("reqToken") '>and req_token = #{reqToken} </if>
- <if test=' this.has("reqIp") '> and req_ip = #{reqIp} </if>
- <if test=' this.has("reqApi") '>and req_api = #{reqApi} </if>
- <if test=' this.has("resCode") '>and res_code = #{resCode} </if>
- <if test=' this.has("userId") '>and user_id = #{userId} </if>
- <if test=' this.has("adminId") '>and admin_id = #{adminId} </if>
- <if test=' this.has("sTime") '>and start_time >= #{sTime} </if>
- <if test=' this.has("eTime") '>and start_time <= #{eTime} </if>
- order by
- <choose>
- <when test='sortType == "id" '>id desc</when>
- <when test='sortType == "start_time" '>start_time desc, id desc</when>
- <when test='sortType == "cost_time" '>cost_time desc, id desc</when>
- <otherwise>id desc</otherwise>
- </choose>
- </select>
-
-
-
- <!-- 统计 -->
- <select id="staBy" resultType="somap">
- select sum(cost_time) as cost_time_count from sp_apilog
- where 1 = 1
- <if test=' this.has("id") '>and id = #{id} </if>
- <if test=' this.has("reqToken") '>and req_token = #{reqToken} </if>
- <if test=' this.has("reqIp") '> and req_ip = #{reqIp} </if>
- <if test=' this.has("reqApi") '>and req_api = #{reqApi} </if>
- <if test=' this.has("resCode") '>and res_code = #{resCode} </if>
- <if test=' this.has("userId") '>and user_id = #{userId} </if>
- <if test=' this.has("adminId") '>and admin_id = #{adminId} </if>
- <if test=' this.has("sTime") '>and start_time >= #{sTime} </if>
- <if test=' this.has("eTime") '>and start_time <= #{eTime} </if>
- </select>
- </mapper>
|