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

main
topsun 2 years ago
parent 318bf0a8f5
commit b505d01cc0

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

@ -1,9 +1,16 @@
package com.taxi.servicedriveruser.controller; 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.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
@ -13,8 +20,15 @@ import org.springframework.stereotype.Controller;
* @author author * @author author
* @since 2023-04-28 * @since 2023-04-28
*/ */
@Controller @RestController
@RequestMapping("/car")
public class CarController { 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; 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; import org.springframework.stereotype.Service;
@Service @Service
public class CarService { public class CarService {
@Autowired
private CarMapper carMapper;
public ResponseResult addCar(Car car) {
carMapper.insert(car);
return ResponseResult.success();
}
} }

Loading…
Cancel
Save