package com.fdkankan.platform.goods.controller.api;

import com.fdkankan.common.controller.BaseController;
import com.fdkankan.platform.goods.service.IDeviceService;
import com.fdkankan.platform.goods.vo.ResponseCameraApp;
import com.fdkankan.platform.user.request.RequestCamera;
import com.fdkankan.platform.user.vo.ResponseCamera;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 设备中心接口-
 */
@Log4j2
@RestController
@RequestMapping("/service/platform/device/camera")
public class DeviceCameraController extends BaseController {

    @Autowired
    private IDeviceService deviceService;

    /**
     * 获取设备详情
     * cameraId     相机id
     * @return
     */
    @RequestMapping(value = "/detail", method = RequestMethod.POST)
    public ResponseCamera getCameraInfo(@RequestBody RequestCamera param) throws Exception {
        return deviceService.getCameraDetail(param.getCameraId());
    }

    /**
     * 绑定设备
     * userName     用户名
     * childName    相机的物理地址
     * @return
     */
    @RequestMapping(value = "/bindCamera", method = RequestMethod.POST)
    public String bindCamera(@RequestBody RequestCamera camera) throws Exception {
        return deviceService.bindCamera(camera);
    }

    /**
     * 获取用户所有设备
     * userName     用户名
     */
    @RequestMapping(value = "/getCamerasForUser", method = RequestMethod.POST)
    public List<ResponseCameraApp> getCamerasForUser(@RequestBody RequestCamera camera) throws Exception {
        return  deviceService.getCamerasForUser(camera);
    }

    /**
     * 设备解除绑定
     * userName         用户名
     * cameraType       相机类型，1双目，4八目
     * childName        相机的物理地址
     * @return
     */
    @RequestMapping(value = "/unbind", method = RequestMethod.POST)
    public String unbind(@RequestBody RequestCamera camera) throws Exception {
        return deviceService.unbind(camera);
    }
}
