<?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.iocoder.yudao.module.rescue.mapper.RescueConfigMapper">

    <resultMap type="cn.iocoder.yudao.module.rescue.domain.RescueConfig" id="RescueConfigResult">
        <result property="id"    column="id"    />
        <result property="rescueTcBig"    column="rescue_tc_big"    />
        <result property="rescueTcMid"    column="rescue_tc_mid"    />
        <result property="rescueTcSmall"    column="rescue_tc_small"    />
    </resultMap>

    <sql id="selectRescueConfigVo">
        select id, top_dept_id, rescue_tc_big, rescue_tc_mid, rescue_tc_small from rescue_config
    </sql>

    <select id="selectRescueConfigList" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueConfig" resultMap="RescueConfigResult">
        <include refid="selectRescueConfigVo"/>
        <where>
            <if test="topDeptId != null "> and top_dept_id = #{topDeptId}</if>
            <if test="rescueTcBig != null "> and rescue_tc_big = #{rescueTcBig}</if>
            <if test="rescueTcMid != null "> and rescue_tc_mid = #{rescueTcMid}</if>
            <if test="rescueTcSmall != null "> and rescue_tc_small = #{rescueTcSmall}</if>
        </where>
    </select>

    <select id="selectRescueConfigByDeptId"  resultMap="RescueConfigResult">
        <include refid="selectRescueConfigVo"/>
    </select>

    <insert id="insertRescueConfig" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueConfig"  useGeneratedKeys="true" keyProperty="id">
        insert into rescue_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="topDeptId != null">top_dept_id,</if>
            <if test="rescueTcBig != null">rescue_tc_big,</if>
            <if test="rescueTcMid != null">rescue_tc_mid,</if>
            <if test="rescueTcSmall != null">rescue_tc_small,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="topDeptId != null">#{topDeptId},</if>
            <if test="rescueTcBig != null">#{rescueTcBig},</if>
            <if test="rescueTcMid != null">#{rescueTcMid},</if>
            <if test="rescueTcSmall != null">#{rescueTcSmall},</if>
        </trim>
    </insert>

    <update id="updateRescueConfig" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueConfig">
        update rescue_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="topDeptId != null">top_dept_id = #{topDeptId},</if>
            <if test="rescueTcBig != null">rescue_tc_big = #{rescueTcBig},</if>
            <if test="rescueTcMid != null">rescue_tc_mid = #{rescueTcMid},</if>
            <if test="rescueTcSmall != null">rescue_tc_small = #{rescueTcSmall},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRescueConfigById" >
        delete from rescue_config where id = #{id}
    </delete>

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