package com.gyee.alarm.mapper.auto;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gyee.alarm.model.auto.ProEconEarlyReport;
import com.gyee.alarm.model.auto.ProEconEarlyReportWt;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 设备预警报告 Mapper 接口
 * </p>
 *
 * @author shilin
 * @since 2023-09-05
 */
public interface ProEconEarlyReportWtMapper extends BaseMapper<ProEconEarlyReportWt> {

    @Select("select * from pro_econ_early_report_wt where report_id=#{reportId}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(
                    property = "alarmInfoList",
                    column = "id",
                    javaType = List.class,
                    many = @Many(select = "com.gyee.alarm.mapper.auto.ProEconEarlyReportAlarmMapper.findByWindturbineReportId")
            )})
    List<ProEconEarlyReportWt> findByReportId(@Param("reportId")String reportId);

    @Select("<script>select * from pro_econ_early_report_wt where ID in <foreach item='item' index='index' collection='idList'  open='(' separator=',' close=')'>#{item} </foreach></script>")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(
                    property = "alarmInfoList",
                    column = "id",
                    javaType = List.class,
                    many = @Many(select = "com.gyee.alarm.mapper.auto.ProEconEarlyReportAlarmMapper.findByWindturbineReportId")
            ),
            @Result(
                    property = "earlyReport",
                    column = "report_id",
                    javaType = ProEconEarlyReport.class,
                    one = @One(select = "com.gyee.alarm.mapper.auto.ProEconEarlyReportMapper.selectById")
            )
    })
    List<ProEconEarlyReportWt> findByIds(@Param("idList") List<String> idList);

    @Select("<script>select * from pro_econ_early_report_wt where report_id in <foreach item='item' index='index' collection='reportIdList'  open='(' separator=',' close=')'>#{item} </foreach></script>")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(
                    property = "alarmInfoList",
                    column = "id",
                    javaType = List.class,
                    many = @Many(select = "com.gyee.alarm.mapper.auto.ProEconEarlyReportAlarmMapper.findByWindturbineReportId")
            ),
            @Result(
                    property = "earlyReport",
                    column = "report_id",
                    javaType = ProEconEarlyReport.class,
                    one = @One(select = "com.gyee.alarm.mapper.auto.ProEconEarlyReportMapper.selectById")
            )
    })
    List<ProEconEarlyReportWt> findByReportIds(@Param("reportIdList") List<String> reportIdList);

}
