package com.xhpc.charging.station.controller;

import com.xhpc.charging.station.service.IXhpcEquipmenMonitorService;
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.XhpcEquipmenMonitor;
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/9/12 10:57
 */
@RestController
@RequestMapping("/equipmenMonitor")
public class XhpcEquipmenMonitorController extends BaseController {

    @Resource
    private IXhpcEquipmenMonitorService xhpcEquipmenMonitorService;

    /**
     * 列表
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(HttpServletRequest request, String equipmenName, String equipmenNumber, Long chargingStationId) {
        startPage();
        List<Map<String, Object>> list = xhpcEquipmenMonitorService.list(request,equipmenName,equipmenNumber,chargingStationId);
        return getDataTable(list);
    }


    /**
     * 详情
     *
     * @return
     */
    @GetMapping(value = "/getequipmenMonitorById")
    public AjaxResult getequipmenMonitorById(@RequestParam(value = "equipmenMonitorId") Long equipmenMonitorId) {

        return xhpcEquipmenMonitorService.getequipmenMonitorById(equipmenMonitorId);
    }


    /**
     * 新增
     *
     * @return
     */
    @PostMapping(value = "/addEquipmenMonitor")
    public AjaxResult addEquipmenMonitor(@RequestBody XhpcEquipmenMonitor xhpcEquipmenMonitor) {

        return xhpcEquipmenMonitorService.addEquipmenMonitor(xhpcEquipmenMonitor);
    }

    @DeleteMapping("/{equipmenMonitorId}")
    public AjaxResult remove(@PathVariable Long equipmenMonitorId) {

        return xhpcEquipmenMonitorService.remove(equipmenMonitorId);
    }

    /**
     * 场站监控列表
     *
     * @param chargingStationId
     * @return
     */
    @GetMapping(value = "/getChargingStationMonitor")
    public AjaxResult getChargingStationMonitor(Long chargingStationId) {

        return xhpcEquipmenMonitorService.getChargingStationMonitor(chargingStationId);
    }
    /**
     * 场站监控Token
     *
     * @return
     */
    @GetMapping(value = "/getChargingStationEquipmenToken")
    public AjaxResult getChargingStationEquipmenToken() {
        //Map<String, Object> map = new HashMap<>();
        //map.put("accessToken","at.35peeqba81hltpja2c32fw8e9fhxwjes-7p2r9zyvtp-1016urx-bkfywfr2z");
        return xhpcEquipmenMonitorService.getChargingStationEquipmenToken();
    }
}
