package org.springblade.estate.feign;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springblade.estate.entity.ParkingArea;
import org.springblade.estate.entity.ParkingLot;
import org.springblade.estate.entity.ParkingSpace;
import org.springblade.estate.service.IParkingAreaService;
import org.springblade.estate.service.IParkingSpaceService;
import org.springblade.estate.vo.ParkingAreaVO;
import org.springblade.estate.vo.ParkingSpaceVO;
import org.springblade.estate.wrapper.ParkingAreaWrapper;
import org.springblade.estate.wrapper.ParkingLotWrapper;
import org.springblade.estate.wrapper.ParkingSpaceWrapper;
import org.springblade.system.expand.feign.IOrgPositionClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 车位信息 client
 *
 * @author lianghanqiang
 * @since 2021-03-30
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/parkingarea")

public class ParkingAreaClient implements IParkingAreaClient {

	private IParkingAreaService parkingAreaService;

	@Override
	@GetMapping("/detail")
	public ParkingAreaVO detail(ParkingArea parkingArea) {
		ParkingArea detail = parkingAreaService.getOne(Condition.getQueryWrapper(parkingArea));
		return ParkingAreaWrapper.build().entityVO(detail);
	}

	@Override
	@GetMapping("/list")
	public List<ParkingAreaVO> list(ParkingArea parkingArea) {
		return ParkingAreaWrapper.build().listVO(parkingAreaService.list(Condition.getQueryWrapper(parkingArea)));
	}

	@Override
	@PostMapping("/save")
	public boolean save(ParkingArea parkingArea) {
		return parkingAreaService.save(parkingArea);
	}

	@Override
	@PostMapping("/update")
	public boolean update(ParkingArea parkingArea) {
		return parkingAreaService.updateById(parkingArea);
	}

	@Override
	@PostMapping("/submit")
	public boolean submit(ParkingArea parkingArea) {
		return parkingAreaService.saveOrUpdate(parkingArea);
	}

	@Override
	@PostMapping("/remove")
	public boolean remove(String ids) {
		return parkingAreaService.deleteLogic(Func.toLongList(ids));
	}
}
