package link.at17.mid.tushare.dao;

import com.alibaba.fastjson2.JSONObject;
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.cache.EvictAfterUpdate;
import link.at17.mid.tushare.data.models.StockHolder;
import link.at17.mid.tushare.data.models.interfaces.ITsTradeDate;
import link.at17.mid.tushare.enums.StockHolderType;

import org.apache.ibatis.annotations.Mapper;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface StockHolderDao extends MPJBaseMapper<StockHolder>, ITsTradeDate {
    @BatchInsert
    int insertOrUpdateList(@BatchList List<JSONObject> list, @NonNull StockHolderType holderType);

    @EvictAfterUpdate("tushare")
    @Cacheable("stockHolderDao.getAllByStockCode")
    List<StockHolder> getAllByStockCode(@NonNull String stockCode, @NonNull StockHolderType holderType);
}
