package com.sptg.estate.biz.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.estate.api.dto.ParkingLotDto;
import com.sptg.estate.api.entity.ParkingLot;
import com.sptg.estate.api.feigns.ParkingLotFeign;
import com.sptg.estate.biz.service.ParkingLotServiceInterface;
import lombok.RequiredArgsConstructor;
import org.springframework.util.Assert;
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.RestController;

@RestController
@RequiredArgsConstructor
public class ParkingLotController implements ParkingLotFeign {

    private final ParkingLotServiceInterface parkingLotServiceInterface;

    @Override
    @PostMapping(value = "/parkingLot/page")
    public ResultBean<Page<ParkingLot>> page(@RequestBody ParkingLotDto dto) {
        return this.parkingLotServiceInterface.page(dto);
    }

    @Override
    @PostMapping(value = "/parkingLot/add")
    public ResultBean<Boolean> add(@RequestBody ParkingLotDto dto) {
        return this.parkingLotServiceInterface.add(dto);
    }

    @Override
    @PostMapping(value = "/parkingLot/edit")
    public ResultBean<Boolean> edit(@RequestBody ParkingLotDto dto) {
        return this.parkingLotServiceInterface.edit(dto);
    }

    @Override
    @PostMapping(value = "/parkingLot/delete")
    public ResultBean<Boolean> delete(@RequestBody ParkingLotDto dto) {
        return this.parkingLotServiceInterface.delete(dto);
    }

    @Override
    @PostMapping(value = "/parkingLot/getById")
    public ParkingLot getById(@RequestBody Long id) {
        Assert.notNull(id,"id不能为空");
        return this.parkingLotServiceInterface.getById(id);
    }
}
