|  |  | 
 |  |  | import com.doumee.config.annotation.CloudRequiredPermission; | 
 |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
 |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
 |  |  | import com.doumee.core.model.ApiResponse; | 
 |  |  | import com.doumee.core.model.PageData; | 
 |  |  | import com.doumee.core.model.PageWrap; | 
 |  |  | import com.doumee.service.business.third.model.ApiResponse; | 
 |  |  | import com.doumee.service.business.third.model.PageData; | 
 |  |  | import com.doumee.service.business.third.model.PageWrap; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.dao.business.model.Cars; | 
 |  |  | import com.doumee.service.business.CarsService; | 
 |  |  | import com.doumee.service.business.ParkBookService; | 
 |  |  | import com.doumee.service.business.impl.hksync.fhk.HkSyncVehicleFromHKServiceImpl; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | import io.swagger.annotations.*; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  | import org.springframework.web.multipart.MultipartFile; | 
 |  |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | import java.io.File; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.List; | 
 |  |  | /** | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private CarsService carsService; | 
 |  |  |     @Autowired | 
 |  |  |     private ParkBookService parkBookService; | 
 |  |  |     @Autowired | 
 |  |  |     private HkSyncVehicleFromHKServiceImpl hkSyncVehicleFromHKService; | 
 |  |  |  | 
 |  |  |     @PreventRepeat | 
 |  |  | 
 |  |  |     @PostMapping("/create") | 
 |  |  |     @CloudRequiredPermission("business:cars:create") | 
 |  |  |     public ApiResponse create(@RequestBody Cars cars,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
 |  |  |         cars.setLoginUserInfo(this.getLoginUser(token)); | 
 |  |  |         return ApiResponse.success(carsService.create(cars)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     @GetMapping("/delete/{id}") | 
 |  |  |     @CloudRequiredPermission("business:cars:delete") | 
 |  |  |     public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
 |  |  |         carsService.deleteById(id); | 
 |  |  |         carsService.deleteById(id,this.getLoginUser(token)); | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         for (String id : idArray) { | 
 |  |  |             idList.add(Integer.valueOf(id)); | 
 |  |  |         } | 
 |  |  |         carsService.deleteByIdInBatch(idList); | 
 |  |  |         carsService.deleteByIdInBatch(idList,this.getLoginUser(token)); | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     @PostMapping("/updateById") | 
 |  |  |     @CloudRequiredPermission("business:cars:update") | 
 |  |  |     public ApiResponse updateById(@RequestBody Cars cars,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
 |  |  |         cars.setLoginUserInfo(this.getLoginUser(token)); | 
 |  |  |         carsService.updateById(cars); | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |     } | 
 |  |  | 
 |  |  |     @PostMapping("/page") | 
 |  |  |     @CloudRequiredPermission("business:cars:query") | 
 |  |  |     public ApiResponse<PageData<Cars>> findPage (@RequestBody PageWrap<Cars> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
 |  |  |         pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token)); | 
 |  |  |         return ApiResponse.success(carsService.findPage(pageWrap)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     @PostMapping("/list") | 
 |  |  |     @CloudRequiredPermission("business:cars:query") | 
 |  |  |     public ApiResponse<List<Cars>> findList (@RequestBody Cars cars,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
 |  |  |        cars.setLoginUserInfo(this.getLoginUser(token)); | 
 |  |  |         return ApiResponse.success(carsService.findList(cars)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     @PostMapping("/exportExcel") | 
 |  |  |     @CloudRequiredPermission("business:cars:exportExcel") | 
 |  |  |     public void exportExcel (@RequestBody PageWrap<Cars> pageWrap, HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
 |  |  |         pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token)); | 
 |  |  |         ExcelExporter.build(Cars.class).export(carsService.findPage(pageWrap).getRecords(), "车辆信息表", response); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     public ApiResponse findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
 |  |  |         return ApiResponse.success(carsService.findById(id)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "车辆信息导入" ,notes = "车辆信息导入") | 
 |  |  |     @PostMapping("/importExcel") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "file", value = "file", required = true, paramType = "query", dataType = "file", dataTypeClass = File.class), | 
 |  |  |     }) | 
 |  |  |     @CloudRequiredPermission("business:cars:create") | 
 |  |  |     public ApiResponse<String> importExcel (@ApiParam(value = "file") MultipartFile file, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
 |  |  |         List<Cars> carsList = carsService.importBatch(file,this.getLoginUser(token)); | 
 |  |  |         //异步更新车辆授权数据 | 
 |  |  |         carsService.dealCarsAuthBiz(carsList); | 
 |  |  |         return ApiResponse.success("导入成功"); | 
 |  |  |     } | 
 |  |  | } |