|
@@ -0,0 +1,138 @@
|
|
|
+package com.iden.bms.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.iden.bms.service.CameraService;
|
|
|
+import com.iden.common.annotation.Permission;
|
|
|
+import com.iden.common.exception.BDException;
|
|
|
+import com.iden.common.util.PageResult;
|
|
|
+import com.iden.common.util.Result;
|
|
|
+import com.iden.common.util.WebPageUtils;
|
|
|
+import com.iden.common.vo.CameraVO;
|
|
|
+import com.iden.common.vo.PageReqVO;
|
|
|
+import com.iden.common.vo.UserLogindConvertVO;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: lilt
|
|
|
+ * @Date: 2021/5/26
|
|
|
+ * @Desc:
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@Api(value = "CameraController", tags = { "摄像头管理" })
|
|
|
+@Slf4j
|
|
|
+@RequestMapping("/bms/camera")
|
|
|
+@Permission
|
|
|
+public class CameraController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CameraService cameraService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/listCamera")
|
|
|
+ @ApiOperation(value = "摄像头列表分页 ")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "type", value = "摄像头类型,1摄像机,2抓拍设备"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "district", value = "所属区域"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "subdistrict", value = "所属街道"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "communityId", value = "小区ID"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "name", value = "摄像头名称")
|
|
|
+
|
|
|
+ })
|
|
|
+ public PageResult<List<CameraVO>> listCamera(HttpServletRequest request, @RequestHeader(value = "token") String token,
|
|
|
+ @RequestParam(value = "type", required = true) String type,
|
|
|
+ @RequestParam(value = "district", required = false) String district,
|
|
|
+ @RequestParam(value = "subdistrict", required = false) String subdistrict,
|
|
|
+ @RequestParam(value = "communityId", required = false) String communityId,
|
|
|
+ @RequestParam(value = "name", required = false) String name,
|
|
|
+ PageReqVO pageReqVo){
|
|
|
+ try {
|
|
|
+ UserLogindConvertVO loginUser = WebPageUtils.getCurrentLoginedUser(request);
|
|
|
+ IPage<CameraVO> pageResponse = this.cameraService.listCamera(type,district,subdistrict,communityId,name,loginUser ,pageReqVo);
|
|
|
+ return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("摄像头列表查询-分页列表出现异常",e);
|
|
|
+ return PageResult.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("摄像头管理: 摄像头列表查询出现异常",e);
|
|
|
+ return PageResult.error( "获取列表失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/addCamera")
|
|
|
+ @ApiOperation(value = "新增摄像头")
|
|
|
+ public Result<Object> addCamera(HttpServletRequest request,@RequestHeader("token") String token,
|
|
|
+ @RequestBody CameraVO vo){
|
|
|
+ try {
|
|
|
+
|
|
|
+ UserLogindConvertVO loginUser = WebPageUtils.getCurrentLoginedUser(request);
|
|
|
+ int flag = this.cameraService.createCamera(vo,loginUser);
|
|
|
+ if (flag == 1) {
|
|
|
+ return Result.error("名称已存在!");
|
|
|
+ } if (flag == 2) {
|
|
|
+ return Result.error("编码已存在!");
|
|
|
+ } else if (flag == 0) {
|
|
|
+ return Result.success("新增成功!");
|
|
|
+ } else {
|
|
|
+ return Result.error("新增失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("新增摄像头-出现异常",e);
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("摄像头管理: 新增摄像头出现异常",e);
|
|
|
+ return Result.error("新增失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/updateCamera")
|
|
|
+ @ApiOperation(value = "修改摄像头")
|
|
|
+ public Result<Object> updateCamera(HttpServletRequest request,@RequestHeader("token") String token,
|
|
|
+ @RequestBody CameraVO vo){
|
|
|
+ try {
|
|
|
+ this.cameraService.updateCamera(vo);
|
|
|
+ return Result.success("修改成功!");
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("修改摄像头-出现异常",e);
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("摄像头管理: 修改摄像头出现异常",e);
|
|
|
+ return Result.error("修改失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getCameraInfo/{id}")
|
|
|
+ @ApiOperation(value = "摄像头详情")
|
|
|
+ public Result<CameraVO> getCameraInfo(HttpServletRequest request, @RequestHeader("token") String token, @PathVariable("id") Long id){
|
|
|
+ CameraVO orderInfo = this.cameraService.getCameraById(id);
|
|
|
+ return Result.success("查询成功!",orderInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/deleteCamera/{id}")
|
|
|
+ @ApiOperation(value = "删除摄像头")
|
|
|
+ public Result<Object> deleteCamera(HttpServletRequest request,@RequestHeader("token") String token,
|
|
|
+ @PathVariable("id") Long id){
|
|
|
+ try {
|
|
|
+ if( this.cameraService.deleteById(id)){
|
|
|
+ return Result.success("删除成功!");
|
|
|
+ } else {
|
|
|
+ return Result.error("摄像头被引用,删除失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("摄像头管理: 删除出现异常",e);
|
|
|
+ return Result.error("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|