package org.springblade.device.feign;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.device.entity.ElevatorDevice;
import org.springblade.device.vo.ElevatorDeviceVO;
import org.springblade.device.wrapper.ElevatorDeviceWrapper;
import org.springblade.device.service.IElevatorDeviceService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 云梯-电梯信息 client
 *
 * @author lianghanqiang
 * @since 2021-04-19
 */

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

public class ElevatorDeviceClient implements IElevatorDeviceClient {

    private final IElevatorDeviceService elevatorDeviceService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public ElevatorDeviceVO detail(@SpringQueryMap ElevatorDevice elevatorDevice) {
        ElevatorDevice detail = elevatorDeviceService.getOne(Condition.getQueryWrapper(elevatorDevice));
        return ElevatorDeviceWrapper.build().entityVO(detail);
        }

    /**
     * 查询 云梯-电梯信息
     */
    @Override
    @GetMapping("/list")
    public List<ElevatorDeviceVO> list(@SpringQueryMap ElevatorDevice elevatorDevice) {
        return ElevatorDeviceWrapper.build().listVO(elevatorDeviceService.list(Condition.getQueryWrapper(elevatorDevice)));
        }



    /**
     * 新增 云梯-电梯信息
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody ElevatorDevice elevatorDevice) {
        return elevatorDeviceService.save(elevatorDevice);
        }

    /**
     * 修改 云梯-电梯信息
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody ElevatorDevice elevatorDevice) {
        return elevatorDeviceService.updateById(elevatorDevice);
        }

    /**
     * 新增或修改 云梯-电梯信息
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody ElevatorDevice elevatorDevice) {
        return elevatorDeviceService.saveOrUpdate(elevatorDevice);
        }


    /**
     * 删除 云梯-电梯信息
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return elevatorDeviceService.deleteLogic(Func.toLongList(ids));
        }

	@Override
    @PostMapping("/getOne")
	public ElevatorDevice getOne(LambdaQueryWrapper<ElevatorDevice> elevatorWrapper) {
		return elevatorDeviceService.getOne(elevatorWrapper);
	}


}
