package link.at17.mid.tushare.dao;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.base.MPJBaseMapper;

import link.at17.mid.tushare.annotation.BatchInsert;
import link.at17.mid.tushare.annotation.BatchList;
import link.at17.mid.tushare.data.models.ThsStockInfo;
import link.at17.mid.tushare.enums.ThsStockMarket;

import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface ThsListDao extends MPJBaseMapper<ThsStockInfo> {
    @BatchInsert
    int insertOrUpdateList(@BatchList List<JSONObject> list);
    default List<ThsStockInfo> listByExchange(ThsStockMarket exchange){
        return selectList(new LambdaQueryWrapper<ThsStockInfo>().eq(exchange != null, ThsStockInfo::getExchange, exchange));
    }
}