hsy
2026-08-28 a8e4132c3e2e9c3b3fcb0360901b35571b6464ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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));
    }
}