package link.at17.mid.tushare.data;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import link.at17.mid.tushare.dao.StockDailyDao;
import link.at17.mid.tushare.data.crawler.QueryWay;
import link.at17.mid.tushare.data.crawler.tushare.TushareCrawler;
import link.at17.mid.tushare.data.service.StockAdjustService;
import link.at17.mid.tushare.data.service.StockCalendarService;
import link.at17.mid.tushare.data.service.StockDailyBasicService;
import link.at17.mid.tushare.data.service.StockDailyService;
import link.at17.mid.tushare.data.service.StockInfoService;
import link.at17.mid.tushare.data.service.ThsDailyService;
import lombok.extern.slf4j.Slf4j;

@SpringBootTest
@Slf4j
class UpdateDataCrossCheck {

    @Autowired
    TushareCrawler tushareCrawler;
    
    @Autowired
    StockDailyDao stockDailyDao;
    
    @Autowired
    StockInfoService stockInfoService;
    
    @Autowired
    StockCalendarService stockCalendarService;
    
    @Autowired
    StockDailyService stockDailyService;
    
    @Autowired
    StockAdjustService stockAdjustService;
    
    @Autowired
    StockDailyBasicService stockDailyBasicService;
    
    @Autowired
    ThsDailyService thsDailyService;
    
    
    @Test
    void testStockListUpdate() {

        stockCalendarService.updateData();
        
        stockInfoService.updateData();
        stockDailyService.updateData(QueryWay.ByStockCrossCheck);
        stockDailyBasicService.updateData(QueryWay.ByStockCrossCheck);
        stockAdjustService.updateData(QueryWay.ByStockCrossCheck);
        
        thsDailyService.updateData(QueryWay.ByStockCrossCheck);
        //tushareCrawler.updateStockMinValue(QueryWay.ByStockCrossCheck, StockSpan.SixtyMinute);
        //tushareCrawler.updateStockMinValue(QueryWay.ByStockCrossCheck, StockSpan.Minute);
        //tushareCrawler.updateThsMember();
        //tushareCrawler.updateStockHolder(StockHolderType.TOP10Float);
        
        // 2022-02-11 高级 token 失效了，daily_basic 接口和 ths 相关接口用不了了
        // 2022-02-12 添加自己的高级 token
        //List<StockInfo> stockList = stockInfoDao.getStockListByListStatus(ListStatus.LIST);
        //kaipanlaCrawler.rollingQueryByStock(KaipanlaIndexType.BID_VOL, StockSpan.Daily, stockList, 630L, QueryWay.ByStock);
    }

}
