package com.xhpc.charging.station.controller;

import com.xhpc.charging.station.service.IXhpcDownCodeService;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * program: ruoyi
 * User: HongYun
 * Date:2021-09-30 15
 */
@RestController
@RequestMapping(value = "/code")
public class XhpcDownCodeController extends BaseController {

    @Autowired
    private IXhpcDownCodeService iXhpcDownCodeService;
    @Autowired
    private Environment environment;

    @GetMapping(value = "/listStations")
    public TableDataInfo listStations(String tenantId,Long operatorId,Long chargingStationId,String stationName){
        return getDataTable(iXhpcDownCodeService.listStations(tenantId,operatorId,chargingStationId,stationName));
    }

    @GetMapping(value = "/listPiles")
    public TableDataInfo listPiles(@RequestParam Long stationId){

        startPage();
        return getDataTable(iXhpcDownCodeService.listPiles(stationId));
    }

    @GetMapping(value = "/downMaterialByPileId")
    public AjaxResult downMaterialBy(@RequestParam Long pileId) throws Exception {

        String s = iXhpcDownCodeService.downMaterialBy(pileId);

        return AjaxResult.success(environment.getProperty("img.getUrl") + s);
    }

    @GetMapping(value = "/downMaterialByStationId")
    public AjaxResult downMaterialByStationId(@RequestParam Long stationId) throws Exception {

        String s = iXhpcDownCodeService.downMaterialByStationId(stationId);

        return AjaxResult.success(environment.getProperty("img.getUrl") + s);
    }
}
