package com.friday.executor.common;

import com.friday.base.common.response.DubboResult;
import com.friday.mystery.toolkitapi.service.ITradingDayService;
import com.friday.operation.api.executor.service.ITradeDayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author YaoYao
 * @Date Created In 13:57 2023/4/4
 * @Description 资讯接口服务
 * @Modified By
 */
@Service
@Slf4j
public class TradingDayHelper implements ITradeDayService {
    @Autowired(required = false)
    private ITradingDayService tradingDayService;


    @Override
    public DubboResult checkCurrentDate(String type) {
        DubboResult result = tradingDayService.checkCurrentDate(type);
        if(result.success()){
            return DubboResult.newSuccess(result.getObject());
        }
        return DubboResult.newFailure(DubboResult.SERVER_EXCEPTION, result.getMessage());
    }

    @Override
    public DubboResult checkCurrentDateAndAdjacent(String type) {
        DubboResult result = tradingDayService.checkCurrentDateAndAdjacent(type);
        if(result.success()){
            return DubboResult.newSuccess(result.getObject());
        }
        return DubboResult.newFailure(DubboResult.SERVER_EXCEPTION, result.getMessage());
    }

    @Override
    public DubboResult checkSpecifiedDate(String date, String type) {
        DubboResult result = tradingDayService.checkSpecifiedDate(date, type);
        if(result.success()){
            return DubboResult.newSuccess(result.getObject());
        }
        return DubboResult.newFailure(DubboResult.SERVER_EXCEPTION, result.getMessage());
    }

    @Override
    public DubboResult getRangeOfTradingDay(String dateStart, String dateEnd, String type) {
        DubboResult result = tradingDayService.getRangeOfTradingDay(dateStart, dateEnd, type);
        if(result.success()){
            return DubboResult.newSuccess(result.getObject());
        }
        return DubboResult.newFailure(DubboResult.SERVER_EXCEPTION, result.getMessage());
    }

//    @Override
//    public DubboResult getTradingDate(String date, String type, int index) {
//        DubboResult result = tradingDayService.getTradingDate(date, type, index);
//        if(result.success()){
//            return DubboResult.newSuccess(result.getObject());
//        }
//        return DubboResult.newFailure(DubboResult.SERVER_EXCEPTION, result.getMessage());
//    }
}
