|
@@ -0,0 +1,199 @@
|
|
|
|
|
+<?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.steerinfo.dil.logresult.mapper.LogResultMapper">
|
|
|
|
|
+ <resultMap id="BaseResultMap" type="com.steerinfo.dil.logresult.model.LogResult">
|
|
|
|
|
+ <id column="LOG_ID" jdbcType="DECIMAL" property="logId" />
|
|
|
|
|
+ <result column="LOG_CONTENT" jdbcType="VARCHAR" property="logContent" />
|
|
|
|
|
+ <result column="FOREIGN_KEY_ID" jdbcType="DECIMAL" property="foreignKeyId" />
|
|
|
|
|
+ <result column="FOREIGN_KEY_TYPE" jdbcType="VARCHAR" property="foreignKeyType" />
|
|
|
|
|
+ <result column="METHOD_NAME" jdbcType="VARCHAR" property="methodName" />
|
|
|
|
|
+ <result column="METHOD_DESCRIPTION" jdbcType="VARCHAR" property="methodDescription" />
|
|
|
|
|
+ <result column="EXE_COST" jdbcType="DECIMAL" property="exeCost" />
|
|
|
|
|
+ <result column="FILE_PATH" jdbcType="VARCHAR" property="filePath" />
|
|
|
|
|
+ <result column="INSERT_TIME" jdbcType="TIMESTAMP" property="insertTime" />
|
|
|
|
|
+ <result column="INSERT_USERNAME" jdbcType="VARCHAR" property="insertUsername" />
|
|
|
|
|
+ <result column="REMARK" jdbcType="VARCHAR" property="remark" />
|
|
|
|
|
+ <result column="DATAGRAM1" jdbcType="VARCHAR" property="datagram1" />
|
|
|
|
|
+ <result column="DATAGRAM2" jdbcType="VARCHAR" property="datagram2" />
|
|
|
|
|
+ <result column="DATAGRAM3" jdbcType="VARCHAR" property="datagram3" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS1" jdbcType="VARCHAR" property="alternateFields1" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS2" jdbcType="VARCHAR" property="alternateFields2" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS3" jdbcType="VARCHAR" property="alternateFields3" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS4" jdbcType="VARCHAR" property="alternateFields4" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS5" jdbcType="VARCHAR" property="alternateFields5" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS6" jdbcType="VARCHAR" property="alternateFields6" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS7" jdbcType="VARCHAR" property="alternateFields7" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS8" jdbcType="VARCHAR" property="alternateFields8" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS9" jdbcType="VARCHAR" property="alternateFields9" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS10" jdbcType="VARCHAR" property="alternateFields10" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS11" jdbcType="VARCHAR" property="alternateFields11" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS12" jdbcType="VARCHAR" property="alternateFields12" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS13" jdbcType="VARCHAR" property="alternateFields13" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS14" jdbcType="VARCHAR" property="alternateFields14" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS15" jdbcType="VARCHAR" property="alternateFields15" />
|
|
|
|
|
+ <result column="ALTERNATE_FIELDS16" jdbcType="VARCHAR" property="alternateFields16" />
|
|
|
|
|
+ </resultMap>
|
|
|
|
|
+ <sql id="columns">
|
|
|
|
|
+ LOG_ID,LOG_CONTENT,FOREIGN_KEY_ID,FOREIGN_KEY_TYPE
|
|
|
|
|
+ </sql>
|
|
|
|
|
+ <sql id="select">
|
|
|
|
|
+ select <include refid="columns"/> from log_result
|
|
|
|
|
+ </sql>
|
|
|
|
|
+<!-- 1.定义重复的字段列表,维护成本高,通过复用基础字段来简化-->
|
|
|
|
|
+ <sql id="aliasColumns">
|
|
|
|
|
+ <foreach collection="columns.split(',')" item="col" separator=",">
|
|
|
|
|
+ t.${col.trim()}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </sql>
|
|
|
|
|
+
|
|
|
|
|
+ <sql id="select_alias">
|
|
|
|
|
+ select <include refid="aliasColumns"> from log_result t</include>
|
|
|
|
|
+ </sql>
|
|
|
|
|
+ <sql id="where">
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="logId !=null">
|
|
|
|
|
+ and LOG_ID=#{logId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="logContent !=null and logContent !=''">
|
|
|
|
|
+ and LOG_CONTENT=#{logContent}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="foreignKeyType !=null and foreignKeyType !=''">
|
|
|
|
|
+ and FOREIGN_KEY_TYPE=#{foreignKeyType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+-- 2.重复字段的硬编译,用循环来优化
|
|
|
|
|
+ <if test="alternateFeilds !=null and alternateFeilds.size()>0">
|
|
|
|
|
+ <foreach collection="alternateFeilds" item="field" index="index">
|
|
|
|
|
+ <if test="field !=null and field !=''">
|
|
|
|
|
+ and ALTERNATE_FIELDS${index +1}=#{field}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ </sql>
|
|
|
|
|
+ <sql id="whereLike">
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="logId !=null">
|
|
|
|
|
+ and LOG_ID=#{logId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="logContent !=null and logContent !=''">
|
|
|
|
|
+-- 3.直接拼接会存在SQL注入的风险
|
|
|
|
|
+ and LOG_CONTENT like concat('%',#{logContent},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="foreignKeyId !=null">
|
|
|
|
|
+ and FOREIGN_KEY_ID=#{foreignKeyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="foreignKeyType !=null and foreignKeyType !=''">
|
|
|
|
|
+ and FOREIGN_KEY_TYPE like concat('%','foreignKeyType','%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="insertTime !=null">
|
|
|
|
|
+ and TO_CHAR(INSERT_TIME,'yyyy-mm-dd')=#{insertTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="datagram !=null and datagram !=''">
|
|
|
|
|
+ <foreach collection="datagram" item="field" index="index">
|
|
|
|
|
+ <if test="field !=null and field !=''">
|
|
|
|
|
+ and DATAGRAM${index+1} like concat('%','field','%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="alternateFields !=null and alternateFields !=''">
|
|
|
|
|
+ <foreach collection="alternateFields" item="field" index="index">
|
|
|
|
|
+ <if test="field !=null and field !=''">
|
|
|
|
|
+ and ALTERNATE_FIELDS${index+1} like concat('%','field','%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ </sql>
|
|
|
|
|
+ <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
|
|
|
|
|
+ delete from LOG_RESULT
|
|
|
|
|
+ where LOG_ID=#{logId,jdbcType=DECIMAL}
|
|
|
|
|
+ </delete>
|
|
|
|
|
+ <delete id="delete" parameterType="HashMap">
|
|
|
|
|
+ delete from LOG_RESULT
|
|
|
|
|
+ where 1!=1
|
|
|
|
|
+ <if test="logContent !=null and logContent !=''">
|
|
|
|
|
+ or LOG_CONTENT=#{logContent}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="datagram !=null and datagram !=''">
|
|
|
|
|
+ <foreach collection="datagram" index="index" item="field">
|
|
|
|
|
+ <if test="field !=null and field !=''">
|
|
|
|
|
+ or DATAGRAM${index+1} =#{field}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </delete>
|
|
|
|
|
+ <insert id="insert" parameterType="LogResult">
|
|
|
|
|
+ insert into LOG_RESULT(LOG_ID,LOG_CONTENT,FOREIGN_KEY_ID,FOREIGN_KEY_TYPE)
|
|
|
|
|
+ values(#{logId},#{logContent},#{foreignKeyId},#{foreignKeyType}})
|
|
|
|
|
+ </insert>
|
|
|
|
|
+ <insert id="insert2" parameterType="LogResult">
|
|
|
|
|
+ insert into LOG_RESULT
|
|
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
+ <if test="logId !=null"> LOG_ID,</if>
|
|
|
|
|
+ <if test="logContent !=null"> LOG_CONTENT,</if>
|
|
|
|
|
+ <if test="foreignKeyId !=null"> FOREIGN_KEY_ID,</if>
|
|
|
|
|
+ <if test="foreignKeyType !=null"> FOREIGN_KEY_TYPE,</if>
|
|
|
|
|
+ <if test="alternateFields !=null">
|
|
|
|
|
+ <foreach collection="alternateFields" item="field" index="index">
|
|
|
|
|
+ ALTERNATE_FIELDS${index+1},
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </trim>
|
|
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
+ <if test="logId !=null">#{logId}</if>
|
|
|
|
|
+ <if test="logContent !=null">#{logContent}</if>
|
|
|
|
|
+ <if test="foreignKeyId !=null">#{foreignKeyId}</if>
|
|
|
|
|
+ <if test="foreignKeyType !=null">#{foreignKeyType}</if>
|
|
|
|
|
+ <if test="alternateFields !=null">
|
|
|
|
|
+ <foreach collection="alternateFields" index="index" item="field">
|
|
|
|
|
+ <if test="field !=null">
|
|
|
|
|
+ #{field}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </trim>
|
|
|
|
|
+ </insert>
|
|
|
|
|
+ <update id="update" parameterType="LogResult">
|
|
|
|
|
+ update LOG_RESULT
|
|
|
|
|
+ set LOG_CONTENT=#{logContent},
|
|
|
|
|
+ FOREIGN_KEY_ID=#{foeignKeyId},
|
|
|
|
|
+ FOREIGN_KEY_TYPE= #{foreignKeyType}
|
|
|
|
|
+ where LOG_ID=#{logId}
|
|
|
|
|
+ </update>
|
|
|
|
|
+ <update id="update2" parameterType="LogResult">
|
|
|
|
|
+ update LOG_RESULT
|
|
|
|
|
+ <set>
|
|
|
|
|
+ <if test="logContent !=null">
|
|
|
|
|
+ LOG_CONTENT=#{logContent}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="foreignKeyId !=null">
|
|
|
|
|
+ FOREIGN_KEY_ID= #{foreignKeyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="foreignKeyType !=null">
|
|
|
|
|
+ FOREIGN_KEY_TYPE= #{foreignKeyType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="alternateFields !=null">
|
|
|
|
|
+ <foreach collection="alternateFields" index="index" item="field">
|
|
|
|
|
+ <if test="field !=null">
|
|
|
|
|
+ ALTERNATE_FIELDS${index+1}=#{field}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </set>
|
|
|
|
|
+where LOG_ID = #{logId}
|
|
|
|
|
+ </update>
|
|
|
|
|
+<!-- 4.分页查询添加分页查询支持-->
|
|
|
|
|
+ <select id="selectByParameters" parameterType="HashMap" resultType="BaseResultMap">
|
|
|
|
|
+ <include refid="select"></include>
|
|
|
|
|
+ <include refid="where"></include>
|
|
|
|
|
+limit #{offset} , #{pageSize}
|
|
|
|
|
+ </select>
|
|
|
|
|
+ <delete id="batchDel" parameterType="List">
|
|
|
|
|
+ delete from LOG_RESULT
|
|
|
|
|
+ where LOG_ID in
|
|
|
|
|
+ <foreach collection="list" item="id" open="(" close=")" separator=",">
|
|
|
|
|
+ #{id}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </delete>
|
|
|
|
|
+
|
|
|
|
|
+</mapper>
|