HiKController.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package beilv.hik.controller;
  2. import beilv.common.core.controller.BaseController;
  3. import beilv.common.core.domain.AjaxResult;
  4. import beilv.hik.controller.utils.GetCameraPreviewURL;
  5. import beilv.hik.controller.utils.GetCameras;
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.util.CollectionUtils;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import java.util.Map;
  15. @Controller
  16. @RequestMapping("/system/hik")
  17. public class HiKController extends BaseController {
  18. private String prefix = "system/hik";
  19. @GetMapping()
  20. public String hik() {
  21. return prefix + "/hik";
  22. }
  23. @Value("${hik.appKey}")
  24. private String appKey;
  25. @Value("${hik.appSecret}")
  26. private String appSecret;
  27. @Value("${hik.host}")
  28. private String host;
  29. /**
  30. * 根据userId查询用户积分流水列表
  31. */
  32. @GetMapping("/getCameraPreviewURL")
  33. @ResponseBody
  34. public AjaxResult getCameraPreviewURL() {
  35. List<String> urlList = new ArrayList<>();
  36. List<Map<String, Object>> cameras = GetCameras.getCameras(host, appKey, appSecret);
  37. if (!CollectionUtils.isEmpty(cameras)) {
  38. for (Map<String, Object> map : cameras) {
  39. String url = GetCameraPreviewURL.getCameraPreviewURL(host, appKey, appSecret, map.get("cameraIndexCode").toString());
  40. urlList.add(url);
  41. }
  42. }
  43. return AjaxResult.success(urlList);
  44. }
  45. }