63 lines
1.7 KiB
Java
63 lines
1.7 KiB
Java
package com.muyu.web.controller;
|
|
|
|
import com.muyu.web.common.Result;
|
|
import com.muyu.web.domain.VehicleInfo;
|
|
import com.muyu.web.domain.req.VehicleCreateAddReq;
|
|
import com.muyu.web.service.VehicleInfoService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author DongZeLiang
|
|
* @version 1.0
|
|
* @description 用户控制层
|
|
* @date 2023/11/9
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/vehicle")
|
|
public class VehicleController {
|
|
|
|
@Autowired
|
|
private VehicleInfoService vehicleInfoService;
|
|
|
|
@GetMapping("/list")
|
|
public Result<List<VehicleInfo>> list(){
|
|
return Result.success(vehicleInfoService.list());
|
|
}
|
|
|
|
/**
|
|
* 根据输入的数量进行车辆随机生成
|
|
* @param sum 车辆总数
|
|
* @return 结果集
|
|
*/
|
|
@GetMapping("/gen/{sum}")
|
|
public Result<String> generate(@PathVariable(value = "sum") Integer sum){
|
|
vehicleInfoService.generate(sum);
|
|
return Result.success();
|
|
}
|
|
/**
|
|
* 根据输入的数量进行车辆随机生成
|
|
* @param vehicleCreateAddReq 车辆总数
|
|
* @return 结果集
|
|
*/
|
|
@PostMapping("/create")
|
|
public Result<String> create(@RequestBody VehicleCreateAddReq vehicleCreateAddReq){
|
|
vehicleInfoService.create(vehicleCreateAddReq.getVinStr());
|
|
return Result.success();
|
|
}
|
|
|
|
|
|
/**
|
|
* 删除车辆
|
|
* @param vin 车辆总数
|
|
* @return 结果集
|
|
*/
|
|
@DeleteMapping("/{vin}")
|
|
public Result<String> delete(@PathVariable("vin") String vin){
|
|
this.vehicleInfoService.delete(vin);
|
|
return Result.success(null,"删除成功");
|
|
}
|
|
}
|