<?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.user.mapper.XhpcStationInternetBlacklistMapper">

    <resultMap type="com.xhpc.user.domain.XhpcStationInternetBlacklist" id="XhpcStationInternetBlacklistResult">
        <result column="xhpc_station_internet_blacklist_id" property="xhpcStationInternetBlackId"/>
        <result column="internet_user_id" property="internetUserId"/>
        <result column="charging_station_id" property="chargingStationId" />
        <result column="operator_id_evcs" property="operatorIdEvcs" />
        <result column="status" property="status" />
        <result column="create_time" property="createTime" />
        <result column="create_by" property="createBy" />
        <result column="update_time" property="updateTime" />
        <result column="update_by" property="updateBy" />
        <result column="remark" property="remark" />
    </resultMap>


    <insert id="insert" parameterType="com.xhpc.user.domain.XhpcInternetUser" useGeneratedKeys="true"
            keyProperty="xhpcStationInternetBlackId">
        insert into xhpc_station_internet_blacklist
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="null != internetUserId and '' != internetUserId">
                internet_user_id,
            </if>
            <if test="null != chargingStationId and '' != chargingStationId">
                charging_station_id,
            </if>
            <if test="null != status and '' != status">
                status,
            </if>
            <if test="null != createTime">
                create_time,
            </if>
            <if test="null != createBy and '' != createBy">
                create_by,
            </if>
            <if test="null != updateTime">
                update_time,
            </if>
            <if test="null != updateBy and '' != updateBy">
                update_by,
            </if>
            <if test="null != remark and '' != remark">
                remark
            </if>
    </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="null != internetUserId and '' != internetUserId">
                #{internetUserId},
            </if>
            <if test="null != chargingStationId and '' != chargingStationId">
                #{chargingStationId},
            </if>
            <if test="null != status and '' != status">
                #{status},
            </if>
            <if test="null != createTime">
                #{createTime},
            </if>
            <if test="null != createBy and '' != createBy">
                #{createBy},
            </if>
            <if test="null != updateTime">
                #{updateTime},
            </if>
            <if test="null != updateBy and '' != updateBy">
                #{updateBy},
            </if>
            <if test="null != remark and '' != remark">
                #{remark}
            </if>
        </trim>
    </insert>

    <delete id="deleteByOperatorIdEvcs" parameterType="java.lang.String">
        delete
        from xhpc_station_internet_blacklist
        where internet_user_id = #{internetUserId}
    </delete>

    <update id="updateByOperatorIdEvcs">
        update xhpc_station_internet_blacklist set operator_id_evcs=#{operatorIdEvcs} where internet_user_id = #{internetUserId}
    </update>
    <select id="list" parameterType="java.lang.Long" resultType="java.util.Map">
        select
        internet_user_id internetUserId, charging_station_id chargingStationId
        from xhpc_station_internet_blacklist
        WHERE 1 = 1
        <if test="internetUserId != null and internetUserId != ''">
            and internet_user_id = #{internetUserId}
        </if>
    </select>

    <select id="getXhpcChargingStation" parameterType="java.lang.Long" resultType="java.util.Map">
        select
        charging_station_id chargingStationId, `name`,operator_id operatorId
        from xhpc_charging_station
        WHERE del_flag = 0
        <if test="operatorId != null and operatorId != ''">
            and operator_id = #{operatorId}
        </if>
    </select>
</mapper>
