|
@@ -4,27 +4,29 @@ package beilv.hik.controller;
|
|
|
import beilv.common.core.controller.BaseController;
|
|
|
import beilv.common.core.domain.AjaxResult;
|
|
|
import beilv.hik.controller.utils.GetCameraPreviewURL;
|
|
|
-import beilv.hik.controller.utils.GetCameras;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.PrintWriter;
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping("/system/hik")
|
|
|
-public class HiKController extends BaseController {
|
|
|
+public class HiKController extends BaseController {
|
|
|
|
|
|
private String prefix = "system/hik";
|
|
|
|
|
|
- @GetMapping()
|
|
|
- public String hik() {
|
|
|
+ @GetMapping("/{cameraIndexCode}")
|
|
|
+ public String hik(@PathVariable("cameraIndexCode") String cameraIndexCode, ModelMap mmap) throws IOException {
|
|
|
+ mmap.put("cameraIndexCode", cameraIndexCode);
|
|
|
return prefix + "/hik";
|
|
|
}
|
|
|
|
|
@@ -38,17 +40,10 @@ public class HiKController extends BaseController {
|
|
|
/**
|
|
|
* 获取直播流地址
|
|
|
*/
|
|
|
- @GetMapping("/getCameraPreviewURL")
|
|
|
+ @GetMapping("/getCameraPreviewURL/{cameraIndexCode}")
|
|
|
@ResponseBody
|
|
|
- public AjaxResult getCameraPreviewURL() {
|
|
|
- List<String> urlList = new ArrayList<>();
|
|
|
- List<Map<String, Object>> cameras = GetCameras.getCameras(host, appKey, appSecret);
|
|
|
- if (!CollectionUtils.isEmpty(cameras)) {
|
|
|
- for (Map<String, Object> map : cameras) {
|
|
|
- String url = GetCameraPreviewURL.getCameraPreviewURL(host, appKey, appSecret, map.get("cameraIndexCode").toString());
|
|
|
- urlList.add(url);
|
|
|
- }
|
|
|
- }
|
|
|
- return AjaxResult.success(urlList);
|
|
|
+ public AjaxResult getCameraPreviewURL(@PathVariable("cameraIndexCode") String cameraIndexCode) {
|
|
|
+ String cameraPreviewURL = GetCameraPreviewURL.getCameraPreviewURL(host, appKey, appSecret, cameraIndexCode);
|
|
|
+ return AjaxResult.success("操作成功", cameraPreviewURL);
|
|
|
}
|
|
|
}
|