package com.base.biz.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.base.biz.model.dto.request.SatelliteInfoDTOListReq;
import com.base.biz.model.dto.response.SatellitePayloadDTO;
import com.base.biz.model.entity.SatelliteInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Mapper
@Repository
public interface SatelliteInfoMapper extends BaseMapper<SatelliteInfo> {

    List<SatelliteInfo> getSatelliteInfoDTOList(@Param("req") SatelliteInfoDTOListReq req);

    default List<SatelliteInfo> listByIds(List<String> satelliteCodes){
        QueryWrapper<SatelliteInfo> queryWrapper=new QueryWrapper<>();
        if (!CollectionUtils.isEmpty(satelliteCodes)){
            queryWrapper.in("satellite_code",satelliteCodes);
        }
        return this.selectList(queryWrapper);
    }
    default List<SatelliteInfo> queryAllSatelliteByIds(List<String> satelliteids){
        QueryWrapper<SatelliteInfo> queryWrapper=new QueryWrapper<>();
        if (!CollectionUtils.isEmpty(satelliteids)){
            queryWrapper.in("id",satelliteids);
        }
        return this.selectList(queryWrapper);
    }
    default SatelliteInfo getSatelliteInfoByCode(String satelliteCode){
        QueryWrapper<SatelliteInfo> queryWrapper=new QueryWrapper<>();
        if (satelliteCode!=null){
            queryWrapper.eq("satellite_code",satelliteCode);
        }
        return this.selectOne(queryWrapper);
    }

    List<SatellitePayloadDTO> selectSatellitePayloadDTOList(@Param("type") List<String> list);
}
