<?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.WorkerApplyMapper">
    
    <resultMap type="WorkerApply" id="WorkerApplyResult">
        <result property="id"    column="id"    />
        <result property="uid"    column="uid"    />
        <result property="name"    column="name"    />
        <result property="phone"    column="phone"    />
        <result property="address"    column="address"    />
        <result property="cardNo"    column="card_no"    />
        <result property="skillId"    column="skill_id"    />
        <result property="cardAvatar"    column="card_avatar"    />
        <result property="cardBadge"    column="card_badge"    />
        <result property="image"    column="image"    />
        <result property="skill"    column="skill"    />
        <result property="criminal"    column="criminal"    />
        <result property="health"    column="health"    />
        <result property="education"    column="education"    />
        <result property="drive"    column="drive"    />
        <result property="status"    column="status"    />
        <result property="remarks"    column="remarks"    />
        <result property="cityPid"    column="city_pid"    />
        <result property="cityIds"    column="city_ids"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
        <result property="deletedAt"    column="deleted_at"    />
    </resultMap>

    <sql id="selectWorkerApplyVo">
        select id, uid, name, phone, address, card_no, skill_id, card_avatar, card_badge, image, skill, criminal, health, education, drive, status, remarks, city_pid, city_ids, created_at, updated_at, deleted_at from worker_apply
    </sql>

    <select id="selectWorkerApplyList" parameterType="WorkerApply" resultMap="WorkerApplyResult">
        <include refid="selectWorkerApplyVo"/>
        <where>  
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
            <if test="address != null  and address != ''"> and address like  concat('%', #{address}, '%')</if>
            <if test="cardNo != null  and cardNo != ''"> and card_no = #{cardNo}</if>
            <if test="skillId != null  and skillId != ''"> and skill_id = #{skillId}</if>
            <if test="cardAvatar != null  and cardAvatar != ''"> and card_avatar = #{cardAvatar}</if>
            <if test="cardBadge != null  and cardBadge != ''"> and card_badge = #{cardBadge}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="skill != null  and skill != ''"> and skill = #{skill}</if>
            <if test="criminal != null  and criminal != ''"> and criminal = #{criminal}</if>
            <if test="health != null  and health != ''"> and health = #{health}</if>
            <if test="education != null  and education != ''"> and education = #{education}</if>
            <if test="drive != null  and drive != ''"> and drive = #{drive}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="cityPid != null "> and city_pid = #{cityPid}</if>
            <if test="cityIds != null  and cityIds != ''"> and city_ids = #{cityIds}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
            <if test="deletedAt != null "> and deleted_at = #{deletedAt}</if>
        </where>
    </select>
    
    <select id="selectWorkerApplyById" parameterType="Long" resultMap="WorkerApplyResult">
        <include refid="selectWorkerApplyVo"/>
        where id = #{id}
    </select>

    <insert id="insertWorkerApply" parameterType="WorkerApply" useGeneratedKeys="true" keyProperty="id">
        insert into worker_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uid != null">uid,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="address != null and address != ''">address,</if>
            <if test="cardNo != null">card_no,</if>
            <if test="skillId != null">skill_id,</if>
            <if test="cardAvatar != null">card_avatar,</if>
            <if test="cardBadge != null">card_badge,</if>
            <if test="image != null">image,</if>
            <if test="skill != null">skill,</if>
            <if test="criminal != null">criminal,</if>
            <if test="health != null">health,</if>
            <if test="education != null">education,</if>
            <if test="drive != null">drive,</if>
            <if test="status != null">status,</if>
            <if test="remarks != null">remarks,</if>
            <if test="cityPid != null">city_pid,</if>
            <if test="cityIds != null">city_ids,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="updatedAt != null">updated_at,</if>
            <if test="deletedAt != null">deleted_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uid != null">#{uid},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="address != null and address != ''">#{address},</if>
            <if test="cardNo != null">#{cardNo},</if>
            <if test="skillId != null">#{skillId},</if>
            <if test="cardAvatar != null">#{cardAvatar},</if>
            <if test="cardBadge != null">#{cardBadge},</if>
            <if test="image != null">#{image},</if>
            <if test="skill != null">#{skill},</if>
            <if test="criminal != null">#{criminal},</if>
            <if test="health != null">#{health},</if>
            <if test="education != null">#{education},</if>
            <if test="drive != null">#{drive},</if>
            <if test="status != null">#{status},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="cityPid != null">#{cityPid},</if>
            <if test="cityIds != null">#{cityIds},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="updatedAt != null">#{updatedAt},</if>
            <if test="deletedAt != null">#{deletedAt},</if>
         </trim>
    </insert>

    <update id="updateWorkerApply" parameterType="WorkerApply">
        update worker_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="uid != null">uid = #{uid},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="address != null and address != ''">address = #{address},</if>
            <if test="cardNo != null">card_no = #{cardNo},</if>
            <if test="skillId != null">skill_id = #{skillId},</if>
            <if test="cardAvatar != null">card_avatar = #{cardAvatar},</if>
            <if test="cardBadge != null">card_badge = #{cardBadge},</if>
            <if test="image != null">image = #{image},</if>
            <if test="skill != null">skill = #{skill},</if>
            <if test="criminal != null">criminal = #{criminal},</if>
            <if test="health != null">health = #{health},</if>
            <if test="education != null">education = #{education},</if>
            <if test="drive != null">drive = #{drive},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="cityPid != null">city_pid = #{cityPid},</if>
            <if test="cityIds != null">city_ids = #{cityIds},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
            <if test="updatedAt != null">updated_at = #{updatedAt},</if>
            <if test="deletedAt != null">deleted_at = #{deletedAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWorkerApplyById" parameterType="Long">
        delete from worker_apply where id = #{id}
    </delete>

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