<?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.ruoyi.system.mapper.SysHesuanConfigurationMapper">
    
    <resultMap type="SysHesuanConfiguration" id="SysHesuanConfigurationResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="jobStyle"    column="job_style"    />
        <result property="focusCrowdStyle"    column="focus_crowd_style"    />
        <result property="detectionNumber"    column="detection_number"    />
        <result property="detectionScope"    column="detection_scope"    />
    </resultMap>

    <sql id="selectSysHesuanConfigurationVo">
        select id, dept_id, job_style, focus_crowd_style, detection_number, detection_scope from sys_hesuan_configuration
    </sql>

    <select id="selectSysHesuanConfigurationList" parameterType="SysHesuanConfiguration" resultMap="SysHesuanConfigurationResult">
        <include refid="selectSysHesuanConfigurationVo"/>
        <where>  
            <if test="jobStyle != null  and jobStyle != ''"> and job_style = #{jobStyle}</if>
            <if test="focusCrowdStyle != null  and focusCrowdStyle != ''"> and focus_crowd_style = #{focusCrowdStyle}</if>
            <if test="detectionNumber != null  and detectionNumber != ''"> and detection_number = #{detectionNumber}</if>
            <if test="detectionScope != null  and detectionScope != ''"> and detection_scope = #{detectionScope}</if>
            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
            <if test="deptIdList!= null and deptIdList.size()>0" >
                and dept_id in
                <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>

        </where>
    </select>
    
    <select id="selectSysHesuanConfigurationById" parameterType="Long" resultMap="SysHesuanConfigurationResult">
        <include refid="selectSysHesuanConfigurationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysHesuanConfiguration" parameterType="SysHesuanConfiguration" useGeneratedKeys="true" keyProperty="id">
        insert into sys_hesuan_configuration
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="jobStyle != null">job_style,</if>
            <if test="focusCrowdStyle != null">focus_crowd_style,</if>
            <if test="detectionNumber != null">detection_number,</if>
            <if test="detectionScope != null">detection_scope,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="jobStyle != null">#{jobStyle},</if>
            <if test="focusCrowdStyle != null">#{focusCrowdStyle},</if>
            <if test="detectionNumber != null">#{detectionNumber},</if>
            <if test="detectionScope != null">#{detectionScope},</if>
         </trim>
    </insert>

    <update id="updateSysHesuanConfiguration" parameterType="SysHesuanConfiguration">
        update sys_hesuan_configuration
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="jobStyle != null">job_style = #{jobStyle},</if>
            <if test="focusCrowdStyle != null">focus_crowd_style = #{focusCrowdStyle},</if>
            <if test="detectionNumber != null">detection_number = #{detectionNumber},</if>
            <if test="detectionScope != null">detection_scope = #{detectionScope},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysHesuanConfigurationById" parameterType="Long">
        delete from sys_hesuan_configuration where id = #{id}
    </delete>

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