<?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.sqx.modules.resumes.dao.ViewResumesDao">

    <select id="selectResumesByCompanyId" resultType="com.sqx.modules.resumes.entity.ViewResumes">
        select a.* from (
        select * from view_resumes
        where company_id=#{companyId}
                      ) a
        left join resumes r on r.resumes_id=a.resumes_id
        where r.resumes_id is not null and r.status=2
        order by a.create_time desc
    </select>
    <select id="getUseCount" resultType="java.lang.Integer">
        select count(*)
        from view_resumes v
        where v.company_id = #{companyId}
          and date_format(v.create_time, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
    </select>

    <select id="getViewResumesList" resultType="com.sqx.modules.resumes.vo.ViewResumesVo">
        SELECT
            r.`resumes_id`,
            r.`user_id`,
            v.`company_id`,
            IFNULL(r.resumes_name,"简历已删除") AS resumes_name,
            ifnull(u.user_name,"用户已删除") as user_name,
            r.resumes_sex,
            r.resumes_age,
            r.resumes_phone,
            r.resumes_education,
            v.pay_type,
            v.pay_money,
            v.create_time
        FROM view_resumes v
                 LEFT JOIN resumes r ON v.resumes_id = r.resumes_id
        left join tb_user u on u.user_id = r.user_id
        WHERE v.`company_id` = #{companyId}
        ORDER BY v.create_time DESC
    </select>


</mapper>