package com.mrxu.admin.controller.iot; import com.mrxu.admin.controller.AdminBaseController; import com.mrxu.framework.boot.bean.ResponseObj; import com.mrxu.iot.model.IotDeviceVideoNode; import com.mrxu.iot.service.IotDeviceChannelService; import com.mrxu.iot.service.IotDeviceClassService; import com.mrxu.iot.third.WvpFeignClient; import com.mrxu.iot.third.response.StreamContent; import io.swagger.annotations.Api; import lombok.RequiredArgsConstructor; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import java.util.List; @Api(tags = "设备视频") @Controller @RequestMapping("/iot/iotDeviceVideo") @RequiredArgsConstructor(onConstructor = @__(@Autowired)) public class IotDeviceVideoController extends AdminBaseController { private final WvpFeignClient wvpClient; private final IotDeviceClassService classService; private final IotDeviceChannelService channelService; @RequiresPermissions("iot:iotDeviceVideo:read") @RequestMapping("index.html") public String index(Model model) { return "iot/iotDeviceVideo.html"; } @RequiresPermissions("iot:iotDeviceVideo:read") @ResponseBody @RequestMapping("/classList.json") public ResponseObj> classList() { return success(classService.deviceVideoNodeList(getTenantId())); } @RequiresPermissions("iot:iotDeviceVideo:read") @ResponseBody @RequestMapping("/play.json") public ResponseObj play(Integer channelId) { return success(classService.play(getTenantId(),channelId,getUsername())); } @RequiresPermissions("iot:iotDeviceVideo:read") @ResponseBody @RequestMapping("/getChannelConfig.json") public ResponseObj getChannelConfig(Integer channelId) { return success(channelService.getById(getTenantId(),channelId).getConfig()); } @RequiresPermissions("iot:iotDeviceVideo:read") @ResponseBody @RequestMapping("/control.json") public ResponseObj control(String deviceId , String channelId , String command , int horizonSpeed , int verticalSpeed , int zoomSpeed) { wvpClient.control(deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed); return success(); } @RequiresPermissions("iot:iotDeviceVideo:update") @ResponseBody @RequestMapping("/saveAndCommand.json") public ResponseObj saveAndCommand(String deviceId ,String channelId ,@RequestParam(required = false) Integer cmdCode ,int parameter1 ,int parameter2 ,int bindCode2,String config) { channelService.saveAndCommand(getTenantId(),deviceId,channelId, cmdCode,parameter1, parameter2, bindCode2,config,getUsername()); return success(); } }