package org.springblade.third.iotdevice.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.springblade.third.iotdevice.entity.IotSysConf;
import org.springblade.third.iotdevice.service.IIotSysConfService;
import org.springblade.third.iotdevice.vo.IotSysConfVO;
import org.springblade.third.iotdevice.wrapper.IotSysConfWrapper;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;

import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-05-28
 */

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

public class IotSysConfClient implements IIotSysConfClient {

    private final IIotSysConfService iotSysConfService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public IotSysConfVO detail(@SpringQueryMap IotSysConf iotSysConf) {
        IotSysConf detail = iotSysConfService.getOne(Condition.getQueryWrapper(iotSysConf));
        return IotSysConfWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<IotSysConfVO> list(IotSysConf iotSysConf) {
        return IotSysConfWrapper.build().listVO(iotSysConfService.list(Condition.getQueryWrapper(iotSysConf)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody IotSysConf iotSysConf) {
        return iotSysConfService.save(iotSysConf);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody IotSysConf iotSysConf) {
        return iotSysConfService.updateById(iotSysConf);
        }

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


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


}
