package com.objecteye.controller; import com.objecteye.common.CommonResult; import com.objecteye.entity.PageResult; import com.objecteye.entity.SyVehicleDb; import com.objecteye.service.DeployService; import com.objecteye.service.VehicleDbService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; /** * controller * * @author Administrator */ @RestController @Api(tags = "VehicleDbController", description = "车辆库管理") @RequestMapping("/vehicleDb") @CrossOrigin public class VehicleDbController { @Autowired private VehicleDbService vehicleDbService; @Autowired private DeployService deployService; /** * 返回全部列表 * * @return */ @ApiOperation("分页返回全部车库") @RequestMapping(value = "/findPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult findPage(@RequestParam int currentpage, @RequestParam int pagevolume) { PageResult page = vehicleDbService.findPage(currentpage, pagevolume); if (page.gettotal() == 0) { return CommonResult.failed("无符合条件的数据"); } return CommonResult.success(page); } /** * 增加 * * @param vehicel * @return */ @ApiOperation("添加车库") @RequestMapping(value = "/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult add(@RequestBody SyVehicleDb vehicel) { String id = vehicleDbService.add(vehicel); if (id != null) { return CommonResult.success(id); } return CommonResult.failed(); } /** * @param feature * @return */ @ApiOperation("更新车库") @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult update(@RequestBody SyVehicleDb feature) { vehicleDbService.update(feature); return CommonResult.success(null); } /** * 获取实体 * * @param * @return */ @ApiOperation("查找车库") @RequestMapping(value = "/findOne", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult findOne(@RequestBody Map map) { String id = (String) map.get("id"); SyVehicleDb feature = vehicleDbService.findOne(id); if (feature != null) { return CommonResult.success(feature); } return CommonResult.success("", "id无效"); } /** * 批量删除 * * @param * @return */ @ApiOperation("删除车库") @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult delete(@RequestBody Map map) { try { List ids = (List) map.get("ids"); vehicleDbService.delete(ids); return CommonResult.success(""); } catch (Exception e) { e.printStackTrace(); return CommonResult.failed(e.getMessage()); } } /** * 判断车辆库是否被使用 * * @param map 请求参数 * @return 操作状态 */ @ApiOperation("判断车辆库是否被使用") @RequestMapping(value = "/checkDelete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult checkDeleteByLibIdDeployType(@RequestBody Map map) { List deploys = deployService.getDeployListByLibAndDeployType((String) map.get("id"), 1); if (deploys != null && deploys.size() > 0) { return CommonResult.success(201, "存在布控任务使用该车辆库", ""); } else { return CommonResult.success(200, "不存在布控任务使用该车辆库", ""); } } /** * 人像库下拉框 * * @return */ @ApiOperation("车库下拉框") @RequestMapping(value = "/findAllName", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult findAllName() { List> all = vehicleDbService.findAllName(); if (all.size() > 0) { return CommonResult.success(all); } return CommonResult.success("", "车库为空"); } }