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.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.device.entity.GbDeviceChannel;
import org.springblade.device.vo.GbDeviceChannelVO;
import org.springblade.device.wrapper.GbDeviceChannelWrapper;
import org.springblade.device.service.IGbDeviceChannelService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-12-06
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/gbdevicechannel")
public class GbDeviceChannelClient implements IGbDeviceChannelClient {

    private final IGbDeviceChannelService gbDeviceChannelService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public GbDeviceChannelVO detail(GbDeviceChannel gbDeviceChannel) {
        GbDeviceChannel detail = gbDeviceChannelService.getOne(Condition.getQueryWrapper(gbDeviceChannel));
        return GbDeviceChannelWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<GbDeviceChannelVO> list(GbDeviceChannel gbDeviceChannel) {
        return GbDeviceChannelWrapper.build().listVO(gbDeviceChannelService.list(Condition.getQueryWrapper(gbDeviceChannel)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody GbDeviceChannel gbDeviceChannel) {
        return gbDeviceChannelService.save(gbDeviceChannel);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody GbDeviceChannel gbDeviceChannel) {
        return gbDeviceChannelService.updateById(gbDeviceChannel);
        }

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


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

	/**
	 * 批量新增或修改
	 */
	@Override
	@PostMapping("/submitBatch")
	public R submitBatch(@RequestBody List<GbDeviceChannel> gbDeviceChannelList) {
		return gbDeviceChannelService.submitBatch(gbDeviceChannelList);
	}


}
