package com.ruoyi.basic.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.basic.pojo.Vehicle;
|
import com.ruoyi.basic.service.IVehicleService;
|
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
import com.ruoyi.framework.web.domain.R;
|
import lombok.AllArgsConstructor;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
/**
|
* 车辆信息Controller
|
*
|
* @author ruoyi
|
* @date 2026-09-20
|
*/
|
@RestController
|
@RequestMapping("/basic/vehicle")
|
@AllArgsConstructor
|
public class VehicleController {
|
private IVehicleService vehicleService;
|
|
/**
|
* 分页查询车辆信息列表
|
*/
|
@GetMapping("/list")
|
public R list(Page<Vehicle> page, Vehicle vehicle) {
|
IPage<Vehicle> result = vehicleService.selectVehicleList(page, vehicle);
|
return R.ok(result);
|
}
|
|
/**
|
* 查询全部启用中的车辆(供出库表单下拉选择)
|
*/
|
@GetMapping("/all")
|
public R all() {
|
return R.ok(vehicleService.selectAll());
|
}
|
|
/**
|
* 获取车辆信息详细信息
|
*/
|
@GetMapping(value = "/{id}")
|
public R getInfo(@PathVariable("id") Long id) {
|
return R.ok(vehicleService.selectVehicleById(id));
|
}
|
|
/**
|
* 新增车辆信息
|
*/
|
@Log(title = "车辆信息", businessType = BusinessType.INSERT)
|
@PostMapping("/add")
|
public R add(@RequestBody Vehicle vehicle) {
|
return R.ok(vehicleService.insertVehicle(vehicle));
|
}
|
|
/**
|
* 修改车辆信息
|
*/
|
@Log(title = "车辆信息", businessType = BusinessType.UPDATE)
|
@PostMapping("/update")
|
public R edit(@RequestBody Vehicle vehicle) {
|
return R.ok(vehicleService.updateVehicle(vehicle));
|
}
|
|
/**
|
* 删除车辆信息
|
*/
|
@Log(title = "车辆信息", businessType = BusinessType.DELETE)
|
@DeleteMapping("/del")
|
public R remove(@RequestBody Long[] ids) {
|
if (ids == null || ids.length == 0) {
|
return R.fail("请传入要删除的ID");
|
}
|
return R.ok(vehicleService.deleteVehicleByIds(ids));
|
}
|
}
|