<?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.njzscloud.supervisory.station.mapper.StationManageMapper">

    <select id="paging" resultType="com.njzscloud.supervisory.station.pojo.result.SearchStationManageResult">
        SELECT c.nickname,
        c.phone user_phone,
        b.uscc,
        b.company_name,
        b.business_license,
        b.license_start_time,
        b.license_end_time,
        b.legal_representative,
        b.province,
        b.city,
        b.area,
        b.town,
        b.province_name,
        b.city_name,
        b.area_name,
        b.town_name,
        b.address,
        b.lng,
        b.lat,
        b.contacts,
        b.phone
        FROM station_manage a
        INNER JOIN biz_company b ON b.id = a.station_id AND b.station = 1 AND b.deleted = 0
        INNER JOIN sys_user c ON c.id = a.user_id AND c.deleted = 0
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="myStation"
            resultType="com.njzscloud.supervisory.station.pojo.result.SearchStationManageResult">
        SELECT c.nickname,
        c.phone user_phone,
        b.uscc,
        b.company_name,
        b.business_license,
        b.license_start_time,
        b.license_end_time,
        b.legal_representative,
        b.province,
        b.city,
        b.area,
        b.town,
        b.province_name,
        b.city_name,
        b.area_name,
        b.town_name,
        b.address,
        b.lng,
        b.lat,
        b.contacts,
        b.phone,
        a.station_id,
        b.open,
        b.company_name station_name
        FROM station_manage a
        INNER JOIN biz_company b ON b.id = a.station_id AND b.station = 1 AND b.deleted = 0
        INNER JOIN sys_user c ON c.id = a.user_id AND c.deleted = 0
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="listManager"
            resultType="com.njzscloud.supervisory.station.pojo.result.SearchStationManageResult">
        SELECT b.nickname,
        b.phone user_phone,
        a.user_id
        FROM sys_user_role a
        INNER JOIN sys_user b ON b.id = a.user_id AND b.deleted = 0
        INNER JOIN sys_role c ON c.id = a.role_id AND c.deleted = 0
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="myManage" resultType="java.lang.Long">
        SELECT a.user_id
        FROM station_manage a
        INNER JOIN biz_company b ON b.id = a.station_id AND b.station = 1 AND b.deleted = 0
        INNER JOIN sys_user c ON c.id = a.user_id AND c.deleted = 0
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="adminStation"
            resultType="com.njzscloud.supervisory.station.pojo.result.SearchStationManageResult">
        SELECT c.nickname,
               c.phone        user_phone,
               b.uscc,
               b.company_name,
               b.business_license,
               b.license_start_time,
               b.license_end_time,
               b.legal_representative,
               b.province,
               b.city,
               b.area,
               b.town,
               b.province_name,
               b.city_name,
               b.area_name,
               b.town_name,
               b.address,
               b.lng,
               b.lat,
               b.contacts,
               b.open,
               b.phone,
               b.id           station_id,
               b.company_name station_name
        FROM biz_company b
                 INNER JOIN sys_user c ON c.id = 1 AND c.deleted = 0
        WHERE b.station = 1
          AND b.deleted = 0
    </select>
</mapper>
