package com.payment_system.controller;

import com.alipay.api.domain.CarInfo;
import com.payment_system.entity.Car;
import com.payment_system.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car")
public class CarController {
    @Autowired
    private CarService carService;

    @PostMapping
    public boolean bind(@RequestBody Car car){
        boolean result = carService.bind(car);
        return result;
    }

    @DeleteMapping("/{userId}")
    public void unbind(@PathVariable long userId){
        carService.unbind(userId);
    }

    //查询车牌绑定情况
    @GetMapping("/{userId}")
    public boolean judge(@PathVariable long userId){
        boolean result = carService.judge(userId);
        return result;
    }

    @GetMapping("/query/{userId}")
    public com.payment_system.entity.CarInfo query(@PathVariable long userId){
        return carService.query(userId);
    }
}

