<?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.SzxcCsEmplyeesMapper">
    
    <resultMap type="SzxcCsEmplyees" id="SzxcCsEmplyeesResult">
        <result property="id"    column="id"    />
        <result property="csId"    column="cs_id"    />
        <result property="csName"    column="cs_name"    />
        <result property="ygName"    column="yg_name"    />
        <result property="phone"    column="phone"    />
        <result property="cardId"    column="card_id"    />
        <result property="sex"    column="sex"    />
        <result property="dyOrNot"    column="dy_or_not"    />
        <result property="currentAddress"    column="current_address"    />
        <result property="province"    column="province"    />
        <result property="city"    column="city"    />
        <result property="county"    column="county"    />
        <result property="hjAddress"    column="hj_address"    />
        <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="selectSzxcCsEmplyeesVo">
        select id, cs_id, cs_name, yg_name, phone, card_id, sex, dy_or_not, current_address, province, city, county, hj_address, create_by, create_time, update_by, update_time from szxc_cs_emplyees
    </sql>

    <select id="selectSzxcCsEmplyeesList" parameterType="SzxcCsEmplyees" resultMap="SzxcCsEmplyeesResult">
        <include refid="selectSzxcCsEmplyeesVo"/>
        <where>  
            <if test="csId != null "> and cs_id = #{csId}</if>
            <if test="csName != null  and csName != ''"> and cs_name like concat('%', #{csName}, '%')</if>
            <if test="ygName != null  and ygName != ''"> and yg_name like concat('%', #{ygName}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="cardId != null  and cardId != ''"> and card_id = #{cardId}</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="dyOrNot != null  and dyOrNot != ''"> and dy_or_not = #{dyOrNot}</if>
            <if test="currentAddress != null  and currentAddress != ''"> and current_address = #{currentAddress}</if>
            <if test="province != null  and province != ''"> and province = #{province}</if>
            <if test="city != null  and city != ''"> and city = #{city}</if>
            <if test="county != null  and county != ''"> and county = #{county}</if>
            <if test="hjAddress != null  and hjAddress != ''"> and hj_address = #{hjAddress}</if>
        </where>
    </select>
    
    <select id="selectSzxcCsEmplyeesById" parameterType="Long" resultMap="SzxcCsEmplyeesResult">
        <include refid="selectSzxcCsEmplyeesVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSzxcCsEmplyees" parameterType="SzxcCsEmplyees" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_cs_emplyees
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="csId != null">cs_id,</if>
            <if test="csName != null">cs_name,</if>
            <if test="ygName != null">yg_name,</if>
            <if test="phone != null">phone,</if>
            <if test="cardId != null">card_id,</if>
            <if test="sex != null">sex,</if>
            <if test="dyOrNot != null">dy_or_not,</if>
            <if test="currentAddress != null">current_address,</if>
            <if test="province != null">province,</if>
            <if test="city != null">city,</if>
            <if test="county != null">county,</if>
            <if test="hjAddress != null">hj_address,</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="csId != null">#{csId},</if>
            <if test="csName != null">#{csName},</if>
            <if test="ygName != null">#{ygName},</if>
            <if test="phone != null">#{phone},</if>
            <if test="cardId != null">#{cardId},</if>
            <if test="sex != null">#{sex},</if>
            <if test="dyOrNot != null">#{dyOrNot},</if>
            <if test="currentAddress != null">#{currentAddress},</if>
            <if test="province != null">#{province},</if>
            <if test="city != null">#{city},</if>
            <if test="county != null">#{county},</if>
            <if test="hjAddress != null">#{hjAddress},</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="updateSzxcCsEmplyees" parameterType="SzxcCsEmplyees">
        update szxc_cs_emplyees
        <trim prefix="SET" suffixOverrides=",">
            <if test="csId != null">cs_id = #{csId},</if>
            <if test="csName != null">cs_name = #{csName},</if>
            <if test="ygName != null">yg_name = #{ygName},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="cardId != null">card_id = #{cardId},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="dyOrNot != null">dy_or_not = #{dyOrNot},</if>
            <if test="currentAddress != null">current_address = #{currentAddress},</if>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="county != null">county = #{county},</if>
            <if test="hjAddress != null">hj_address = #{hjAddress},</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="deleteSzxcCsEmplyeesById" parameterType="Long">
        delete from szxc_cs_emplyees where id = #{id}
    </delete>

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