/*
 * 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 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 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(), "");
    }
}
