package org.springblade.device.feign;

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.TemperatureDevice;
import org.springblade.device.vo.TemperatureDeviceVO;
import org.springblade.device.wrapper.TemperatureDeviceWrapper;
import org.springblade.device.service.ITemperatureDeviceService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-05-14
 */

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

public class TemperatureDeviceClient implements ITemperatureDeviceClient {

    private final ITemperatureDeviceService temperatureDeviceService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public TemperatureDeviceVO detail(@SpringQueryMap TemperatureDevice temperatureDevice) {
        TemperatureDevice detail = temperatureDeviceService.getOne(Condition.getQueryWrapper(temperatureDevice));
        return TemperatureDeviceWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<TemperatureDeviceVO> list(TemperatureDevice temperatureDevice) {
        return TemperatureDeviceWrapper.build().listVO(temperatureDeviceService.list(Condition.getQueryWrapper(temperatureDevice)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody TemperatureDevice temperatureDevice) {
        return temperatureDeviceService.save(temperatureDevice);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody TemperatureDevice temperatureDevice) {
        return temperatureDeviceService.updateById(temperatureDevice);
        }

    /**
     * 新增或修改
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody TemperatureDevice temperatureDevice) {
        return temperatureDeviceService.saveOrUpdate(temperatureDevice);
        }


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


}
