InternalDomainHistoryMapper.xml 2.8 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.monitor.mysql.mapper.InternalDomainHistoryMapper" >
  <resultMap id="BaseResultMap" type="com.model.InternalDomainHistory" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="domain" property="domain" jdbcType="VARCHAR" />
    <result column="environment" property="environment" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="value" property="value" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="tag" property="tag" jdbcType="VARCHAR" />
    <result column="user" property="user" jdbcType="VARCHAR" />
    <result column="operate" property="operate" jdbcType="VARCHAR" />
    <result column="createTime" property="createTime" jdbcType="VARCHAR" />

  </resultMap>

  <select id="selectCountByCodition"  resultType="java.lang.Integer">
    select
      count(1)
    from internal_domain_history
    where
    1=1
    <if test="params.id != null &amp;&amp; params.id != 0" >
      and id = #{params.id}
    </if>
    <if test="params.domain != null &amp;&amp; params.domain != ''" >
    and domain = #{params.domain}
  </if>
    <if test="params.environment != null &amp;&amp; params.environment != ''" >
      and environment = #{params.environment}
    </if>
    <if test="params.name != null &amp;&amp; params.name != ''" >
      and name = #{params.name}
    </if>
  </select>

  <select id="selectByCodition"   resultMap="BaseResultMap">
    select
    id,user,operate,domain,environment,name,value,user,type,tag,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime
    from internal_domain_history
    where
    1=1
    <if test="params.id != null &amp;&amp; params.id != 0" >
      and id = #{params.id}
    </if>
    <if test="params.domain != null &amp;&amp; params.domain != ''" >
      and domain = #{params.domain}
    </if>
    <if test="params.environment != null &amp;&amp; params.environment != ''" >
      and environment = #{params.environment}
    </if>
    <if test="params.name != null &amp;&amp; params.name != ''" >
      and name = #{params.name}
    </if>
    order by create_time desc
    limit #{startIndex},#{pageSize}
  </select>

  <insert id="insert" parameterType="com.model.InternalDomainHistory" >
    insert into internal_domain_history
    (id,domain, environment, name, value, type,tag,user,operate,create_time)
    values
    (#{id,jdbcType=INTEGER},#{domain,jdbcType=VARCHAR},#{environment,jdbcType=VARCHAR},
    #{name,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},
    #{type,jdbcType=VARCHAR},#{tag,jdbcType=VARCHAR}
    ,#{user,jdbcType=VARCHAR},#{operate,jdbcType=VARCHAR},now())
  </insert>

</mapper>