194 lines
5.4 KiB
Java
194 lines
5.4 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package com.ifish.controller;
|
|
|
|
import com.ifish.bean.Tbl_Device;
|
|
import com.ifish.bean.Tbl_Device_User;
|
|
import com.ifish.bean.Tbl_User;
|
|
import com.ifish.enums.ResultEnum;
|
|
import com.ifish.helper.DeviceHelperI;
|
|
import com.ifish.util.IfishUtil;
|
|
import java.util.Date;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
/**
|
|
*
|
|
* @author Administrator
|
|
*/
|
|
@RestController
|
|
public class Device {
|
|
|
|
@Autowired
|
|
private DeviceHelperI deviceHelperI;
|
|
|
|
/**
|
|
* 绑定设备
|
|
*
|
|
* @param userId
|
|
* @param macAddress
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/bindDevice.do", method = RequestMethod.POST)
|
|
public Object bindDevice(Integer userId, String macAddress) {
|
|
try {
|
|
return deviceHelperI.bindDevice(userId, macAddress);
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
|
}
|
|
|
|
/**
|
|
* 分享设备
|
|
*
|
|
* @param userId
|
|
* @param macAddress
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/shareDevice", method = RequestMethod.POST)
|
|
public Object shareDevice(Integer userId, Integer deviceId) {
|
|
return deviceHelperI.shareDevice(userId, deviceId);
|
|
}
|
|
|
|
/**
|
|
* 绑定摄像头
|
|
*
|
|
* @param userId
|
|
* @param cameraId
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/bindCamera.do", method = RequestMethod.POST)
|
|
public Object bindCamera(Integer userId, String cameraId) {
|
|
try {
|
|
return deviceHelperI.bindCamera(userId, cameraId);
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
|
}
|
|
|
|
/**
|
|
* 激活摄像头
|
|
*
|
|
* @param activeCode
|
|
* @param cameraId
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/activeCamera.do", method = RequestMethod.POST)
|
|
public Object activeCamera(String activeCode, String cameraId) {
|
|
try {
|
|
return deviceHelperI.activeCamera(activeCode, cameraId);
|
|
} catch (Exception e) {
|
|
}
|
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
|
}
|
|
|
|
/**
|
|
* 修改设备显示名称
|
|
*
|
|
* @param device
|
|
* @param userId
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/updateDeviceUser.do", method = RequestMethod.POST)
|
|
public Object updateDeviceUser(Tbl_Device_User device) {
|
|
try {
|
|
return deviceHelperI.updateDeviceUser(device);
|
|
} catch (Exception e) {
|
|
}
|
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
|
}
|
|
|
|
/**
|
|
* 修改摄像头信息
|
|
*
|
|
* @param cameraId
|
|
* @param device_User
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/updateCameraUser.do", method = RequestMethod.POST)
|
|
public Object updateCameraUser(Integer cameraId, Tbl_Device_User device_User) {
|
|
try {
|
|
return deviceHelperI.updateCameraUser(cameraId, device_User);
|
|
} catch (Exception e) {
|
|
}
|
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
|
}
|
|
|
|
/**
|
|
* 删除绑定的设备
|
|
*
|
|
* @param deviceUser
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/deleteDeviceUser.do", method = RequestMethod.POST)
|
|
public Object deleteDeviceUser(Tbl_Device_User deviceUser) {
|
|
try {
|
|
return deviceHelperI.deleteDeviceUser(deviceUser);
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
|
}
|
|
|
|
/**
|
|
* 删除绑定的摄像头
|
|
*
|
|
* @param deviceUser
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/deleteCameraUser.do", method = RequestMethod.POST)
|
|
public Object deleteCameraUser(Integer userId, String cameraId) {
|
|
try {
|
|
return deviceHelperI.deleteCameraUser(userId, cameraId);
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
|
}
|
|
|
|
/**
|
|
* 设置是否接收离线通知
|
|
*
|
|
* @param macAddress
|
|
* @param offLive
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = {"/updateDeviceOffLive"}, method = RequestMethod.POST)
|
|
public Object updateDeviceOffLive(Integer userId, Integer deviceId, String offLive) {
|
|
return deviceHelperI.updateDeviceOffLive(userId, deviceId, offLive);
|
|
}
|
|
|
|
/**
|
|
* 设置换水提醒
|
|
*
|
|
* @param macAddress 设备mac
|
|
* @param todayRemind 今天是否提醒
|
|
* @param waterRemind 是否开启换水提醒
|
|
* @param remindDate 换水提醒日期
|
|
* @param remindCycle 换水提醒周期
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = {"/updateDeviceRemind"}, method = RequestMethod.POST)
|
|
public Object updateDeviceRemind(Integer deviceId, String waterRemind, Integer remindCycle) {
|
|
return deviceHelperI.updateDeviceRemind(deviceId, waterRemind, remindCycle);
|
|
}
|
|
|
|
/**
|
|
* 根据设备ID获取设备换水提醒
|
|
*
|
|
* @param deviceId
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = {"/getDeviceRemind"}, method = RequestMethod.GET)
|
|
public Object getDeviceRemind(Integer deviceId) {
|
|
return deviceHelperI.getDeviceRemind(deviceId);
|
|
}
|
|
}
|