package com.kym.admin.controller;

import com.kym.common.R;
import com.kym.entity.admin.ConnectorInfo;
import com.kym.entity.admin.queryParams.EquipmentQueryParam;
import com.kym.entity.admin.vo.ConnectorInfoVo;
import com.kym.entity.common.PageBean;
import com.kym.service.admin.ConnectorInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 充电桩桩体设备 前端控制器
 * </p>
 *
 * @author skyline
 * @since 2023-08-05
 */
@RestController
@RequestMapping("/connector")
public class ConnectorInfoController {

    private final ConnectorInfoService connectorInfoService;

    public ConnectorInfoController(ConnectorInfoService connectorInfoService) {
        this.connectorInfoService = connectorInfoService;
    }


    /**
     * 充电桩列表
     *
     * @param params
     * @return
     */
    @GetMapping("/listConnectors")
    R<?> listEquipment(@ModelAttribute EquipmentQueryParam params) {
        PageBean<ConnectorInfoVo> res = connectorInfoService.listConnectors(params);
        return R.success(res);
    }

    @GetMapping("detail/{id}")
    R<?> detail(@PathVariable(name = "id") long id) {
        ConnectorInfo res = connectorInfoService.getById(id);
        return R.success(res);
    }


    /**
     * 统计充电桩状态
     *
     * @return
     */
    @GetMapping("/statConnectorStatus")
    R<?> statEquipment(String stationId) {
        return R.success(connectorInfoService.statConnectorStatus(stationId));
    }


}
