<?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.UserInfoMapper">
    
    <resultMap type="UserInfo" id="UserInfoResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="gender"    column="gender"    />
        <result property="age"    column="age"    />
        <result property="idCard"    column="id_card"    />
        <result property="phoneNum"    column="phone_num"    />
        <result property="deptId"    column="dept_id"    />
        <result property="nucleicCollectTime"    column="nucleic_collect_time"    />
        <result property="nucleicResultsTime"    column="nucleic_results_time"    />
        <result property="jobStyle"    column="job_style"    />
        <result property="focusCrowdStyle"    column="focus_crowd_style"    />
        <result property="collectPlace"    column="collect_place"    />
        <result property="detectionFrequency"    column="detection_frequency"    />
        <result property="detectionNumber"    column="detection_number"    />
        <result property="detectionScope"    column="detection_scope"    />
        <result property="deptName"    column="dept_name"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectUserInfoVo">
        select id, name, gender, age, id_card, phone_num, dept_id, collect_place, nucleic_collect_time, nucleic_results_time, job_style, focus_crowd_style, detection_frequency, detection_number, detection_scope, dept_name, start_time, end_time, create_by, create_time, update_by, update_time, remark from user_info
    </sql>

    <select id="selectUserInfoList" parameterType="UserInfo" resultMap="UserInfoResult">
        <include refid="selectUserInfoVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="phoneNum != null  and phoneNum != ''"> and phone_num = #{phoneNum}</if>
            <if test="nucleicCollectTime != null  and nucleicCollectTime != ''"> and nucleic_collect_time = #{nucleicCollectTime}</if>
            <if test="nucleicResultsTime != null  and nucleicResultsTime != ''"> and nucleic_results_time = #{nucleicResultsTime}</if>
            <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="detectionFrequency != null  and detectionFrequency != ''"> and detection_frequency = #{detectionFrequency}</if>
            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>

            <if test="startTime != null  and startTime != ''"> and start_time > #{startTime}</if>
            <if test="endTime != null  and endTime != ''"> and #{endTime}>=end_time</if>

        </where>
    </select>
    
    <select id="selectUserInfoById" parameterType="Long" resultMap="UserInfoResult">
        <include refid="selectUserInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertUserInfo" parameterType="UserInfo">
        insert into user_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="gender != null">gender,</if>
            <if test="age != null">age,</if>
            <if test="idCard != null">id_card,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="nucleicCollectTime != null">nucleic_collect_time,</if>
            <if test="nucleicResultsTime != null">nucleic_results_time,</if>
            <if test="jobStyle != null">job_style,</if>
            <if test="focusCrowdStyle != null">focus_crowd_style,</if>
            <if test="detectionFrequency != null">detection_frequency,</if>
            <if test="detectionNumber != null">detection_number,</if>
            <if test="detectionScope != null">detection_scope,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="gender != null">#{gender},</if>
            <if test="age != null">#{age},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="nucleicCollectTime != null">#{nucleicCollectTime},</if>
            <if test="nucleicResultsTime != null">#{nucleicResultsTime},</if>
            <if test="jobStyle != null">#{jobStyle},</if>
            <if test="focusCrowdStyle != null">#{focusCrowdStyle},</if>
            <if test="detectionFrequency != null">#{detectionFrequency},</if>
            <if test="detectionNumber != null">#{detectionNumber},</if>
            <if test="detectionScope != null">#{detectionScope},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateUserInfo" parameterType="UserInfo">
        update user_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="age != null">age = #{age},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="nucleicCollectTime != null">nucleic_collect_time = #{nucleicCollectTime},</if>
            <if test="nucleicResultsTime != null">nucleic_results_time = #{nucleicResultsTime},</if>
            <if test="jobStyle != null">job_style = #{jobStyle},</if>
            <if test="focusCrowdStyle != null">focus_crowd_style = #{focusCrowdStyle},</if>
            <if test="detectionFrequency != null">detection_frequency = #{detectionFrequency},</if>
            <if test="detectionNumber != null">detection_number = #{detectionNumber},</if>
            <if test="detectionScope != null">detection_scope = #{detectionScope},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUserInfoById" parameterType="Long">
        delete from user_info where id = #{id}
    </delete>

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