package com.its.bis.api.controller;

import com.its.app.utils.SysUtils;
import com.its.bis.api.dto.AgipObeLoc;
import com.its.bis.api.service.AgipControlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@Api(tags = "1.BIS AGIP Controller")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/bis")
public class AgipControlController {

    private final AgipControlService service;

    @ApiOperation(value = "AGIP 실시간 OBE 위치정보 수집")
    @PostMapping(value = "/location", produces = {"application/json; charset=utf8"})
    public void receiveWebhooksFromAGIP2(@RequestBody List<Map<String, Object>> payload) {
        log.error("{}", payload);
    }

    @ApiOperation(value = "AGIP 실시간 OBE 위치정보 수집")
    @PostMapping(value = "/location2", produces = {"application/json; charset=utf8"})
    public void receiveWebhooksFromAGIP(@RequestBody AgipObeLoc payload) {
        log.error("{}", payload);
    }

    @ApiOperation(value = "AGIP 테스트 URL", response = String.class)
    @PostMapping(value = "/test", produces = {"application/json; charset=utf8"})
    public String test(@RequestBody String payload) {
        log.info("URL test: {}", payload);
        return payload + ": " + SysUtils.getSysTime();
    }

}
