<?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.huatek.busi.mapper.BusiSiteMapper">

    <sql id="Base_Column_List">
            id,
            site_name as siteName,
            site_address as siteAddress,
            create_time as createTime,
            latitude as latitude,
            id as id,
            create_user as createUser,
            org_code as orgCode,
            longitude as longitude,
            status as status,
            create_name as createName
    </sql>


   <select id="queryAllSite" resultType="com.huatek.busi.vo.BusiSiteVo">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        busi_site where `status` = 1
    </select>
    
    
    <select id="selectBusiSitePage" parameterType="com.huatek.busi.dto.BusiSiteDto" resultType="com.huatek.busi.vo.BusiSiteVo">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        busi_site t
        WHERE 1=1
        <if test="siteName != null and siteName != ''">
             and t.site_name = #{siteName}
        </if>
        <if test="siteAddress != null and siteAddress != ''">
             and t.site_address = #{siteAddress}
        </if>
        <if test="createTime != null">
             and t.create_time = #{createTime}
        </if>
        <if test="latitude != null and latitude != ''">
             and t.latitude = #{latitude}
        </if>
        <if test="id != null and id != ''">
             and t.id = #{id}
        </if>
        <if test="createUser != null">
             and t.create_user = #{createUser}
        </if>
        <if test="orgCode != null and orgCode != ''">
             and t.org_code = #{orgCode}
        </if>
        <if test="longitude != null and longitude != ''">
             and t.longitude = #{longitude}
        </if>
        <if test="status != null and status != ''">
             and t.status = #{status}
        </if>
        <if test="createName != null and createName != ''">
             and t.create_name = #{createName}
        </if>
    </select>
	<select id="getSiteInfo" resultType="com.huatek.busi.vo.BusiSiteVo">
        SELECT
        	<include refid="Base_Column_List"/>
        FROM
        	busi_site t
        WHERE t.status = '1' 
  		AND t.id <![CDATA[ <> ]]> '1' 
  		ORDER BY t.`create_time` 
  		LIMIT 1
    </select>

    <select id="findBySiteName" parameterType="java.lang.String" resultType="com.huatek.busi.dto.BusiSiteDto">
        SELECT
            *
        FROM
            busi_site
        WHERE
            `status` = 1
        AND site_name = #{siteName}
    </select>

    <select id="findAll" resultType="com.huatek.busi.dto.BusiSiteDto">
        SELECT
            <include refid="Base_Column_List"/>
        FROM
            busi_site
        WHERE
            `status` = 1;
    </select>

    <select id="findSiteInfo" resultType="com.huatek.busi.vo.BusiSiteVo">
    SELECT
        id,
        site_name as siteName,
        longitude,
        latitude
    FROM
        `busi_site`;
    </select>

</mapper>