<?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.zhongzheng.modules.recruit.mapper.RecruitTemplateMapper">

    <resultMap type="com.zhongzheng.modules.recruit.domain.RecruitTemplate" id="RecruitTemplateResult">
        <result property="id" column="id"/>
        <result property="companyId" column="company_id"/>
        <result property="job" column="job"/>
        <result property="incomeStart" column="income_start"/>
        <result property="incomeEnd" column="income_end"/>
        <result property="duty" column="duty"/>
        <result property="requirement" column="requirement"/>
        <result property="welfare" column="welfare"/>
        <result property="jobKey" column="job_key"/>
        <result property="workingYearsDict" column="working_years_dict"/>
        <result property="workingYearsStart" column="working_years_start"/>
        <result property="workingYearsEnd" column="working_years_end"/>
        <result property="minimumEduDict" column="minimum_edu_dict"/>
        <result property="major" column="major"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="status" column="status"/>
        <result property="incomeType" column="income_type"/>
        <result property="minimumEduLabel" column="minimum_edu_label"/>
        <result property="workingYearsLabel" column="working_years_label"/>
        <result property="companyName" column="company_name"/>
    </resultMap>

    <select id="queryRecruitTemplateList" parameterType="com.zhongzheng.modules.recruit.bo.RecruitTemplateQueryBo"  resultMap="RecruitTemplateResult">
        SELECT
        rt.*,
        dd.dict_label AS minimum_edu_label,
        dd1.dict_label AS working_years_label,
        vtc.company_name
        FROM
        recruit_template rt
        LEFT JOIN sys_dict_data dd ON rt.minimum_edu_dict = dd.dict_code
        LEFT JOIN sys_dict_data dd1 ON rt.working_years_dict = dd1.dict_code
        LEFT JOIN v_tenant_company vtc ON rt.company_id = vtc.company_id
        WHERE
        1 = 1
        <if test="job != null and job != ''">
            AND rt.job like concat('%', #{job}, '%')
        </if>
        <if test="companyName != null and companyName != ''">
            AND vtc.company_name like concat('%', #{companyName}, '%')
        </if>
        <if test="status != null and status.size()!=0 ">
            AND rt.status in
            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        ORDER BY
        rt.id DESC
    </select>

</mapper>
