|
@@ -4,15 +4,15 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.xiaoan.common.constant.MsgCode;
|
|
|
import com.xiaoan.common.model.PageDto;
|
|
|
import com.xiaoan.common.util.ResultJson;
|
|
|
+import com.xiaoan.domain.backend.CameraDetailEntity;
|
|
|
import com.xiaoan.domain.backend.CameraEntity;
|
|
|
import com.xiaoan.domain.backend.LogEntity;
|
|
|
import com.xiaoan.domain.backend.SceneProEntity;
|
|
|
+import com.xiaoan.domain.dto.request.CameraRequest;
|
|
|
import com.xiaoan.domain.dto.request.SceneProRequest;
|
|
|
+import com.xiaoan.domain.dto.response.CameraResponse;
|
|
|
import com.xiaoan.domain.dto.response.SceneResponse;
|
|
|
-import com.xiaoan.service.backend.CameraService;
|
|
|
-import com.xiaoan.service.backend.LogService;
|
|
|
-import com.xiaoan.service.backend.SceneService;
|
|
|
-import com.xiaoan.service.backend.UserService;
|
|
|
+import com.xiaoan.service.backend.*;
|
|
|
import com.xiaoan.web.aop.WebControllerLog;
|
|
|
import com.xiaoan.web.shiro.JWTUtil;
|
|
|
import com.xiaoan.web.shiro.JwtUtil2;
|
|
@@ -20,10 +20,12 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -43,7 +45,8 @@ public class PersonalCenterController extends BaseController {
|
|
|
private CameraService cameraService;
|
|
|
|
|
|
@Autowired
|
|
|
- private LogService logService;
|
|
|
+ private CameraDetailService cameraDetailService;
|
|
|
+
|
|
|
|
|
|
@RequiresPermissions("admin:scene:list")
|
|
|
@WebControllerLog(description = "个人中心-我的场景/搜索")
|
|
@@ -109,7 +112,7 @@ public class PersonalCenterController extends BaseController {
|
|
|
@PostMapping("camera/list")
|
|
|
public ResultJson cameraList(@RequestBody PageDto param){
|
|
|
|
|
|
- List<CameraEntity> list = null;
|
|
|
+ List<CameraResponse> list = null;
|
|
|
List userRole = JwtUtil2.getUserRole(getToken());
|
|
|
if (userRole.contains("admin")) {
|
|
|
list = cameraService.findAllBySearchKey(param, null);
|
|
@@ -118,7 +121,7 @@ public class PersonalCenterController extends BaseController {
|
|
|
list = cameraService.findAllBySearchKey(param, userId);
|
|
|
}
|
|
|
|
|
|
- PageInfo<CameraEntity> pageInfo = new PageInfo<>(list);
|
|
|
+ PageInfo<CameraResponse> pageInfo = new PageInfo<>(list);
|
|
|
|
|
|
return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
|
|
|
}
|
|
@@ -133,24 +136,39 @@ public class PersonalCenterController extends BaseController {
|
|
|
@RequiresPermissions("admin:camera:add")
|
|
|
@ApiOperation("新增相机")
|
|
|
@WebControllerLog(description = "设备管理-新增相机")
|
|
|
- @GetMapping("camera/save/{code}")
|
|
|
- public ResultJson save(@PathVariable String code){
|
|
|
- if(StringUtils.isEmpty(code)){
|
|
|
- return new ResultJson(MsgCode.e_COMMON_3001, MsgCode.msg_COMMON_3001);
|
|
|
- }
|
|
|
+ @PostMapping("camera/save")
|
|
|
+ public ResultJson save(@RequestBody CameraRequest param){
|
|
|
|
|
|
-
|
|
|
- CameraEntity cameraEntity = cameraService.findByWifiName(code);
|
|
|
- if(cameraEntity == null){
|
|
|
+ CameraEntity cameraEntity = null;
|
|
|
+ if (param.getId() == null) {
|
|
|
cameraEntity = new CameraEntity();
|
|
|
- cameraEntity.setChildName(code);
|
|
|
- cameraEntity.setWifiName(code);
|
|
|
+ cameraEntity.setChildName(param.getChildName());
|
|
|
+ cameraEntity.setWifiName(param.getChildName());
|
|
|
+ cameraEntity.setSnCode(param.getSnCode());
|
|
|
cameraEntity.setWifiPassword("12345678");
|
|
|
+ cameraService.save(cameraEntity);
|
|
|
|
|
|
+ CameraDetailEntity cameraDetailEntity = new CameraDetailEntity();
|
|
|
+ // 1:表示专业八目
|
|
|
+ cameraDetailEntity.setType(1);
|
|
|
+ cameraDetailEntity.setCameraId(cameraEntity.getId());
|
|
|
+ cameraDetailService.save(cameraDetailEntity);
|
|
|
+ } else {
|
|
|
+ cameraEntity = cameraService.findById(param.getId());
|
|
|
+ if (cameraEntity == null) {
|
|
|
+ return new ResultJson(MsgCode.e_COMMON_3002, MsgCode.msg_COMMON_3002);
|
|
|
+ }
|
|
|
|
|
|
- cameraService.save(cameraEntity);
|
|
|
+ BeanUtils.copyProperties(param, cameraEntity);
|
|
|
+ cameraEntity.setUpdateTime(new Date());
|
|
|
+ cameraService.update(cameraEntity);
|
|
|
+
|
|
|
+ // 目前cameraDetailEntity 是写死的,暂时不需要修改他
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.msg_SUCCESS);
|
|
|
}
|
|
|
|