<?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.szxc.mapper.SzxcDyManageMapper">
    
    <resultMap type="SzxcDyManage" id="SzxcDyManageResult">
        <result property="id"    column="id"    />
        <result property="jmId"    column="jm_id"    />
        <result property="name"    column="name"    />
        <result property="cardId"    column="card_id"    />
        <result property="phone"    column="phone"    />
        <result property="deptName"    column="dept_name"    />
        <result property="deptId"    column="dept_id"    />
        <result property="jg"    column="jg"    />
        <result property="joinDate"    column="join_date"    />
        <result property="joinUnit"    column="join_unit"    />
        <result property="post"    column="post"    />
        <result property="type"    column="type"    />
        <result property="remark"    column="remark"    />
        <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="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcDyManageVo">
        select id, jm_id, name, card_id, phone, dept_name, dept_id, jg, join_date, join_unit, post, type, remark, create_by, create_time, update_by, update_time, user_id from szxc_dy_manage
    </sql>

    <select id="selectSzxcDyManageList" parameterType="SzxcDyManage" resultMap="SzxcDyManageResult">
        <include refid="selectSzxcDyManageVo"/>
        <where>  
            <if test="jmId != null "> and jm_id = #{jmId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="cardId != null  and cardId != ''"> and card_id = #{cardId}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="jg != null  and jg != ''"> and jg = #{jg}</if>
            <if test="joinDate != null "> and join_date = #{joinDate}</if>
            <if test="joinUnit != null  and joinUnit != ''"> and join_unit = #{joinUnit}</if>
            <if test="post != null  and post != ''"> and post = #{post}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>
    
    <select id="selectSzxcDyManageById" parameterType="Long" resultMap="SzxcDyManageResult">
        <include refid="selectSzxcDyManageVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSzxcDyManage" parameterType="SzxcDyManage" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_dy_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jmId != null">jm_id,</if>
            <if test="name != null">name,</if>
            <if test="cardId != null">card_id,</if>
            <if test="phone != null">phone,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="jg != null">jg,</if>
            <if test="joinDate != null">join_date,</if>
            <if test="joinUnit != null">join_unit,</if>
            <if test="post != null">post,</if>
            <if test="type != null">type,</if>
            <if test="remark != null">remark,</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="userId != null">user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jmId != null">#{jmId},</if>
            <if test="name != null">#{name},</if>
            <if test="cardId != null">#{cardId},</if>
            <if test="phone != null">#{phone},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="jg != null">#{jg},</if>
            <if test="joinDate != null">#{joinDate},</if>
            <if test="joinUnit != null">#{joinUnit},</if>
            <if test="post != null">#{post},</if>
            <if test="type != null">#{type},</if>
            <if test="remark != null">#{remark},</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="userId != null">#{userId},</if>
         </trim>
    </insert>

    <update id="updateSzxcDyManage" parameterType="SzxcDyManage">
        update szxc_dy_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="jmId != null">jm_id = #{jmId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="cardId != null">card_id = #{cardId},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="jg != null">jg = #{jg},</if>
            <if test="joinDate != null">join_date = #{joinDate},</if>
            <if test="joinUnit != null">join_unit = #{joinUnit},</if>
            <if test="post != null">post = #{post},</if>
            <if test="type != null">type = #{type},</if>
            <if test="remark != null">remark = #{remark},</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="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcDyManageById" parameterType="Long">
        delete from szxc_dy_manage where id = #{id}
    </delete>

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