|
@@ -2,9 +2,9 @@
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<!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">
|
|
<mapper namespace="com.pj.project4sp.apilog.SpApilogMapper">
|
|
|
|
|
|
-
|
|
|
|
- <!-- 保存入库 -->
|
|
|
|
- <insert id="saveObj">
|
|
|
|
|
|
+
|
|
|
|
+ <!-- 保存入库 -->
|
|
|
|
+ <insert id="saveObj">
|
|
insert into
|
|
insert into
|
|
sp_apilog (
|
|
sp_apilog (
|
|
id, req_ip, req_api, req_parame, req_type, req_token, req_header, user_id, admin_id, start_time,
|
|
id, req_ip, req_api, req_parame, req_type, req_token, req_header, user_id, admin_id, start_time,
|
|
@@ -13,29 +13,32 @@
|
|
#{id}, #{reqIp}, #{reqApi}, #{reqParame}, #{reqType}, #{reqToken}, #{reqHeader}, #{userId}, #{adminId}, #{startTime},
|
|
#{id}, #{reqIp}, #{reqApi}, #{reqParame}, #{reqType}, #{reqToken}, #{reqHeader}, #{userId}, #{adminId}, #{startTime},
|
|
#{resCode}, #{resMsg}, #{resString}, #{endTime}, #{costTime})
|
|
#{resCode}, #{resMsg}, #{resString}, #{endTime}, #{costTime})
|
|
</insert>
|
|
</insert>
|
|
-
|
|
|
|
-
|
|
|
|
- <!-- 增 -->
|
|
|
|
- <insert id="add">
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <!-- 增 -->
|
|
|
|
+ <insert id="add">
|
|
insert into
|
|
insert into
|
|
sp_apilog (id, req_ip, req_api, req_parame, req_token, user_id, admin_id, start_time)
|
|
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))
|
|
values (#{id}, #{reqIp}, #{reqApi}, #{reqParame}, #{reqToken}, #{userId}, #{adminId}, now(3))
|
|
</insert>
|
|
</insert>
|
|
|
|
|
|
- <!-- 删 -->
|
|
|
|
- <delete id="delete">
|
|
|
|
|
|
+ <!-- 删 -->
|
|
|
|
+ <delete id="delete">
|
|
delete from sp_apilog
|
|
delete from sp_apilog
|
|
where id = #{id}
|
|
where id = #{id}
|
|
</delete>
|
|
</delete>
|
|
|
|
|
|
- <!-- 删 -->
|
|
|
|
- <delete id="deleteByStartEnd">
|
|
|
|
|
|
+ <!-- 删 -->
|
|
|
|
+ <delete id="deleteByStartEnd">
|
|
delete from sp_apilog
|
|
delete from sp_apilog
|
|
where start_time BETWEEN #{startTime} AND #{endTime}
|
|
where start_time BETWEEN #{startTime} AND #{endTime}
|
|
</delete>
|
|
</delete>
|
|
-
|
|
|
|
- <!-- 改 -->
|
|
|
|
- <update id="update">
|
|
|
|
|
|
+ <delete id="cleanHistoryLog">
|
|
|
|
+ delete from sp_apilog where date_format(end_time,'%Y-%m-%d') <=#{cleanDayBefore}
|
|
|
|
+ </delete>
|
|
|
|
+
|
|
|
|
+ <!-- 改 -->
|
|
|
|
+ <update id="update">
|
|
update sp_apilog set
|
|
update sp_apilog set
|
|
res_code = #{resCode},
|
|
res_code = #{resCode},
|
|
res_msg = #{resMsg},
|
|
res_msg = #{resMsg},
|
|
@@ -44,71 +47,70 @@
|
|
cost_time = #{costTime}
|
|
cost_time = #{costTime}
|
|
where id = #{id}
|
|
where id = #{id}
|
|
</update>
|
|
</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">
|
|
|
|
|
|
+
|
|
|
|
+ <!-- ================================== 查询相关 ================================== -->
|
|
|
|
+
|
|
|
|
+ <!-- 通用映射 -->
|
|
|
|
+ <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
|
|
select * from sp_apilog
|
|
</sql>
|
|
</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 == 0'>id desc</when>
|
|
|
|
- <when test='sortType == 1'>start_time desc, id desc</when>
|
|
|
|
- <when test='sortType == 2'>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>
|
|
|
|
|
|
+
|
|
|
|
+ <!-- 查询,根据条件(参数为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 == 0'>id desc</when>
|
|
|
|
+ <when test='sortType == 1'>start_time desc, id desc</when>
|
|
|
|
+ <when test='sortType == 2'>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>
|
|
</mapper>
|