package com.ics.admin.controller.meeting;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ics.common.core.domain.R;
import com.ics.common.core.controller.BaseController;
import com.ics.admin.domain.meeting.RoomEquipment;
import com.ics.admin.service.meeting.IRoomEquipmentService;
import org.wf.jwtp.annotation.RequiresPermissions;

/**
 * 房间和设备关联 提供者
 *
 * @author chen
 * @date 2024-02-25
 */
@RestController
@RequestMapping("/meeting/roomEquipment")
public class RoomEquipmentController extends BaseController {

    @Autowired
    private IRoomEquipmentService roomEquipmentService;

    /**
     * 查询房间和设备关联
     */
    @GetMapping("get/{id}")
    public RoomEquipment get(@PathVariable("id") Long id) {
        return roomEquipmentService.selectRoomEquipmentById(id);
    }

    /**
     * 查询房间和设备关联列表
     */
    @RequiresPermissions("meeting:roomEquipment:list")
    @GetMapping("list")
    public R list(RoomEquipment roomEquipment) {
        startPage();
        return result(roomEquipmentService.selectRoomEquipmentList(roomEquipment));
    }


    /**
     * 新增保存房间和设备关联
     */
    @RequiresPermissions("meeting:roomEquipment:add")
    @PostMapping("save")
    public R addSave(@RequestBody RoomEquipment roomEquipment) {
        return toAjax(roomEquipmentService.insertRoomEquipment(roomEquipment));
    }

    /**
     * 修改保存房间和设备关联
     */
    @RequiresPermissions("meeting:roomEquipment:edit")
    @PostMapping("update")
    public R editSave(@RequestBody RoomEquipment roomEquipment) {
        return toAjax(roomEquipmentService.updateRoomEquipment(roomEquipment));
    }

    /**
     * 删除房间和设备关联
     */
    @RequiresPermissions("meeting:roomEquipment:remove")
    @PostMapping("remove")
    public R remove(String ids) {
        return toAjax(roomEquipmentService.deleteRoomEquipmentByIds(ids));
    }

}
