package com.sky.ioc.controller.security;

import com.sky.ioc.service.energy.EnergyDeviceService;
import com.sky.ioc.tool.ReturnMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "智慧安防--智能源")
@Slf4j
@RequestMapping("/security_camera")
@RestController
public class EnergyDeviceController {

    @Autowired
    EnergyDeviceService energyDeviceService;

    @ApiOperation("空调设备开关")
    @PostMapping("/controlAirCondition")
    public ReturnMsg controlAirCondition(@RequestParam(name = "deviceId", required = true) Integer deviceId,
                                         @RequestParam(name = "temperature", required = true) Double temperature,
                                         @RequestParam(name = "speed", required = true) Double speed,
                                         @RequestParam(name = "mode", required = true) Integer mode) {
        return energyDeviceService.openControlAirCondition(deviceId,temperature,speed,mode);
    }

    @ApiOperation("热水器设备开关")
    @PostMapping("/openWaterHeater")
    public ReturnMsg openWaterHeater(@RequestParam(name = "deviceId", required = true) Integer deviceId,
                                     @RequestParam(name = "open", required = true) Integer open) {
        return energyDeviceService.openWaterHeater(deviceId,open);
    }

    @ApiOperation("灯光设备开关")
    @PostMapping("/openLight")
    public ReturnMsg openLight(@RequestParam(name = "deviceId", required = true) Integer deviceId,
                                     @RequestParam(name = "open", required = true) Integer open) {
        return energyDeviceService.openControlLight(deviceId,open);
    }

}
