|
@@ -1,121 +1,78 @@
|
|
|
-//package com.fdkankan.platform.goods.controller.app;
|
|
|
-//
|
|
|
-//import com.fdkankan.common.controller.BaseController;
|
|
|
-//import com.fdkankan.platform.user.request.RequestCamera;
|
|
|
-//import lombok.extern.log4j.Log4j2;
|
|
|
-//import org.apache.commons.lang.StringUtils;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-//import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-//import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-//import org.springframework.web.bind.annotation.RestController;
|
|
|
-//
|
|
|
-//import java.util.ArrayList;
|
|
|
-//import java.util.List;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * 设备中心接口-app设备模块
|
|
|
-// */
|
|
|
-//@Log4j2
|
|
|
-//@RestController
|
|
|
-//@RequestMapping("/api/app/camera")
|
|
|
-//public class DeviceCameraAppController extends BaseController {
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 获取设备详情
|
|
|
-// * childPassword 相机密码
|
|
|
-// * childName 相机的物理地址
|
|
|
-// */
|
|
|
-// @RequestMapping(value = "/getCameraInfo", method = RequestMethod.POST)
|
|
|
-// public String getCameraInfo(@RequestBody RequestCamera param) throws Exception {
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 绑定设备
|
|
|
-// */
|
|
|
-// @ApiOperation("绑定设备")
|
|
|
-// @RequestMapping(value = "/bindCamera", method = RequestMethod.POST)
|
|
|
-// @ApiImplicitParams({
|
|
|
-// @ApiImplicitParam(name = "userName", value = "用户名", dataType = "number"),
|
|
|
-// @ApiImplicitParam(name = "childName", value = "相机的物理地址", dataType = "String"),
|
|
|
-// @ApiImplicitParam(name = "cameraType", value = "相机类型,1双目,4八目", dataType = "String"),
|
|
|
-// @ApiImplicitParam(name = "snCode", value = "sn码", dataType = "String")
|
|
|
-// })
|
|
|
-// public Result bindCamera(@RequestBody RequestCamera camera) throws Exception {
|
|
|
-// if((StringUtils.isEmpty(camera.getChildName()) && StringUtils.isEmpty(camera.getSnCode())) || StringUtils.isEmpty(camera.getUserName())){
|
|
|
-// throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
|
|
|
-// }
|
|
|
-// return deviceService.bindProCamera(camera);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 获取用户所有设备
|
|
|
-// */
|
|
|
-// @ApiOperation("获取用户所有设备")
|
|
|
-// @RequestMapping(value = "/getCamerasForUser", method = RequestMethod.POST)
|
|
|
-// @ApiImplicitParams({
|
|
|
-// @ApiImplicitParam(name = "userName", value = "用户名", dataType = "number"),
|
|
|
-// @ApiImplicitParam(name = "cameraType", value = "相机类型,1双目,4八目", dataType = "String")
|
|
|
-// })
|
|
|
-// public Result<List<ResponseCameraApp>> getCamerasForUser(@RequestBody RequestCamera camera) throws Exception {
|
|
|
-// if(StringUtils.isEmpty(camera.getUserName())){
|
|
|
-// throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
|
|
|
-// }
|
|
|
-// Result userResult = userService.findByUserName(camera.getUserName());
|
|
|
-// if (userResult.getCode() == Result.CODE_FAILURE){
|
|
|
-// return userResult;
|
|
|
-// }
|
|
|
-// SSOUser ssoUser = mapper.convertValue(userResult.getData(), SSOUser.class);
|
|
|
-// if (ssoUser == null){
|
|
|
-// throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3015, LoginConstant.FAILURE_MSG_3015);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(camera.getCameraType() == null){
|
|
|
-// camera.setCameraType(4);
|
|
|
-// }
|
|
|
-// List<CameraDetailEntity> list = cameraDetailService.findEntityByUserId(ssoUser.getId(), camera.getCameraType().longValue());
|
|
|
-// if(list == null){
|
|
|
-// Result.success();
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<ResponseCameraApp> resultList = new ArrayList<>();
|
|
|
-// for(CameraDetailEntity entity : list){
|
|
|
-// CameraEntity cameraEntity = goodsService.findCameraById(entity.getCameraId());
|
|
|
-//
|
|
|
-// if(cameraEntity == null){
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// Result result = goodsService.getCameraInfo(cameraEntity.getChildName(), cameraEntity.getChildPassword());
|
|
|
-// if (result.getCode() == Result.CODE_FAILURE){
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-// ResponseCameraApp cameraApp = mapper.convertValue(result.getData(), ResponseCameraApp.class);
|
|
|
-//
|
|
|
-// UserIncrementEntity userIncrementEntity = userIncrementService.findByCameraId(cameraEntity.getId());
|
|
|
-// if(userIncrementEntity != null){
|
|
|
-// cameraApp.setUserIncrementId(userIncrementEntity.getId());
|
|
|
-// cameraApp.setIsExpire(userIncrementEntity.getIsExpired());
|
|
|
-// }
|
|
|
-//
|
|
|
-// resultList.add(cameraApp);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return Result.success(resultList);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 设备解除绑定
|
|
|
-// */
|
|
|
-// @ApiOperation("设备解除绑定")
|
|
|
-// @RequestMapping(value = "/unbind", method = RequestMethod.POST)
|
|
|
-// @ApiImplicitParams({
|
|
|
-// @ApiImplicitParam(name = "userName", value = "用户名", dataType = "number"),
|
|
|
-// @ApiImplicitParam(name = "cameraType", value = "相机类型,1双目,4八目", dataType = "String"),
|
|
|
-// @ApiImplicitParam(name = "childName", value = "相机的物理地址", dataType = "String")})
|
|
|
-// public Result unbind(@RequestBody RequestCamera camera) throws Exception {
|
|
|
-// return deviceService.unbindPro(camera);
|
|
|
-// }
|
|
|
-//}
|
|
|
+package com.fdkankan.platform.goods.controller.app;
|
|
|
+
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.controller.BaseController;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.platform.goods.service.IDeviceService;
|
|
|
+import com.fdkankan.platform.goods.vo.ResponseCameraApp;
|
|
|
+import com.fdkankan.platform.user.request.RequestCamera;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设备中心接口-app设备模块
|
|
|
+ */
|
|
|
+@Log4j2
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/app/camera")
|
|
|
+public class DeviceCameraAppController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDeviceService deviceService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取设备详情
|
|
|
+ * childPassword 相机密码
|
|
|
+ * childName 相机的物理地址
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getCameraInfo", method = RequestMethod.POST)
|
|
|
+ public ResponseCameraApp getCameraInfo(@RequestBody RequestCamera param) throws Exception {
|
|
|
+ return deviceService.getCameraInfo(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绑定设备
|
|
|
+ * userName 用户名
|
|
|
+ * childName 相机的物理地址
|
|
|
+ * cameraType 相机类型,1双目,4八目
|
|
|
+ * snCode sn码
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/bindCamera", method = RequestMethod.POST)
|
|
|
+ public ResponseCameraApp bindCamera(@RequestBody RequestCamera camera) throws Exception {
|
|
|
+ if((StringUtils.isEmpty(camera.getChildName()) && StringUtils.isEmpty(camera.getSnCode())) || StringUtils.isEmpty(camera.getUserName())){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ return deviceService.bindProCamera(camera);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户所有设备
|
|
|
+ * userName 用户名
|
|
|
+ * cameraType 相机类型,1双目,4八目
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getCamerasForUser", method = RequestMethod.POST)
|
|
|
+ public List<ResponseCameraApp> getCamerasForUser(@RequestBody RequestCamera camera) throws Exception {
|
|
|
+ return deviceService.getCamerasForUser(camera);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设备解除绑定
|
|
|
+ * userName 用户名
|
|
|
+ * cameraType 相机类型,1双目,4八目
|
|
|
+ * childName 相机的物理地址
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/unbind", method = RequestMethod.POST)
|
|
|
+ public String unbind(@RequestBody RequestCamera camera) throws Exception {
|
|
|
+ return deviceService.unbindPro(camera);
|
|
|
+ }
|
|
|
+}
|