package com.ffii.towngas.sensor.web;

import org.springframework.beans.BeanUtils;
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 com.ffii.core.support.AbstractController;
import com.ffii.towngas.sensor.entity.Wok;
import com.ffii.towngas.sensor.req.SendWokDataReq;
import com.ffii.towngas.sensor.service.WokService;

@RestController
@RequestMapping("/protected/sensorData")
public class WokController extends AbstractController{

    private WokService wokService;

    public WokController (WokService wokService){
        this.wokService = wokService;
    }

    @PostMapping("/api")
    public void saveSensorData (@RequestBody SendWokDataReq sendSenserDataReq) {
        Wok wok = new Wok();
        BeanUtils.copyProperties(sendSenserDataReq, wok);

        wokService.save(wok);
    }
    
}
