1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package com.fdkankan.ucenter.controller.app;
- import com.alibaba.fastjson.JSONObject;
- import com.fdkankan.ucenter.common.Result;
- import com.fdkankan.ucenter.constant.LoginConstant;
- import com.fdkankan.ucenter.service.impl.AppCameraService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.ObjectUtils;
- import org.springframework.web.bind.annotation.*;
- import java.util.Map;
- import java.util.concurrent.CompletableFuture;
- @RestController
- @RequestMapping("/app/camera")
- public class AppCameraController {
- @Autowired
- private AppCameraService appCameraService;
- @PostMapping("/getCamerasForUser")
- public Result getCamerasForUser(@RequestBody JSONObject param ){
- String userName = param.get("userName") == null ? null : param.getString("userName");
- Integer cameraType = param.get("cameraType") == null ? 4 : param.getInteger("cameraType");
- return Result.success(appCameraService.getCameraForUser(userName,cameraType));
- }
- /**
- * 绑定相机
- */
- @PostMapping("/bindCamera")
- public Result bindCamera(@RequestBody JSONObject param ){
- String userName = param.get("userName") == null ? null : param.getString("userName");
- String snCode = param.get("snCode") == null ? null : param.getString("snCode");
- return Result.success(appCameraService.bindCamera(userName,snCode));
- }
- /**
- * 解绑相机
- */
- @PostMapping("/unbind")
- public Result unbind(@RequestBody JSONObject param ){
- String userName = param.get("userName") == null ? null : param.getString("userName");
- String childName = param.get("childName") == null ? null : param.getString("childName");
- appCameraService.unbindCamera(userName,childName);
- return Result.success();
- }
- /**
- * 获取相机信息
- */
- @PostMapping("/getCameraInfo")
- public Result getCameraInfo(@RequestBody JSONObject param ){
- String childName = param.get("childName") == null ? null : param.getString("childName");
- String childPassword = param.get("childPassword") == null ? null : param.getString("childPassword");
- return Result.success(appCameraService.getCameraInfo(childName,childPassword));
- }
- /**
- * 用户相机信息上报 app 需要调用
- */
- @RequestMapping(value = "/uploadUserCameraInfo", method = RequestMethod.POST)
- public Result uploadUserCameraInfo(@RequestBody Map<String,String> param) throws Exception {
- if (ObjectUtils.isEmpty(param) || !param.containsKey("snCode") || !param.containsKey("cameraVersion")
- || !param.containsKey("appVersion")) {
- return Result.failure(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
- }
- CompletableFuture.runAsync(() -> {
- appCameraService.uploadUserCameraInfo(param.get("snCode"),param.get("cameraVersion"),param.get("appVersion"));
- });
- return Result.success();
- }
- }
|