package com.sifang.modules.monitor.ginlong;

import com.sifang.modules.monitor.ginlong.dto.addstation.AddStationR;
import com.sifang.modules.monitor.ginlong.dto.addstation.AddStationReq;
import com.sifang.modules.monitor.ginlong.dto.inverterday.GetInverterDayR;
import com.sifang.modules.monitor.ginlong.dto.inverterday.GetInverterDayReq;
import com.sifang.modules.sunshine.SystemSetting.utils.Result;
import com.sifang.modules.sys.util.http.GinlongRestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class GinlongApiService {

    @Autowired
    GinlongRestTemplate ginlongRestTemplate;

    public Result<AddStationR> addStation(AddStationReq req) {
        String url = "https://api.ginlong.com:13333/v1/api/addStation";
        return ginlongRestTemplate.postJson(url, req, new ParameterizedTypeReference<Result<AddStationR>>() {
        });
    }

    /**
     * 逆变器日实时数据
     */
    public Result<List<GetInverterDayR>> inverterDay(GetInverterDayReq req) throws IOException {
        String url = "https://api.ginlong.com:13333/v1/api/inverterDay";
        return ginlongRestTemplate.postJson(url, req, new ParameterizedTypeReference<Result<List<GetInverterDayR>>>() {
        });
    }


}
