<?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.PayloadInfoMapper">
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, staellite_id, name, type, payload_series, ground_resolution, swath_width, over_lap, min_sun_elevation, max_sun_elevation, fov, model, payload_status, create_date, create_by, last_modified_by, last_modified_date, version, status
    </sql>
    <insert id="batch" parameterType="com.base.biz.model.entity.PayloadInfo">
        insert into payload_info (<include refid="Base_Column_List"/>)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.id},
            #{item.staelliteId},
            #{item.name},
            #{item.type},
            #{item.payloadSeries},
            #{item.groundResolution},
            #{item.swathWidth},
            #{item.overLap},
            #{item.minSunElevation},
            #{item.maxSunElevation},
            #{item.fov},
            #{item.model},
            #{item.payloadStatus},
            #{item.createDate},
            #{item.createBy},
            #{item.lastModifiedBy},
            #{item.lastModifiedDate},
            #{item.version},
            #{item.status}
            )
        </foreach>
    </insert>

    <select id="getPayloadInfoList" parameterType="com.base.biz.model.dto.request.PayloadInfoDTOListReq2" resultType="com.base.biz.model.entity.PayloadInfo">
        select * from payload_info
        <where>
            <if test="req.ids != null and req.ids.size()>0">
                id in
                <foreach collection="req.ids" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.satelliteIds != null and req.satelliteIds.size()>0">
                and satellite_id in
                <foreach collection="req.satelliteIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.satelliteCodes != null and req.satelliteCodes.size()>0">
                and satellite_code in
                <foreach collection="req.satelliteCodes" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.payloadType != null and req.payloadType.size()>0">
                and payload_type in
                <foreach collection="req.payloadType" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.satelliteId != null and req.satelliteId != ''">
                and satellite_id = #{req.satelliteId}
            </if>
            <if test="req.satelliteCode != null and req.satelliteCode != ''">
                and satellite_code = #{req.satelliteCode}
            </if>
        </where>
    </select>

</mapper>
