package com.xhpc.evcs.api;

import com.xhpc.evcs.dto.CommonRequest;
import com.xhpc.evcs.dto.CommonResponse;
import com.xhpc.evcs.dto.NotifyNoBillOrderRequest;
import com.xhpc.evcs.dto.NotifyNoBillOrderResponse;
import com.xhpc.evcs.jpa.XhpcTerminalRepository;
import com.xhpc.evcs.utils.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;

@Slf4j
@RestController
public class NotifyNoBillOrderController {

    @Autowired
    private XhpcTerminalRepository xhpcTerminalRepository;

    @PostMapping("/v1/notify_no_bill_order")
    public CommonResponse notifyNoBillOrder(@RequestBody CommonRequest<NotifyNoBillOrderRequest> commonRequest) throws IOException {

        NotifyNoBillOrderRequest notifyNoBillOrderRequest = JSONUtil.readParams(commonRequest.getData(),
                NotifyNoBillOrderRequest.class);// todo check NPE

        CommonResponse commonResponse = new CommonResponse();
        commonResponse.setMsg("Query equipment business policy success");
        commonResponse.setRet("0");
        NotifyNoBillOrderResponse notifyNoBillOrderResponse = new NotifyNoBillOrderResponse();
        commonResponse.setData(JSONUtil.toJSONString(notifyNoBillOrderResponse));

        return commonResponse;
    }

}
