添加车辆接口代码编写&测试

main
topsun 2 years ago
parent 318bf0a8f5
commit b505d01cc0

@ -166,7 +166,7 @@ public class Car implements Serializable {
/**
* 0:1
*/
private Boolean state;
private Integer state;
/**
* Id

@ -1,9 +1,16 @@
package com.taxi.servicedriveruser.controller;
import com.internal.dto.Car;
import com.internal.dto.ResponseResult;
import com.taxi.servicedriveruser.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
@ -13,8 +20,15 @@ import org.springframework.stereotype.Controller;
* @author author
* @since 2023-04-28
*/
@Controller
@RequestMapping("/car")
@RestController
public class CarController {
@Autowired
private CarService carService;
@PostMapping("/car")
public ResponseResult addCar(@RequestBody Car car){
return carService.addCar(car);
}
}

@ -1,7 +1,20 @@
package com.taxi.servicedriveruser.service;
import com.internal.dto.Car;
import com.internal.dto.ResponseResult;
import com.taxi.servicedriveruser.mapper.CarMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CarService {
@Autowired
private CarMapper carMapper;
public ResponseResult addCar(Car car) {
carMapper.insert(car);
return ResponseResult.success();
}
}

Loading…
Cancel
Save