package com.ruoyi.vehicle.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.vehicle.pojo.FuelRecord; import com.ruoyi.vehicle.service.FuelRecordService; import com.ruoyi.vehicle.mapper.FuelRecordMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/vehicle/fuelRecord") public class FuelRecordController { @Autowired private FuelRecordService fuelRecordService; @Autowired private FuelRecordMapper fuelRecordMapper; @GetMapping("/listPage") public AjaxResult listPage(Page page, FuelRecord query, String beginDate, String endDate) { IPage pageInfo = fuelRecordMapper.selectFuelRecordPage(page, query, beginDate, endDate); return AjaxResult.success(pageInfo); } @PostMapping public AjaxResult add(@RequestBody FuelRecord entity) { return AjaxResult.success(fuelRecordService.saveRecord(entity)); } @PutMapping public AjaxResult edit(@RequestBody FuelRecord entity) { return AjaxResult.success(fuelRecordService.updateRecord(entity)); } @DeleteMapping("/{id}") public AjaxResult remove(@PathVariable Long id) { return AjaxResult.success(fuelRecordService.removeRecordById(id)); } @PostMapping("/submit/{id}") public AjaxResult submit(@PathVariable Long id) { try { fuelRecordService.submitRecord(id); return AjaxResult.success(); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } @PostMapping("/revoke/{id}") public AjaxResult revoke(@PathVariable Long id) { try { fuelRecordService.revokeRecord(id); return AjaxResult.success(); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } }