package com.xhpc.common.api;

import com.xhpc.common.api.factory.PowerPileFallbackFactory;
import com.xhpc.common.core.constant.ServiceNameConstants;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.data.down.StartChargingData;
import com.xhpc.common.data.redis.CacheRateModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@FeignClient(contextId = "powerPileService", value = ServiceNameConstants.PILE_SERVICE, fallbackFactory =
        PowerPileFallbackFactory.class)
public interface PowerPileService {

    //    @PreAuthorize(hasPermi = "user:privilege:add") todo
    @PostMapping("/charging/start")
    R startCharging(@Validated @RequestBody StartChargingData startChargingData);

    @PostMapping("/charging/balance/refresh")
    R refreshBalance(@Validated @RequestBody StartChargingData balanceRefreshData);

    @PutMapping("charging/stop/{orderNo}/{pileNo}/{connectorId}/{version}")
    R stopCharging(@PathVariable("orderNo") String orderNo, @PathVariable("pileNo") String pileNo,
                   @PathVariable("connectorId") String connectorId, @PathVariable("version") String version);

    @PostMapping("/pile/whitelist/add/{stationId}/{version}")
    R addPileWhitelist(@PathVariable("stationId") Long stationId,
                       @PathVariable("version") String version,
                       @RequestBody Set<String> pileNoSet);

    @DeleteMapping("/pile/whitelist/delete/{stationId}")
    R deletePileWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet);

    @PostMapping("/station/rateModel/{stationId}/{rateModelId}")
    R setStationRateModel(@PathVariable("stationId") @Param("stationId") Long stationId,
                          @PathVariable("rateModelId") @Param("rateModelId") Long rateModelId,
                          @RequestBody @Param("rateModel") CacheRateModel rateModel);

    @PostMapping("/pile/{pileNo}/timeNRateModel")
    R configTimeNRateModel(@PathVariable("pileNo") String pileNo);


    @PostMapping("/pile/{pileNo}/softwareUpgrade")
    R pileSoftwareUpgrade(@PathVariable("pileNo") String pileNo);
}
