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.ParkingSpaceDto;
import com.sptg.estate.api.entity.ParkingSpace;
import com.sptg.estate.api.feigns.ParkingSpaceFeign;
import com.sptg.estate.biz.service.ParkingSpaceServiceInterface;
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 ParkingSpaceController implements ParkingSpaceFeign {

    private final ParkingSpaceServiceInterface ParkingSpaceServiceInterface;

    @Override
    @PostMapping(value = "/parkingSpace/page")
    public ResultBean<Page<ParkingSpace>> page(@RequestBody ParkingSpaceDto dto) {
        return this.ParkingSpaceServiceInterface.page(dto);
    }

    @Override
    @PostMapping(value = "/parkingSpace/getById")
    public ParkingSpace getById(@RequestBody Long id) {
        Assert.notNull(id,"id不能为空");
        return this.ParkingSpaceServiceInterface.selectById(id);
    }

    @Override
    @PostMapping(value = "/parkingSpace/add")
    public ResultBean<Boolean> add(@RequestBody ParkingSpaceDto dto) {
        return this.ParkingSpaceServiceInterface.add(dto);
    }

    @Override
    @PostMapping(value = "/parkingSpace/edit")
    public ResultBean<Boolean> edit(@RequestBody ParkingSpaceDto dto) {
        return this.ParkingSpaceServiceInterface.edit(dto);
    }

    @Override
    @PostMapping(value = "/parkingSpace/delete")
    public ResultBean<Boolean> delete(@RequestBody ParkingSpaceDto dto) {
        return this.ParkingSpaceServiceInterface.delete(dto);
    }
}
