<?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.huashe.park.core.mapper.ConsUnitHoleRelMapper">

    <resultMap type="ConsUnitHoleRel" id="ConsUnitHoleRelResult">
        <result property="id" column="id"/>
        <result property="holeId" column="hole_id"/>
        <result property="consUnitId" column="cons_unit_id"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <sql id="selectConsUnitHoleRelVo">
        select id, hole_id, cons_unit_id, update_time, create_time, create_by, update_by
        from cons_cons_unit_hole_rel
    </sql>

    <select id="selectConsUnitHoleRelList" parameterType="ConsUnitHoleRel" resultMap="ConsUnitHoleRelResult">
        <include refid="selectConsUnitHoleRelVo"/>
        <where>
            <if test="holeId != null ">and hole_id = #{holeId}</if>
            <if test="consUnitId != null ">and cons_unit_id = #{consUnitId}</if>
        </where>
    </select>

    <select id="selectConsUnitHoleRelById" parameterType="Long" resultMap="ConsUnitHoleRelResult">
        <include refid="selectConsUnitHoleRelVo"/>
        where id = #{id}
    </select>

    <insert id="insertConsUnitHoleRel" parameterType="ConsUnitHoleRel" useGeneratedKeys="true" keyProperty="id">
        insert into cons_cons_unit_hole_rel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="holeId != null">hole_id,</if>
            <if test="consUnitId != null">cons_unit_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="holeId != null">#{holeId},</if>
            <if test="consUnitId != null">#{consUnitId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updateConsUnitHoleRel" parameterType="ConsUnitHoleRel">
        update cons_cons_unit_hole_rel
        <trim prefix="SET" suffixOverrides=",">
            <if test="holeId != null">hole_id = #{holeId},</if>
            <if test="consUnitId != null">cons_unit_id = #{consUnitId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteConsUnitHoleRelById" parameterType="Long">
        delete
        from cons_cons_unit_hole_rel
        where id = #{id}
    </delete>

    <delete id="deleteConsUnitHoleRelByIds" parameterType="String">
        delete from cons_cons_unit_hole_rel where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>