<?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.web.work.mapper.CompanyMapper">
    
    <select id="selectList" resultType="com.ruoyi.web.work.domain.Company">
        SELECT
        c.id,
        c.company_name,
        c.director,
        c.money,
        c.phone,
        c.create_time,
        c.state,
        ( SELECT COUNT( r.id ) FROM tb_relate r WHERE r.company_id = c.id ) AS peoples
        FROM
        tb_company c
        <where>  
            <if test="companyName != null  and companyName != ''"> and c.company_name like concat('%', #{companyName}, '%')</if>
            <if test="director != null  and director != ''"> and c.director like concat('%', #{director}, '%')</if>
            <if test="phone != null  and phone != ''"> and c.phone = #{phone}</if>
            <if test="state != null "> and c.state = #{state}</if>
            <if test="dateBegin != null  and dateBegin != ''"> AND c.create_time BETWEEN #{dateBegin} AND #{dateEnd} + INTERVAL 1 DAY</if>
        </where>
    </select>

</mapper>