<?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="cn.timer.api.dao.kqgl.AttGroupBinPunchModeMapper" >
  <resultMap id="BaseResultMap" type="cn.timer.api.bean.kqgl.AttGroupBinPunchMode" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="dkfsid" property="dkfsid" jdbcType="INTEGER" />
    <result column="kqz_id" property="kqzId" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="INTEGER" />
    <result column="qyid" property="qyid" jdbcType="INTEGER" />
    <result column="state" property="state" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, dkfsid, kqz_id, type, qyid, state
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from kqgl_asso_kqzdkfs
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from kqgl_asso_kqzdkfs
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="cn.timer.api.bean.kqgl.AttGroupBinPunchMode" useGeneratedKeys="true" keyProperty="id">
    insert into kqgl_asso_kqzdkfs (dkfsid, kqz_id, 
      type, qyid, state)
    values (#{dkfsid,jdbcType=INTEGER}, #{kqzId,jdbcType=INTEGER}, 
      #{type,jdbcType=INTEGER}, #{qyid,jdbcType=INTEGER}, #{state,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="cn.timer.api.bean.kqgl.AttGroupBinPunchMode" useGeneratedKeys="true" keyProperty="id">
    insert into kqgl_asso_kqzdkfs
    <trim prefix="(" suffix=")" suffixOverrides="," >
      
      <if test="dkfsid != null" >
        dkfsid,
      </if>
      <if test="kqzId != null" >
        kqz_id,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="qyid != null" >
        qyid,
      </if>
      <if test="state != null" >
        state,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      
      <if test="dkfsid != null" >
        #{dkfsid,jdbcType=INTEGER},
      </if>
      <if test="kqzId != null" >
        #{kqzId,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        #{type,jdbcType=INTEGER},
      </if>
      <if test="qyid != null" >
        #{qyid,jdbcType=INTEGER},
      </if>
      <if test="state != null" >
        #{state,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.timer.api.bean.kqgl.AttGroupBinPunchMode" >
    update kqgl_asso_kqzdkfs
    <set >
      <if test="dkfsid != null" >
        dkfsid = #{dkfsid,jdbcType=INTEGER},
      </if>
      <if test="kqzId != null" >
        kqz_id = #{kqzId,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=INTEGER},
      </if>
      <if test="qyid != null" >
        qyid = #{qyid,jdbcType=INTEGER},
      </if>
      <if test="state != null" >
        state = #{state,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.timer.api.bean.kqgl.AttGroupBinPunchMode" >
    update kqgl_asso_kqzdkfs
    set dkfsid = #{dkfsid,jdbcType=INTEGER},
      kqz_id = #{kqzId,jdbcType=INTEGER},
      type = #{type,jdbcType=INTEGER},
      qyid = #{qyid,jdbcType=INTEGER},
      state = #{state,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  
	<insert id="insertKqglAssokqzdKfsList" parameterType="java.util.List" >
	    insert into kqgl_asso_kqzdkfs (dkfsid, kqz_id, type, qyid, state)
	    <foreach collection="list" item="item" index="index" open="values " close="" separator=",">
	   	(
	      <if test="item.dkfsid != null" >
	        #{item.dkfsid,jdbcType=INTEGER},
	      </if>
	      <if test="item.kqzId != null" >
	        #{item.kqzId,jdbcType=INTEGER},
	      </if>
	      <if test="item.type != null" >
	        #{item.type,jdbcType=INTEGER},
	      </if>
	      <if test="item.qyid != null" >
	        #{item.qyid,jdbcType=INTEGER},
	      </if>
	      <if test="item.state != null" >
	        #{item.state,jdbcType=INTEGER}
	      </if>
	      )
	    </foreach>
   </insert>
   
   <delete id="deleteByPrimaryBykqzid" parameterType="java.lang.Integer" >
    delete from kqgl_asso_kqzdkfs
    where kqz_id = #{kqzId,jdbcType=INTEGER}
  </delete>
  
  <select id="selectByPrimaryByKqzId" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from kqgl_asso_kqzdkfs
    where kqz_id = #{kqzid,jdbcType=INTEGER}
  </select>
  
  <select id="selectMachineByKqzId" resultMap="BaseResultMap">
  	select * from kqgl_asso_kqzdkfs
    where kqz_id = #{kqzid}
	and type = 1
  </select>
  
  
</mapper>