<?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.neu.his.cloud.service.bms.mapper.SmsSkdMapper">
  <resultMap id="BaseResultMap" type="com.neu.his.cloud.service.bms.model.SmsSkd">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="date" jdbcType="TIMESTAMP" property="date" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="remain" jdbcType="BIGINT" property="remain" />
    <result column="noon" jdbcType="INTEGER" property="noon" />
    <result column="staff_id" jdbcType="BIGINT" property="staffId" />
    <result column="dept_id" jdbcType="BIGINT" property="deptId" />
    <result column="sk_limit" jdbcType="BIGINT" property="skLimit" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, date, status, remain, noon, staff_id, dept_id, sk_limit
  </sql>
  <select id="selectByExample" parameterType="com.neu.his.cloud.service.bms.model.SmsSkdExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from sms_skd
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from sms_skd
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from sms_skd
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.neu.his.cloud.service.bms.model.SmsSkdExample">
    delete from sms_skd
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.neu.his.cloud.service.bms.model.SmsSkd">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sms_skd (date, status, remain, 
      noon, staff_id, dept_id, 
      sk_limit)
    values (#{date,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{remain,jdbcType=BIGINT}, 
      #{noon,jdbcType=INTEGER}, #{staffId,jdbcType=BIGINT}, #{deptId,jdbcType=BIGINT}, 
      #{skLimit,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="com.neu.his.cloud.service.bms.model.SmsSkd">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sms_skd
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="date != null">
        date,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="remain != null">
        remain,
      </if>
      <if test="noon != null">
        noon,
      </if>
      <if test="staffId != null">
        staff_id,
      </if>
      <if test="deptId != null">
        dept_id,
      </if>
      <if test="skLimit != null">
        sk_limit,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="date != null">
        #{date,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="remain != null">
        #{remain,jdbcType=BIGINT},
      </if>
      <if test="noon != null">
        #{noon,jdbcType=INTEGER},
      </if>
      <if test="staffId != null">
        #{staffId,jdbcType=BIGINT},
      </if>
      <if test="deptId != null">
        #{deptId,jdbcType=BIGINT},
      </if>
      <if test="skLimit != null">
        #{skLimit,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neu.his.cloud.service.bms.model.SmsSkdExample" resultType="java.lang.Integer">
    select count(*) from sms_skd
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update sms_skd
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.date != null">
        date = #{record.date,jdbcType=TIMESTAMP},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=INTEGER},
      </if>
      <if test="record.remain != null">
        remain = #{record.remain,jdbcType=BIGINT},
      </if>
      <if test="record.noon != null">
        noon = #{record.noon,jdbcType=INTEGER},
      </if>
      <if test="record.staffId != null">
        staff_id = #{record.staffId,jdbcType=BIGINT},
      </if>
      <if test="record.deptId != null">
        dept_id = #{record.deptId,jdbcType=BIGINT},
      </if>
      <if test="record.skLimit != null">
        sk_limit = #{record.skLimit,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update sms_skd
    set id = #{record.id,jdbcType=BIGINT},
      date = #{record.date,jdbcType=TIMESTAMP},
      status = #{record.status,jdbcType=INTEGER},
      remain = #{record.remain,jdbcType=BIGINT},
      noon = #{record.noon,jdbcType=INTEGER},
      staff_id = #{record.staffId,jdbcType=BIGINT},
      dept_id = #{record.deptId,jdbcType=BIGINT},
      sk_limit = #{record.skLimit,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neu.his.cloud.service.bms.model.SmsSkd">
    update sms_skd
    <set>
      <if test="date != null">
        date = #{date,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="remain != null">
        remain = #{remain,jdbcType=BIGINT},
      </if>
      <if test="noon != null">
        noon = #{noon,jdbcType=INTEGER},
      </if>
      <if test="staffId != null">
        staff_id = #{staffId,jdbcType=BIGINT},
      </if>
      <if test="deptId != null">
        dept_id = #{deptId,jdbcType=BIGINT},
      </if>
      <if test="skLimit != null">
        sk_limit = #{skLimit,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neu.his.cloud.service.bms.model.SmsSkd">
    update sms_skd
    set date = #{date,jdbcType=TIMESTAMP},
      status = #{status,jdbcType=INTEGER},
      remain = #{remain,jdbcType=BIGINT},
      noon = #{noon,jdbcType=INTEGER},
      staff_id = #{staffId,jdbcType=BIGINT},
      dept_id = #{deptId,jdbcType=BIGINT},
      sk_limit = #{skLimit,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>