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.IotAlarmGroup;
import org.springblade.device.vo.IotAlarmGroupVO;
import org.springblade.device.wrapper.IotAlarmGroupWrapper;
import org.springblade.device.service.IIotAlarmGroupService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 告警处理组 client
 *
 * @author lianghanqiang
 * @since 2021-04-19
 */

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

public class IotAlarmGroupClient implements IIotAlarmGroupClient {

    private final IIotAlarmGroupService iotAlarmGroupService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public IotAlarmGroupVO detail(@SpringQueryMap IotAlarmGroup iotAlarmGroup) {
        IotAlarmGroup detail = iotAlarmGroupService.getOne(Condition.getQueryWrapper(iotAlarmGroup));
        return IotAlarmGroupWrapper.build().entityVO(detail);
        }

    /**
     * 查询 告警处理组
     */
    @Override
    @GetMapping("/list")
    public List<IotAlarmGroupVO> list(@SpringQueryMap IotAlarmGroup iotAlarmGroup) {
        return IotAlarmGroupWrapper.build().listVO(iotAlarmGroupService.list(Condition.getQueryWrapper(iotAlarmGroup)));
        }



    /**
     * 新增 告警处理组
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody IotAlarmGroup iotAlarmGroup) {
        return iotAlarmGroupService.save(iotAlarmGroup);
        }

    /**
     * 修改 告警处理组
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody IotAlarmGroup iotAlarmGroup) {
        return iotAlarmGroupService.updateById(iotAlarmGroup);
        }

    /**
     * 新增或修改 告警处理组
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody IotAlarmGroup iotAlarmGroup) {
        return iotAlarmGroupService.saveOrUpdate(iotAlarmGroup);
        }


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


}
