<?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.baseinfo.appverificationcode.mapper.AppVerificationCodeMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.appverificationcode.model.AppVerificationCode">
    <id column="INFO_ID" jdbcType="VARCHAR" property="infoId" />
    <result column="PHONE_NO" jdbcType="VARCHAR" property="phoneNo" />
    <result column="CODE" jdbcType="VARCHAR" property="code" />
    <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
    <result column="EXPIRATION_TIME" jdbcType="TIMESTAMP" property="expirationTime" />
    <result column="VALUE_FLAG" jdbcType="VARCHAR" property="valueFlag" />
  </resultMap>
  <sql id="columns">
    INFO_ID, PHONE_NO, CODE, CREATE_TIME, EXPIRATION_TIME, VALUE_FLAG
  </sql>
  <sql id="columns_alias">
    t.INFO_ID, t.PHONE_NO, t.CODE, t.CREATE_TIME, t.EXPIRATION_TIME, t.VALUE_FLAG
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM APP_VERIFICATION_CODE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM APP_VERIFICATION_CODE t
  </sql>
  <sql id="where">
    <where> 
      <if test="infoId != null and infoId != ''">
        and INFO_ID = #{infoId}
      </if>
      <if test="phoneNo != null and phoneNo != ''">
        and PHONE_NO = #{phoneNo}
      </if>
      <if test="code != null and code != ''">
        and CODE = #{code}
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="expirationTime != null">
        and TO_CHAR(EXPIRATION_TIME,'yyyy-MM-dd') = #{expirationTime}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG = #{valueFlag}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="infoId != null and infoId != ''">
        and INFO_ID LIKE '%${infoId}%'
      </if>
      <if test="phoneNo != null and phoneNo != ''">
        and PHONE_NO LIKE '%${phoneNo}%'
      </if>
      <if test="code != null and code != ''">
        and CODE LIKE '%${code}%'
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="expirationTime != null">
        and TO_CHAR(EXPIRATION_TIME,'yyyy-MM-dd') = #{expirationTime}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG LIKE '%${valueFlag}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from APP_VERIFICATION_CODE
    where INFO_ID = #{infoId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from APP_VERIFICATION_CODE
    where 1!=1 
      <if test="phoneNo != null and phoneNo != ''">
        or PHONE_NO = #{phoneNo}
      </if>
      <if test="code != null and code != ''">
        or CODE = #{code}
      </if>
      <if test="createTime != null">
        or TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = '#{createTime}'
      </if>
      <if test="expirationTime != null">
        or TO_CHAR(EXPIRATION_TIME,'yyyy-MM-dd') = '#{expirationTime}'
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        or VALUE_FLAG = #{valueFlag}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.appverificationcode.model.AppVerificationCode">
    insert into APP_VERIFICATION_CODE (INFO_ID, PHONE_NO, CODE, 
      CREATE_TIME, EXPIRATION_TIME, VALUE_FLAG
      )
    values (#{infoId,jdbcType=VARCHAR}, #{phoneNo,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{expirationTime,jdbcType=TIMESTAMP}, #{valueFlag,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.appverificationcode.model.AppVerificationCode">
    insert into APP_VERIFICATION_CODE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="infoId != null">
        INFO_ID,
      </if>
      <if test="phoneNo != null">
        PHONE_NO,
      </if>
      <if test="code != null">
        CODE,
      </if>
      <if test="createTime != null">
        CREATE_TIME,
      </if>
      <if test="expirationTime != null">
        EXPIRATION_TIME,
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="infoId != null">
        #{infoId,jdbcType=VARCHAR},
      </if>
      <if test="phoneNo != null">
        #{phoneNo,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="expirationTime != null">
        #{expirationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="valueFlag != null">
        #{valueFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.appverificationcode.model.AppVerificationCode">
    update APP_VERIFICATION_CODE
    set PHONE_NO = #{phoneNo,jdbcType=VARCHAR},
      CODE = #{code,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      EXPIRATION_TIME = #{expirationTime,jdbcType=TIMESTAMP},
      VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR}
    where INFO_ID = #{infoId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.appverificationcode.model.AppVerificationCode">
    update APP_VERIFICATION_CODE
    <set>
      <if test="phoneNo != null">
        PHONE_NO = #{phoneNo,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        CODE = #{code,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="expirationTime != null">
        EXPIRATION_TIME = #{expirationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      </if>
    </set>
    where INFO_ID = #{infoId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where INFO_ID = #{infoId,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into APP_VERIFICATION_CODE 
      (INFO_ID, 
      PHONE_NO, CODE, CREATE_TIME, 
      EXPIRATION_TIME, VALUE_FLAG)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.infoId,jdbcType=VARCHAR}, 
      #{item.phoneNo,jdbcType=VARCHAR}, #{item.code,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
      #{item.expirationTime,jdbcType=TIMESTAMP}, #{item.valueFlag,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update APP_VERIFICATION_CODE
     set
       INFO_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case INFO_ID" close="end">
          when #{item.infoId,jdbcType=VARCHAR} then #{item.infoId,jdbcType=VARCHAR}
       </foreach>
       ,PHONE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case INFO_ID" close="end">
          when #{item.infoId,jdbcType=VARCHAR} then #{item.phoneNo,jdbcType=VARCHAR}
       </foreach>
       ,CODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case INFO_ID" close="end">
          when #{item.infoId,jdbcType=VARCHAR} then #{item.code,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case INFO_ID" close="end">
          when #{item.infoId,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
       ,EXPIRATION_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case INFO_ID" close="end">
          when #{item.infoId,jdbcType=VARCHAR} then #{item.expirationTime,jdbcType=TIMESTAMP}
       </foreach>
       ,VALUE_FLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case INFO_ID" close="end">
          when #{item.infoId,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
       </foreach>
     where INFO_ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.infoId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from APP_VERIFICATION_CODE
    where INFO_ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->

  <select id="selectByPhone" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where phone_no = #{phoneNum,jdbcType=VARCHAR}
  </select>
</mapper>