<?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.DsBoatCredentialMapper">
    <select id="getBoatCredentialList" resultType="com.ltgk.boat.domain.vo.DsBoatCredentialVO">
        SELECT bd.boat_name as boatName,
        bd.main_power as mainPower,
        bd.holder_name as holderName,
        bd.holder_phone as holderPhone,
        bc.id as id,
        bc.type as type,
        bc.code as code,
        bc.issue_authority as issueAuthority,
        bc.issue_date as issueDate,
        bc.file as file,
        bc.status as status,
        bc.remark as remark,
        bc.credential_start_time as credentialStartTime,
        bc.credential_end_time as credentialEndTime,
        bc.create_by as createBy,
        bc.update_by as updateBy,
        bc.update_at as updateAt,
        bc.create_at as createAt
        from ds_boat_data bd left JOIN ds_boat_credential bc
        on bd.boat_name = bc.boat_name
        where bd.del_flag = 0 and bc.del_flag = 0
        <if test="getBoatCredentialListReq.type != null and getBoatCredentialListReq.type != ''">
            and bc.type = #{getBoatCredentialListReq.type}
        </if>
        <if test="getBoatCredentialListReq.status != null and getBoatCredentialListReq.status != ''">
            AND bc.status = #{getBoatCredentialListReq.status}
        </if>
        <if test="getBoatCredentialListReq.boatName != null and getBoatCredentialListReq.boatName != ''">
            AND bd.boat_name like concat('%',#{getBoatCredentialListReq.boatName},'%')
        </if>
        <if test="getBoatCredentialListReq.startTime != null and getBoatCredentialListReq.startTime != ''">
            and bc.issue_date &gt;= #{getBoatCredentialListReq.startTime}
        </if>
        <if test="getBoatCredentialListReq.endTime != null and getBoatCredentialListReq.endTime != ''">
            and bc.issue_date &lt;= #{getBoatCredentialListReq.endTime}
        </if>
        ORDER BY bd.boat_name
    </select>
</mapper>