import APP from '@/services';
import { commonSearch_go } from '../index';
import * as type from './interface';
/**
 * 查询行情历史数据
 * @param param QueryHistoryDatas
 * @returns QueryHistoryDatasRsp
 */
export function QueryHistoryDatas(param: type.QueryHistoryDatas): Promise<type.QueryHistoryDatasRsp> {
    return commonSearch_go('/Quote/QueryHistoryDatas', param)
}

/**
 * 查询行情Tik数据
 * @param param QueryHistoryTikDatas
 * @returns QueryHistoryTikDatasRsp
 */
export function QueryHistoryTikDatas(param: type.QueryHistoryTikDatas): Promise<type.QueryHistoryTikDatasRsp[]> {
    return commonSearch_go('/Quote/QueryHistoryTikDatas', param)
}

/**
 * 获取商品盘面信息
 * @param goodsCodes 商品代码列表，格式：CU2102,CU2103,AL2107
 * @returns QueryQuoteDay
 */
export function QueryQuoteDay(goodsCodes: string): Promise<string> {
    return commonSearch_go('/Quote/QueryQuoteDay', { goodsCodes }).then(res => {
        APP.set('quoteDayInfo', res)
        return 'ok'
    }).catch(err => { throw new Error(`获取商品盘面信息失败：${err}`) })
}

/**
 * 分时图数据查询
 * @param goodsCodes 商品代码
 * @returns
 */
export function QueryTSData(goodsCodes: string): Promise<type.QueryTSDataRsp> {
    return commonSearch_go('/Quote/QueryTSData', { goodsCodes })
}
