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.VehicleInfo;
|
import com.ruoyi.vehicle.service.VehicleInfoService;
|
import com.ruoyi.vehicle.mapper.VehicleInfoMapper;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import java.time.LocalDate;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import java.util.List;
|
|
@RestController
|
@RequestMapping("/vehicle/info")
|
public class VehicleInfoController {
|
@Autowired
|
private VehicleInfoService vehicleInfoService;
|
@Autowired
|
private VehicleInfoMapper vehicleInfoMapper;
|
|
@GetMapping("/listPage")
|
public AjaxResult listPage(Page<VehicleInfo> page, VehicleInfo query) {
|
IPage<VehicleInfo> pageInfo = vehicleInfoMapper.selectVehiclePage(page, query);
|
return AjaxResult.success(pageInfo);
|
}
|
|
@GetMapping("/warningList")
|
public AjaxResult warningList() {
|
LocalDate nextMonth = LocalDate.now().plusDays(30);
|
LambdaQueryWrapper<VehicleInfo> wrapper = new LambdaQueryWrapper<>();
|
wrapper.le(VehicleInfo::getInspectionExpireDate, nextMonth).or().le(VehicleInfo::getInsuranceExpireDate, nextMonth);
|
List<VehicleInfo> list = vehicleInfoService.list(wrapper);
|
return AjaxResult.success(list);
|
}
|
|
@PostMapping
|
public AjaxResult add(@RequestBody VehicleInfo entity) {
|
return AjaxResult.success(vehicleInfoService.save(entity));
|
}
|
|
@PutMapping
|
public AjaxResult edit(@RequestBody VehicleInfo entity) {
|
return AjaxResult.success(vehicleInfoService.updateById(entity));
|
}
|
|
@DeleteMapping("/{id}")
|
public AjaxResult remove(@PathVariable Long id) {
|
return AjaxResult.success(vehicleInfoService.removeById(id));
|
}
|
}
|