package com.base.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.base.biz.model.dto.request.PayloadInfoDTOListReq;
import com.base.biz.model.dto.request.PayloadInfoDTOListReq2;
import com.base.biz.model.entity.PayloadInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PayloadInfoMapper extends BaseMapper<PayloadInfo> {

    public List<PayloadInfo> getPayloadInfoList(@Param("req") PayloadInfoDTOListReq2 req);

    @Select("<script> " +
            "        select * from payload_info\n" +
            "        <where>\n" +
            "            <if test=\"satelliteIdList != null\">\n" +
            "                satellite_id in\n" +
            "                <foreach collection=\"satelliteIdList\" index=\"index\" item=\"item\" open=\"(\" separator=\",\" close=\")\">\n" +
            "                    #{item}\n" +
            "                </foreach>\n" +
            "            </if>\n" +
            "        </where>" +
            "</script>")
    List<PayloadInfo> selectByStaelliteIdList(@Param("satelliteIdList") List<String> asList);

    void batch(List<PayloadInfo> list);

    @Delete("<script>delete from payload_info" +
            "        <where>\n" +
            "            <if test=\"satelliteIdList != null\">\n" +
            "                type in\n" +
            "                <foreach collection=\"satelliteIdList\" index=\"index\" item=\"item\" open=\"(\" separator=\",\" close=\")\">\n" +
            "                    #{item}\n" +
            "                </foreach>\n" +
            "            </if>\n" +
            "        </where>" +
            "</script>")
    void deleteBySatelliteId(@Param("satelliteIdList") List<String> satelliteIdList);
}
