<?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.base.biz.mapper.SatelliteInfoMapper">

    <resultMap id="satellitePayloadDTOResMap" type="com.base.biz.model.dto.response.SatellitePayloadDTO">
        <id column="id" property="id"/>
        <result column="satellite_code" property="satelliteCode"/>
        <result column="satellite_name" property="satelliteName"/>
        <result column="payload_type" property="payloadType"/>
        <result column="ground_resolution" property="groundResolution"/>
        <result column="swath_width" property="swathWidth"/>
    </resultMap>

    <select id="getSatelliteInfoDTOList" parameterType="com.base.biz.model.dto.request.SatelliteInfoDTOListReq"
            resultType="com.base.biz.model.entity.SatelliteInfo">
        select * from satellite_info
        <where>
            <if test="req.ids != null">
                req.ids in
                <foreach collection="req.ids" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.satelliteCode != null and req.satelliteCode != ''">
                and satellite_code like "%${req.satelliteCode}%"
            </if>
        </where>
        order by satellite_info.country desc
    </select>


    <!--     <select id="selectSatellitePayloadDTOList" resultType="com.base.biz.model.dto.response.SatellitePayloadDTO">
-->
    <select id="selectSatellitePayloadDTOList" resultMap="satellitePayloadDTOResMap">
        select yibs.id,yibs.satellite_code,yibs.satellite_name,yisp.payload_type,yibs.ground_resolution,yibs.swath_width
        from
        satellite_info yibs left join payload_info yisp on yibs.id = yisp.satellite_id
        <where>
            <if test="type != null">
                yisp.payload_type in
                <foreach collection="type" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>

            </if>
        </where>
    </select>
</mapper>
