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