package org.springblade.openinterface.iot;


import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.homecare.alarmlist.entity.Alarm;
import org.springblade.homecare.alarmlist.service.IAlarmService;
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;

@RestController
@AllArgsConstructor
@RequestMapping("openinterface/iot")
@Api(value = "物联网设备开放接口", tags = "开放接口")
public class IotOpenController {


	private IAlarmService alarmService;
	@PostMapping("/alarm")
	public R iotAlarm(@RequestBody Alarm alarm){

		//根据告警信息的imei绑定设备
		if(alarmService.save(alarm)){
			return R.status(true);
		}else{
			return R.data("设备sn号："+alarm.getDeviceId()+"告警时间为："+alarm.getRecordTime()+"推送失败");
		}


	}

}

