<?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.ssm.mapper.business.SmsRecordMapper" >
  <resultMap id="BaseResultMap" type="com.ssm.model.business.SmsRecord" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="phoens" property="phoens" jdbcType="VARCHAR" />
    <result column="content" property="content" jdbcType="VARCHAR" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="msgid" property="msgid" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, phoens, content, create_date, msgid
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from sms_record
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from sms_record
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.ssm.model.business.SmsRecord" >
    insert into sms_record (id, phoens, content, 
      create_date, msgid)
    values (#{id,jdbcType=INTEGER}, #{phoens,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, 
      #{createDate,jdbcType=TIMESTAMP}, #{msgid,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.ssm.model.business.SmsRecord" >
    insert into sms_record
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="phoens != null" >
        phoens,
      </if>
      <if test="content != null" >
        content,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="msgid != null" >
        msgid,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="phoens != null" >
        #{phoens,jdbcType=VARCHAR},
      </if>
      <if test="content != null" >
        #{content,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="msgid != null" >
        #{msgid,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.ssm.model.business.SmsRecord" >
    update sms_record
    <set >
      <if test="phoens != null" >
        phoens = #{phoens,jdbcType=VARCHAR},
      </if>
      <if test="content != null" >
        content = #{content,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="msgid != null" >
        msgid = #{msgid,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ssm.model.business.SmsRecord" >
    update sms_record
    set phoens = #{phoens,jdbcType=VARCHAR},
      content = #{content,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      msgid = #{msgid,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="selectSmsRecord" resultMap="BaseResultMap">
  	select * from sms_record sr where 1=1 
     <if test="smsRecord.phoens != null and smsRecord.phoens != ''" >
       AND sr.phoens like CONCAT('%',#{smsRecord.phoens,jdbcType=VARCHAR},'%')
     </if>
       order by sr.create_date desc
  </select>
</mapper>