package com.xhpc.charging.station.controller;

import com.xhpc.charging.station.service.IXhpcPileEditionService;
import com.xhpc.common.api.dto.XhpcChargingStationDto;
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 com.xhpc.common.domain.XhpcPileEdition;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @author yuyang
 * @date 2022/8/30 14:17
 */
@RestController
@RequestMapping("/pileEdition")
public class XhpcPileEditionController extends BaseController {


    @Resource
    private IXhpcPileEditionService xhpcPileEditionService;

    @GetMapping("/list")
    public TableDataInfo list(HttpServletRequest request,Long chargingStationId,String chargingPileIds) {
        startPage();
        List<Map<String, Object>> list = xhpcPileEditionService.list(request,chargingStationId,chargingPileIds);
        return getDataTable(list);
    }

    @PostMapping(value = "/addPileEdition")
    public AjaxResult addPileEdition(HttpServletRequest request, @RequestBody XhpcPileEdition xhpcPileEdition) {
        return xhpcPileEditionService.addPileEdition(request, xhpcPileEdition);
    }
    @PostMapping("/status")
    public AjaxResult status(@RequestParam(value = "status", required = true) Integer status,@RequestParam(value = "pileEditionId", required = true) Long pileEditionId) {

        return xhpcPileEditionService.status(pileEditionId,status);
    }

    @GetMapping("/getChargingPileList")
    public AjaxResult getChargingPileList(@RequestParam(value = "chargingStationId", required = true)Long chargingStationId) {
        return xhpcPileEditionService.getChargingPileList(chargingStationId);
    }
}
