package com.xhpc.evcs.api;

import com.xhpc.evcs.dto.*;
import com.xhpc.evcs.encryption.EvcsConst;
import com.xhpc.evcs.utils.JSONUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController()
public class NotificationStationStatusController {

    /**
     * 设备状态变化推送
     * @param commonRequest
     * @return
     * @throws IOException
     */
    @PostMapping("/v1/notification_stationStatus")
    public CommonResponse notificationStationStatus(@RequestBody CommonRequest<ConnectorStatusInfo> commonRequest) throws IOException {

        String operatorID = commonRequest.getOperatorId();
        StationInfo stationInfo = new StationInfo();
        stationInfo.setOperatorId(operatorID);
        ConnectorStatusInfo connectorStatusInfo = commonRequest.transformDataType(ConnectorStatusInfo.class,
                "ConnectorStatusInfo");
        CommonResponse response = new CommonResponse();
        response.setRet(EvcsConst.RET_SUCC);
        response.setData(JSONUtil.toJSONString(new EvcsStatus(0)));
        return response;
    }

}
