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.QueryTargetListDTO;
import com.base.biz.model.dto.request.QueryTargetPointBatchDTO;
import com.base.biz.model.dto.response.TargetPointDTO;
import com.base.biz.model.entity.SceneTargetPoint;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 目标顶点信息 Mapper 接口
 * </p>
 *
 * @author cxl
 * @since 2022-02-24
 */
@Mapper
@Repository
public interface SceneTargetPointMapper extends BaseMapper<SceneTargetPoint> {

    /**
     * 批量导入
     * @param list
     */
    void batch(@Param("list") List<QueryTargetPointBatchDTO> list);

    /**
     * 根据目标id,查询点列表
     * @param targetId 目标id
     * @return 点列表
     */
    default List<SceneTargetPoint> getPointListByTargetId(String targetId){
        return this.selectList(new QueryWrapper<SceneTargetPoint>().eq("target_id",targetId));
    };

    /**
     * 根据目标id,查询点列表
     * @param targetIds 目标id
     * @return 点列表
     */
    default List<SceneTargetPoint> getPointListByTargetIds(Set<String> targetIds){
        return this.selectList(new QueryWrapper<SceneTargetPoint>().in("target_id",targetIds).orderByAsc("sequence"));
    };

    List<TargetPointDTO> getTargetPointDTO(@Param("req") QueryTargetListDTO queryTargetListDTO);

    List<TargetPointDTO> getTargetByVo(@Param("req") QueryTargetListDTO queryTargetListDTO);

}
