package org.springblade.third.doordevice.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.third.doordevice.entity.MqConf;
import org.springblade.third.doordevice.vo.MqConfVO;
import org.springblade.third.doordevice.wrapper.MqConfWrapper;
import org.springblade.third.doordevice.service.IMqConfService;

import java.util.List;
/**
 * 队列配置表 client
 *
 * @author lianghanqiang
 * @since 2021-04-27
 */

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

public class MqConfClient implements IMqConfClient {

    private final IMqConfService mqConfService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public MqConfVO detail(@SpringQueryMap MqConf mqConf) {
        MqConf detail = mqConfService.getOne(Condition.getQueryWrapper(mqConf));
        return MqConfWrapper.build().entityVO(detail);
        }

    /**
     * 查询 队列配置表
     */
    @Override
    @GetMapping("/list")
    public List<MqConfVO> list(MqConf mqConf) {
        return MqConfWrapper.build().listVO(mqConfService.list(Condition.getQueryWrapper(mqConf)));
        }



    /**
     * 新增 队列配置表
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody MqConf mqConf) {
        return mqConfService.save(mqConf);
        }

    /**
     * 修改 队列配置表
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody MqConf mqConf) {
        return mqConfService.updateById(mqConf);
        }

    /**
     * 新增或修改 队列配置表
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody MqConf mqConf) {
        return mqConfService.saveOrUpdate(mqConf);
        }


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


}
