<?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.SmsUserMapper" >
  <resultMap id="BaseResultMap" type="com.ssm.model.business.SmsUser" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="phoen" property="phoen" jdbcType="VARCHAR" />
    <result column="userid" property="userid" jdbcType="INTEGER" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="classify" property="classify" jdbcType="VARCHAR" />
    <result column="dict_name" property="dictName" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, name, phoen, userid, create_date, classify
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from sms_user
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from sms_user
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.ssm.model.business.SmsUser" >
    insert into sms_user (id, name, phoen, 
      userid, create_date, classify
      )
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{phoen,jdbcType=VARCHAR}, 
      #{userid,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}, #{classify,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.ssm.model.business.SmsUser" >
    insert into sms_user
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="phoen != null" >
        phoen,
      </if>
      <if test="userid != null" >
        userid,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="classify != null" >
        classify,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="phoen != null" >
        #{phoen,jdbcType=VARCHAR},
      </if>
      <if test="userid != null" >
        #{userid,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="classify != null" >
        #{classify,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.ssm.model.business.SmsUser" >
    update sms_user
    <set >
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="phoen != null" >
        phoen = #{phoen,jdbcType=VARCHAR},
      </if>
      <if test="userid != null" >
        userid = #{userid,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="classify != null" >
        classify = #{classify,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ssm.model.business.SmsUser" >
    update sms_user
    set name = #{name,jdbcType=VARCHAR},
      phoen = #{phoen,jdbcType=VARCHAR},
      userid = #{userid,jdbcType=INTEGER},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      classify = #{classify,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!-- 按条件查询用户信息 -->
  <select id="selectSmsUser"  resultMap="BaseResultMap">
  	SELECT smsu.*,sd.DictName dict_name from sms_user smsu,SysDictionary sd where 1=1 
      <if test="smsUser.classify != null and smsUser.classify != '' " >
        AND smsu.classify like CONCAT('%',#{smsUser.classify,jdbcType=VARCHAR},'%')
         
      </if>
      <if test="smsUser.name != null and smsUser.name != ''" >
        AND smsu.name like  CONCAT('%',#{smsUser.name,jdbcType=VARCHAR},'%')
        
       
      </if>
      <if test="smsUser.phoen != null and smsUser.phoen != ''" >
        AND smsu.phoen like CONCAT('%',#{smsUser.phoen,jdbcType=VARCHAR},'%')
         
      </if>
      and smsu.classify = sd.DictValue
	  order by smsu.id asc
  </select>
  
  <select id="selectSmsUserCountByPhoen" resultType="java.lang.Integer">
  	select COUNT(su.id) from sms_user su where 1=1
  	AND su.phoen = #{phoen}
  </select>
</mapper>