<?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.JobApplyMapper">

    <resultMap type="JobApply" id="JobApplyResult">
        <result property="id"    column="id"    />
        <result property="jobId"    column="job_id"    />
        <result property="userId"    column="user_id"    />
        <result property="matchingDegree"    column="matching_degree"    />
        <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="selectJobApplyVo">
        select id, job_id, user_id, matching_degree, del_flag, create_by, create_time, update_by, update_time, remark from job_apply
    </sql>

    <select id="selectJobApplyList" parameterType="JobApply" resultMap="JobApplyResult">
        <include refid="selectJobApplyVo"/>
        <where>  del_flag = '0'
            <if test="jobId != null "> and job_id = #{jobId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="matchingDegree != null "> and matching_degree = #{matchingDegree}</if>
        </where>
    </select>
    <select id="applyJob" resultType="com.ruoyi.cms.domain.Job">
        SELECT ja.create_time AS applyTime, j.*
        FROM job j
                 INNER JOIN job_apply ja ON j.job_id = ja.job_id
        WHERE j.del_flag = '0'
          AND j.is_publish = 1
          AND ja.del_flag = '0'
          AND ja.user_id = #{userId}
        ORDER BY ja.create_time DESC
    </select>
    <select id="candidates" resultType="com.ruoyi.cms.domain.vo.CandidateVO">
        SELECT au.*,jc.create_time as apply_date,jc.matching_degree
        from job_apply as jc
                 inner join app_user as au on jc.user_id = au.user_id
        where jc.job_id = #{jobId} and jc.del_flag = '0' and au.del_flag ='0'
    </select>

</mapper>