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

    <select id="selectCompanyList" resultType="com.sqx.modules.resumes.entity.Company">
        select c.*,u.user_name as userName,u.phone from company c
        left join tb_user u on u.user_id=c.user_id
        where 1=1
        <if test="companyName!=null and companyName!=''">
            and c.company_name like concat('%',#{companyName},'%')
        </if>
        <if test="companyPhone!=null and companyPhone!=''">
            and u.phone like concat('%',#{companyPhone},'%')
        </if>
        <if test="userName!=null and userName!=''">
            and u.user_name like concat('%',#{userName},'%')
        </if>
        <if test="status!=null and status!=0">
            and c.status = #{status}
        </if>
        <if test="startTime!=null and startTime!='' and startTime!=null and startTime!=''">
            and date_format(c.create_time,'%Y-%m-%d') BETWEEN #{startTime} and #{endTime}
        </if>
        <if test="startTime!=null and startTime!='' and  (endTime==null or endTime=='')">
            and date_format(c.create_time,'%Y-%m-%d') &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!='' and (startTime==null or startTime=='')">
            and date_format(c.create_time,'%Y-%m-%d') &lt;= #{endTime}
        </if>
        order by c.update_time desc
    </select>

    <select id="selectCompanyListByMember" resultType="com.sqx.modules.resumes.entity.Company">
        select *
        from company c
        where status = 2
          and user_id in (select user_id from tb_user where member = 2)
        order by c.create_time desc
    </select>
    <select id="selectCompanyByCompanyId" resultType="com.sqx.modules.resumes.entity.Company">
        select *
        from company c
        where c.company_id = #{companyId}
    </select>
    <select id="exportExcelCompanyList" resultType="com.sqx.modules.resumes.entity.Company">
        select c.*,u.user_name as userName,u.phone from company c
        left join tb_user u on u.user_id=c.user_id
        where 1=1
        <if test="companyName!=null and companyName!=''">
            and c.company_name like concat('%',#{companyName},'%')
        </if>
        <if test="companyPhone!=null and companyPhone!=''">
            and u.phone like concat('%',#{companyPhone},'%')
        </if>
        <if test="userName!=null and userName!=''">
            and u.user_name like concat('%',#{userName},'%')
        </if>
        <if test="status!=null and status!=0">
            and c.status = #{status}
        </if>
        <if test="startTime!=null and startTime!='' and startTime!=null and startTime!=''">
            and date_format(c.create_time,'%Y-%m-%d') BETWEEN #{startTime} and #{endTime}
        </if>
        <if test="startTime!=null and startTime!='' and  (endTime==null or endTime=='')">
            and date_format(c.create_time,'%Y-%m-%d') &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!='' and (startTime==null or startTime=='')">
            and date_format(c.create_time,'%Y-%m-%d') &lt;= #{endTime}
        </if>
        order by c.update_time desc


    </select>


</mapper>