<?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.ltgk.boat.mapper.DsBoatBlackWhiteMapper">
    <resultMap id="BaseResultMap" type="com.ltgk.boat.domain.entity.DsBoatBlackWhite">
        <!--@mbg.generated-->
        <!--@Table ds_boat_black_white-->
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <result column="boat_id" jdbcType="VARCHAR" property="boatId"/>
        <result column="boat_name" jdbcType="VARCHAR" property="boatName"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
        <result column="create_at" jdbcType="TIMESTAMP" property="createAt"/>
        <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
        <result column="update_at" jdbcType="TIMESTAMP" property="updateAt"/>
        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
        <result column="reason" jdbcType="VARCHAR" property="reason"/>
        <result column="remove_time" jdbcType="TIMESTAMP" property="removeTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, boat_id, boat_name, del_flag, create_by, create_at, remarks, update_at, update_by,
        `type`, reason, remove_time
    </sql>

    <select id="getBlackWhiteList" resultType="com.ltgk.boat.domain.vo.DsBoatBlackWhiteVo">
        select dbbw.id,dbbw.boat_id as boatId,dbbw.boat_name as boatName,dba.boat_type as boatType,
        dbbw.type,dbbw.reason,dbbw.reason_type as reasonType, dbd.device_type as deviceType,dbd.mmsi as
        deviceCode,ddn.gps_time as gpsTime, dbd.mmsi AS terminalCode,
        dba.holder_name AS holderName, dba.holder_phone AS holderPhone, dba.area_name as areaName
        from ds_boat_black_white as dbbw
        left join ds_boat_data as dba on dbbw.boat_id = dba.boat_id
        left join ds_boat_device as dbd on dbbw.boat_id = dbd.boat_id and dbd.device_type = 'AIS'
        left join ds_dynamic_new as ddn on dbbw.boat_id = ddn.boat_id
        where 1=1
        <if test="boatName != null and boatName != ''">
            and dbbw.boat_name like concat('%',#{boatName},'%')
        </if>
        <if test="boatType != null and boatType != ''">
            and dba.boat_type = #{boatType}
        </if>
        <if test="type != null and type != ''">
            and dbbw.type = #{type}
        </if>
        ORDER BY dbbw.create_at DESC
    </select>
</mapper>