<?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.cms.mapper.JobContactMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="JobContact" id="jobContactResult">
        <result property="id" column="id"/>
        <result property="jobId" column="job_id"/>
        <result property="contactPerson" column="contact_person"/>
        <result property="contactPersonPhone" column="contact_person_phone"/>
        <result property="position" column="position"/>
        <result property="delFlag" column="del_flag"/>
        <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="JobContactVo">
        select id, job_id, contact_person, contact_person_phone, position, del_flag, create_by, create_time, update_by, update_time, remark from job_contact
    </sql>


    <select id="getSelectList" resultMap="jobContactResult" parameterType="JobContact">
        <include refid="JobContactVo"/>
        <where> del_flag = '0'
            <if test="jobId!=null and jobId!='' ">
                and job_id=#{jobId}
            </if>
            <if test="contactPerson!=null and contactPerson!='' ">
                and contact_person=#{contactPerson}
            </if>
            <if test="contactPersonPhone!=null and contactPersonPhone!='' ">
                and contact_person_phone=#{contactPersonPhone}
            </if>
            <if test="position!=null and position!='' ">
                and position=#{position}
            </if>
        </where>
    </select>

    <insert id="batchInsert" parameterType="java.util.List">
        INSERT INTO job_contact (
        job_id, contact_person, contact_person_phone,position,
        create_by, create_time, del_flag,remark
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.jobId}, #{item.contactPerson}, #{item.contactPersonPhone},#{item.position},
            #{item.createBy}, #{item.createTime}, #{item.delFlag},#{item.remark}
            )
        </foreach>
    </insert>

    <select id="selectByJobIds" parameterType="java.util.List" resultMap="jobContactResult">
        <include refid="JobContactVo"/>
        <where> del_flag = '0'
            <if test="jobIds != null and jobIds.size() > 0">
                AND job_id IN (
                <foreach collection="jobIds" item="jobId" separator=",">
                    <if test="jobId != null">
                        #{jobId}
                    </if>
                </foreach>
                )
            </if>
            <if test="jobIds == null or jobIds.size() == 0">
                AND 1 = 0
            </if>
        </where>
    </select>

</mapper>
