<?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.gxwebsoft.oa.mapper.OaCompanyMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM oa_company a
        <where>
            <if test="param.companyId != null">
                AND a.company_id = #{param.companyId}
            </if>
            <if test="param.shortName != null">
                AND a.short_name LIKE CONCAT('%', #{param.shortName}, '%')
            </if>
            <if test="param.companyName != null">
                AND a.company_name LIKE CONCAT('%', #{param.companyName}, '%')
            </if>
            <if test="param.companyCode != null">
                AND a.company_code LIKE CONCAT('%', #{param.companyCode}, '%')
            </if>
            <if test="param.companyType != null">
                AND a.company_type LIKE CONCAT('%', #{param.companyType}, '%')
            </if>
            <if test="param.companyTypeMultiple != null">
                AND a.company_type_multiple LIKE CONCAT('%', #{param.companyTypeMultiple}, '%')
            </if>
            <if test="param.companyLogo != null">
                AND a.company_logo LIKE CONCAT('%', #{param.companyLogo}, '%')
            </if>
            <if test="param.appType != null">
                AND a.app_type LIKE CONCAT('%', #{param.appType}, '%')
            </if>
            <if test="param.domain != null">
                AND a.domain LIKE CONCAT('%', #{param.domain}, '%')
            </if>
            <if test="param.phone != null">
                AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
            </if>
            <if test="param.tel != null">
                AND a.tel LIKE CONCAT('%', #{param.tel}, '%')
            </if>
            <if test="param.email != null">
                AND a.email LIKE CONCAT('%', #{param.email}, '%')
            </if>
            <if test="param.invoiceHeader != null">
                AND a.Invoice_header LIKE CONCAT('%', #{param.invoiceHeader}, '%')
            </if>
            <if test="param.businessEntity != null">
                AND a.business_entity LIKE CONCAT('%', #{param.businessEntity}, '%')
            </if>
            <if test="param.startTime != null">
                AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
            </if>
            <if test="param.expirationTime != null">
                AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
            </if>
            <if test="param.version != null">
                AND a.version = #{param.version}
            </if>
            <if test="param.members != null">
                AND a.members = #{param.members}
            </if>
            <if test="param.users != null">
                AND a.users = #{param.users}
            </if>
            <if test="param.industryParent != null">
                AND a.industry_parent LIKE CONCAT('%', #{param.industryParent}, '%')
            </if>
            <if test="param.industryChild != null">
                AND a.industry_child LIKE CONCAT('%', #{param.industryChild}, '%')
            </if>
            <if test="param.departments != null">
                AND a.departments = #{param.departments}
            </if>
            <if test="param.storage != null">
                AND a.storage LIKE CONCAT('%', #{param.storage}, '%')
            </if>
            <if test="param.storageMax != null">
                AND a.storage_max LIKE CONCAT('%', #{param.storageMax}, '%')
            </if>
            <if test="param.country != null">
                AND a.country LIKE CONCAT('%', #{param.country}, '%')
            </if>
            <if test="param.province != null">
                AND a.province LIKE CONCAT('%', #{param.province}, '%')
            </if>
            <if test="param.city != null">
                AND a.city LIKE CONCAT('%', #{param.city}, '%')
            </if>
            <if test="param.region != null">
                AND a.region LIKE CONCAT('%', #{param.region}, '%')
            </if>
            <if test="param.address != null">
                AND a.address LIKE CONCAT('%', #{param.address}, '%')
            </if>
            <if test="param.longitude != null">
                AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
            </if>
            <if test="param.latitude != null">
                AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.authentication != null">
                AND a.authentication = #{param.authentication}
            </if>
            <if test="param.authoritative != null">
                AND a.authoritative = #{param.authoritative}
            </if>
            <if test="param.requestUrl != null">
                AND a.request_url LIKE CONCAT('%', #{param.requestUrl}, '%')
            </if>
            <if test="param.socketUrl != null">
                AND a.socket_url LIKE CONCAT('%', #{param.socketUrl}, '%')
            </if>
            <if test="param.serverUrl != null">
                AND a.server_url LIKE CONCAT('%', #{param.serverUrl}, '%')
            </if>
            <if test="param.modulesUrl != null">
                AND a.modules_url LIKE CONCAT('%', #{param.modulesUrl}, '%')
            </if>
            <if test="param.recommend != null">
                AND a.recommend = #{param.recommend}
            </if>
            <if test="param.likes != null">
                AND a.likes = #{param.likes}
            </if>
            <if test="param.clicks != null">
                AND a.clicks = #{param.clicks}
            </if>
            <if test="param.buys != null">
                AND a.buys = #{param.buys}
            </if>
            <if test="param.isTax != null">
                AND a.is_tax = #{param.isTax}
            </if>
            <if test="param.planId != null">
                AND a.plan_id = #{param.planId}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.OaCompany">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.oa.entity.OaCompany">
        <include refid="selectSql"></include>
    </select>

</mapper>
