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.IotAlarmGroupUser;
import org.springblade.device.vo.IotAlarmGroupUserVO;
import org.springblade.device.wrapper.IotAlarmGroupUserWrapper;
import org.springblade.device.service.IIotAlarmGroupUserService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 告警分组和用户关联表 client
 *
 * @author lianghanqiang
 * @since 2021-04-19
 */

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

public class IotAlarmGroupUserClient implements IIotAlarmGroupUserClient {

    private final IIotAlarmGroupUserService iotAlarmGroupUserService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public IotAlarmGroupUserVO detail(@SpringQueryMap IotAlarmGroupUser iotAlarmGroupUser) {
        IotAlarmGroupUser detail = iotAlarmGroupUserService.getOne(Condition.getQueryWrapper(iotAlarmGroupUser));
        return IotAlarmGroupUserWrapper.build().entityVO(detail);
        }

    /**
     * 查询 告警分组和用户关联表
     */
    @Override
    @GetMapping("/list")
    public List<IotAlarmGroupUserVO> list(IotAlarmGroupUser iotAlarmGroupUser) {
        return IotAlarmGroupUserWrapper.build().listVO(iotAlarmGroupUserService.list(Condition.getQueryWrapper(iotAlarmGroupUser)));
        }



    /**
     * 新增 告警分组和用户关联表
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody IotAlarmGroupUser iotAlarmGroupUser) {
        return iotAlarmGroupUserService.save(iotAlarmGroupUser);
        }

    /**
     * 修改 告警分组和用户关联表
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody IotAlarmGroupUser iotAlarmGroupUser) {
        return iotAlarmGroupUserService.updateById(iotAlarmGroupUser);
        }

    /**
     * 新增或修改 告警分组和用户关联表
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody IotAlarmGroupUser iotAlarmGroupUser) {
        return iotAlarmGroupUserService.saveOrUpdate(iotAlarmGroupUser);
        }


    /**
     * 删除 告警分组和用户关联表
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return iotAlarmGroupUserService.deleteLogic(Func.toLongList(ids));
        }


}
