peng
2026-03-25 2e5c2bc2b7afc7926ec441ff083acd179cb29fc6
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.tievd.jyz.controller;
 
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.tievd.cube.commons.annotations.DictMethod;
import com.tievd.cube.commons.base.Result;
import com.tievd.cube.commons.mybatisplus.QueryGenerator;
import com.tievd.cube.commons.annotations.DictApi;
import com.tievd.cube.commons.annotations.AutoLog;
import com.tievd.cube.commons.utils.SystemContextUtil;
import com.tievd.cube.commons.utils.web.HttpServletUtil;
import com.tievd.jyz.entity.CarInfo;
import com.tievd.jyz.entity.vo.CarInfoReqVo;
import com.tievd.jyz.entity.vo.CarInfoRespVo;
import com.tievd.jyz.service.ICarInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import com.tievd.cube.commons.base.CubeController;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.io.IOException;
import java.util.List;
 
/**
 * CarInfo
 *
 * @author cube
 * @version V2.0.0
 * @since 2023-02-27
 */
@Slf4j
@DictApi
@RestController
@RequestMapping("/jyz/carInfo")
@Tag(name = "车辆档案信息")
public class CarInfoController extends CubeController<CarInfo, ICarInfoService> {
    
    @Autowired
    private ICarInfoService carInfoService;
    
    /**
     * 分页列表查询
     */
    @GetMapping("/list")
    public Result<?> queryPageList(CarInfo carInfo,
                                   @RequestParam(defaultValue = "1") Integer pageNo,
                                   @RequestParam(defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<CarInfo> queryWrapper = QueryGenerator.initQueryWrapper(carInfo, req.getParameterMap());
        Page<CarInfo> page = new Page<>(pageNo, pageSize);
        IPage<CarInfo> pageList = carInfoService.page(page, queryWrapper);
        return Result.ok(pageList);
    }
    
    @GetMapping("/pageCarAllInfo")
    @DictMethod
    @Operation(summary = "分页列表")
    public Result<IPage<CarInfoRespVo>> queryPageList(CarInfoReqVo carInfo,
                                                      @RequestParam(defaultValue = "1") Integer pageNo,
                                                      @RequestParam(defaultValue = "10") Integer pageSize,
                                                      HttpServletRequest req) {
        Page page = new Page<>(pageNo, pageSize);
        IPage<CarInfoRespVo> pageList = carInfoService.pageCarAllInfo(page, carInfo);
        return Result.ok(pageList);
    }
    
    
    /**
     * 添加
     */
    @AutoLog("CarInfo-添加")
    @PostMapping("/add")
    public Result<?> add(@RequestBody CarInfo carInfo) {
        carInfoService.save(carInfo);
        return Result.ok();
    }
    
    /**
     * 编辑
     */
    @AutoLog("CarInfo-编辑")
    @PutMapping("/edit")
    public Result<?> edit(@RequestBody CarInfo carInfo) {
        carInfoService.updateById(carInfo);
        return Result.ok();
    }
    
    /**
     * 通过id删除
     */
    @AutoLog("CarInfo-通过id删除")
    @DeleteMapping("/delete")
    public Result<?> delete(@RequestParam String id) {
        carInfoService.removeById(id);
        return Result.ok();
    }
    
    /**
     * 批量删除
     */
    @AutoLog("CarInfo-批量删除")
    @DeleteMapping("/deleteBatch")
    public Result<?> deleteBatch(@RequestParam String ids) {
        this.carInfoService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.ok();
    }
    
    /**
     * 通过id查询
     */
    @GetMapping("/queryById")
    public Result<?> queryById(@RequestParam String id) {
        CarInfo carInfo = carInfoService.getById(id);
        return Result.ok(carInfo);
    }
    
    /**
     * 导出excel
     */
    @RequestMapping("/exportXls")
    public void exportXls(HttpServletResponse response, CarInfoReqVo carInfoVo) throws IOException {
        List<CarInfoRespVo> carList = carInfoService.pageCarAllInfo(new Page(1, 10000), carInfoVo).getRecords();
        HttpServletUtil.addDownloadHeader(response, "车辆档案");
        easyExcel.export(carList, response.getOutputStream(), SystemContextUtil.dictTranslator());
    }
    
    /**
     * 通过excel导入数据
     */
    @PostMapping("/importExcel")
    public Result<?> importExcel(HttpServletRequest request) throws Exception {
        return super.importExcel(request, CarInfo.class);
    }
}