package com.objecteye.controller; import com.objecteye.common.CommonResult; import com.objecteye.entity.PageResult; import com.objecteye.entity.UploadVehicleDbResult; import com.objecteye.service.VehicleService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; @RestController @RequestMapping("/vehicle") @Api(tags = "VehicleController", description = "车辆库车辆管理") @CrossOrigin public class VehicleController { @Autowired private VehicleService vehicleService; @ApiOperation("车辆库上传多条数据") @RequestMapping(value = "/uploadfiles", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult uploadfiles(MultipartFile[] uploadFiles, String vehicleId) { if (uploadFiles != null && uploadFiles.length > 0) { String msg = vehicleService.uploadFiles(uploadFiles, vehicleId); if (null != msg) { return CommonResult.success("操作成功", msg); } else { return null; } } return CommonResult.failed("上传文件不能为空"); } @ApiOperation("根据车库、车辆名进行分页查询车辆底库数据") @RequestMapping(value = "/findPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult findPage(@RequestParam int vehicleId, @RequestParam String picName, @RequestParam int currentpage, @RequestParam int pagevolume) { PageResult page = vehicleService.findPage(vehicleId, picName, currentpage, pagevolume); if (page.gettotal() == 0) { return CommonResult.failed("车库无数据"); } return CommonResult.success(page); } /** * 批量删除 * * @param map * @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"); vehicleService.delete(ids); return CommonResult.success("操作成功"); } catch (Exception e) { e.printStackTrace(); return CommonResult.failed(); } } /** * 修改车辆名 * * @param uploadVehicleDbResult * @return */ @ApiOperation("修改车辆名") @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult update(@RequestBody UploadVehicleDbResult uploadVehicleDbResult) { try { vehicleService.update(uploadVehicleDbResult); return CommonResult.success("操作成功"); } catch (Exception e) { e.printStackTrace(); return CommonResult.failed(); } } /** * 根据车名检索 * * @param uploadVehicleDbResult * @return */ @ApiOperation("根据车名检索") @RequestMapping(value = "/findByPicName", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult findByPicName(@RequestBody UploadVehicleDbResult uploadVehicleDbResult) { try { List uploadVehicleResultList = vehicleService.findByPicName(uploadVehicleDbResult); return CommonResult.success(uploadVehicleResultList); } catch (Exception e) { e.printStackTrace(); return CommonResult.failed(); } } }