<?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.xhpc.system.mapper.XhpcDataDimensionMapper">

    <resultMap type="com.xhpc.system.domain.XhpcDataDimension" id="XhpcDataDimensionResult">
        <id property="dataDimensionId" column="data_dimension_id"/>
        <result property="userId" column="user_id"/>
        <result property="chargingStationId" column="charging_station_id"/>
        <result property="status"         column="status"         />
        <result property="createBy"       column="create_by"      />
        <result property="createTime"     column="create_time"    />
        <result property="updateTime"     column="update_time"    />
        <result property="updateBy"       column="update_by"      />
        <result property="remark"         column="remark"         />
        <result property="delFlag"         column="del_flag"         />

    </resultMap>


    <select id="selectByUserId" resultType="Integer">
        select charging_station_id
        from xhpc_data_dimension
        where user_id = #{userId} and status=0 and del_flag=0
        order by charging_station_id
    </select>

    <select id="buildMenuTreeSelect" resultType="map">
       SELECT
            concat("9999",opn.operator_id) operatorId,
            opn.name as operatorName,
            (select group_concat(charging_station_id) from xhpc_charging_station where operator_id=opn.operator_id and del_flag =0) chargingStationId,
            (select group_concat(name) from xhpc_charging_station where operator_id=opn.operator_id and del_flag =0) chargingStationName
        FROM
            xhpc_operator as opn
        WHERE
            opn.del_flag = 0
        ORDER BY operator_id desc
    </select>
    
    

</mapper>
