HwVideoController.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.zhiqiyun.open.mvc.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.google.common.collect.Maps;
  5. import com.zhiqiyun.open.annotation.Permission;
  6. import com.zhiqiyun.open.core.models.hwVideo.DeviceList;
  7. import com.zhiqiyun.open.core.video.VideoDockingService;
  8. import com.zhiqiyun.open.mvc.Result;
  9. import com.zhiqiyun.open.mvc.params.QueryPageParams;
  10. import org.springframework.web.bind.annotation.*;
  11. import javax.annotation.Resource;
  12. import java.util.List;
  13. import java.util.Map;
  14. /**
  15. * 华为视频接口登录问题
  16. *
  17. * @author NINGMEI
  18. */
  19. @RestController
  20. @RequestMapping("/hw/video/")
  21. public class HwVideoController {
  22. @Resource
  23. private VideoDockingService videoDockingService;
  24. @PostMapping("findPage")
  25. @Permission(value = "hw.video.find", tags = "查询子设备列表")
  26. public Result page(@RequestBody QueryPageParams pageParams) throws Exception {
  27. Map<String, String> params = Maps.newHashMap();
  28. params.put("fromIndex", String.valueOf((pageParams.getCurrent() - 1) * 10 + 1));
  29. params.put("toIndex", String.valueOf(pageParams.getCurrent() * 10));
  30. JSONObject jsonObject = videoDockingService.loadDeviceList(params);
  31. JSONObject cameraBriefExInfos = jsonObject.getJSONObject("cameraBriefExInfos");
  32. int total = cameraBriefExInfos.getIntValue("total");
  33. JSONObject cameraBriefInfoExList = jsonObject.getJSONObject("cameraBriefInfoExList");
  34. List<DeviceList> cameraBriefInfoExes = cameraBriefInfoExList.getJSONArray("cameraBriefInfoExes")
  35. .toJavaList(DeviceList.class);
  36. Page<DeviceList> resultData = pageParams.getPage();
  37. resultData.setTotal(total);
  38. resultData.setRecords(cameraBriefInfoExes);
  39. return Result.instance(Result.Code.SUCCESS).setData(resultData);
  40. }
  41. @Permission(value = "hw.video.url.find", tags = "获取视频URL信息")
  42. @PostMapping("/rtspUrl")
  43. public Result loadVideoRtspUrl(@RequestBody String cameraCode) throws Exception {
  44. JSONObject jsonObject = videoDockingService.loadVideoRtspUrl(cameraCode);
  45. return Result.instance(Result.Code.SUCCESS).setData(jsonObject.getString("rtspURL"));
  46. }
  47. }