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
52
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.FuelCard;
import com.ruoyi.vehicle.service.FuelCardService;
import com.ruoyi.vehicle.mapper.FuelCardMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 
@RestController
@RequestMapping("/vehicle/fuelCard")
public class FuelCardController {
    @Autowired
    private FuelCardService fuelCardService;
    @Autowired
    private FuelCardMapper fuelCardMapper;
 
    @GetMapping("/listPage")
    public AjaxResult listPage(Page<FuelCard> page, FuelCard query) {
        IPage<FuelCard> pageInfo = fuelCardMapper.selectFuelCardPage(page, query);
        return AjaxResult.success(pageInfo);
    }
 
    @GetMapping("/listAll")
    public AjaxResult listAll() {
        LambdaQueryWrapper<FuelCard> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(FuelCard::getId);
        List<FuelCard> list = fuelCardService.list(wrapper);
        return AjaxResult.success(list);
    }
 
    @PostMapping
    public AjaxResult add(@RequestBody FuelCard entity) {
        if (entity.getInitialBalance() != null) {
            entity.setCurrentBalance(entity.getInitialBalance());
        }
        return AjaxResult.success(fuelCardService.save(entity));
    }
 
    @PutMapping
    public AjaxResult edit(@RequestBody FuelCard entity) {
        return AjaxResult.success(fuelCardService.updateById(entity));
    }
 
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return AjaxResult.success(fuelCardService.removeById(id));
    }
}