ABTestMapper.xml 2.99 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.ABTestMapper" >
  <resultMap id="BaseResultMap" type="com.model.ABTest" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="ab_type" property="abType" jdbcType="VARCHAR" />
    <result column="config_type" property="configType" jdbcType="VARCHAR" />
    <result column="value" property="value" jdbcType="VARCHAR" />
    <result column="comment" property="comment" jdbcType="VARCHAR" />
    <result column="createTime" property="createTime" jdbcType="VARCHAR" />
    <result column="updateTime" property="updateTime" jdbcType="VARCHAR" />

  </resultMap>

  <sql id="Base_Column_List" >
    id, name, ab_type, config_type, value, comment,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime,DATE_FORMAT(update_time,'%Y-%m-%d %H:%i:%S') AS updateTime
  </sql>

  <insert id="insert" parameterType="com.model.ABTest" >
    insert into ab_test
    (name,ab_type,config_type, value, comment, create_time, update_time)
    values
    (#{name,jdbcType=VARCHAR},#{abType,jdbcType=INTEGER},
    #{configType,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},
    #{comment,jdbcType=VARCHAR},
    now(),now())
  </insert>

  <update id="update" parameterType="com.model.AuthModule" >
    update ab_test
    set
    value = #{value,jdbcType=VARCHAR},
    update_time = now()
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectAllByParam" resultMap="BaseResultMap" parameterType="com.model.AuthModule" >
    select
    <include refid="Base_Column_List" />
    from ab_test
    where ab_type = #{abType,jdbcType=VARCHAR} and config_type =  #{configType,jdbcType=VARCHAR}
  </select>

  <select id="selectByPage" resultMap="BaseResultMap" parameterType="com.model.AuthModule" >
    select
    <include refid="Base_Column_List" />
    from ab_test
    where
    1=1
    <if test="params.configType != null &amp;&amp; params.configType != ''" >
      and config_type =  #{configType,jdbcType=VARCHAR}
    </if>
    <if test="params.abType != null &amp;&amp; params.abType != ''" >
      and ab_type = #{params.abType}
    </if>
    order by create_time desc
    limit #{startIndex},#{pageSize}
  </select>

  <select id="selectAll" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ab_test
  </select>

  <select id="selectCount"  resultType="java.lang.Integer">
    select
    count(1)
    from ab_test
    where
    1=1
    <if test="params.configType != null &amp;&amp; params.configType != ''" >
      and config_type =  #{configType,jdbcType=VARCHAR}
    </if>
    <if test="params.abType != null &amp;&amp; params.abType != ''" >
      and ab_type = #{params.abType}
    </if>
  </select>

  <delete id="delete" parameterType="java.lang.Integer" >
    delete from ab_test
    where id = #{id,jdbcType=INTEGER}
  </delete>
</mapper>