<?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.xinelu.manage.mapper.nursestationclassifyrelation.NurseStationClassifyRelationMapper">

    <resultMap type="NurseStationClassifyRelation" id="NurseStationClassifyRelationResult">
        <result property="id" column="id"/>
        <result property="nurseStationId" column="nurse_station_id"/>
        <result property="nurseClassifyId" column="nurse_classify_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectNurseStationClassifyRelationVo">
        select id, nurse_station_id, nurse_classify_id, create_by, create_time, update_by, update_time
        from nurse_station_classify_relation
    </sql>

    <select id="selectNurseStationClassifyRelationList" parameterType="NurseStationClassifyRelation"
            resultMap="NurseStationClassifyRelationResult">
        <include refid="selectNurseStationClassifyRelationVo"/>
        <where>
            <if test="nurseStationId != null ">
                and nurse_station_id = #{nurseStationId}
            </if>
            <if test="nurseClassifyId != null ">
                and nurse_classify_id = #{nurseClassifyId}
            </if>
        </where>
    </select>

    <select id="selectNurseStationClassifyRelationById" parameterType="Long"
            resultMap="NurseStationClassifyRelationResult">
        <include refid="selectNurseStationClassifyRelationVo"/>
        where id = #{id}
    </select>

    <insert id="insertNurseStationClassifyRelation" parameterType="NurseStationClassifyRelation" useGeneratedKeys="true"
            keyProperty="id">
        insert into nurse_station_classify_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nurseStationId != null">nurse_station_id,
            </if>
            <if test="nurseClassifyId != null">nurse_classify_id,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="nurseStationId != null">#{nurseStationId},
            </if>
            <if test="nurseClassifyId != null">#{nurseClassifyId},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
        </trim>
    </insert>

    <update id="updateNurseStationClassifyRelation" parameterType="NurseStationClassifyRelation">
        update nurse_station_classify_relation
        <trim prefix="SET" suffixOverrides=",">
            <if test="nurseStationId != null">nurse_station_id =
                #{nurseStationId},
            </if>
            <if test="nurseClassifyId != null">nurse_classify_id =
                #{nurseClassifyId},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteNurseStationClassifyRelationById" parameterType="Long">
        delete
        from nurse_station_classify_relation
        where id = #{id}
    </delete>

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

    <insert id="insertNurseStationClassifyRelationList">
        insert into nurse_station_classify_relation (
        nurse_station_id,
        nurse_classify_id,
        create_by,
        create_time
        )
        values
        <foreach item="nurseStationClassifyRelationList" index="index" collection="list" separator=",">
            (
            #{nurseStationClassifyRelationList.nurseStationId},
            #{nurseStationClassifyRelationList.nurseClassifyId},
            #{nurseStationClassifyRelationList.createBy},
            #{nurseStationClassifyRelationList.createTime}
            )
        </foreach>
    </insert>

    <select id="selectNurseStationClassifyRelationByStationId" resultType="java.lang.Integer">
        select count(1)
        from nurse_station_classify_relation
        where nurse_station_id = #{nurseStationId}
    </select>

    <select id="selectNurseStationClassifyRelationByStationIds" resultType="java.lang.Integer">
        select count(1)
        from nurse_station_classify_relation
        where nurse_station_id in
        <foreach item="nurseStationId" collection="array" open="(" separator="," close=")">
            #{nurseStationId}
        </foreach>
    </select>

    <delete id="deleteStationClassifyRelationByStationId">
        delete
        from nurse_station_classify_relation
        where nurse_station_id = #{nurseStationId}
    </delete>

    <delete id="deleteStationClassifyRelationByStationIds">
        delete
        from nurse_station_classify_relation
        where nurse_station_id in
        <foreach item="nurseStationId" collection="array" open="(" separator="," close=")">
            #{nurseStationId}
        </foreach>
    </delete>
</mapper>