package com.usky.meeting.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.meeting.domain.MeetingDevice;
import com.usky.meeting.service.MeetingDeviceService;
import com.usky.meeting.service.vo.MeetingDeviceRequestVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 设备表 前端控制器
 * </p>
 *
 * @author zyj
 * @since 2024-03-08
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/meetingDevice")
public class MeetingDeviceController {

    @Autowired
    private MeetingDeviceService meetingDeviceService;

    /**
     * 设备列表
     * @param requestVO
     * @return
     */
    @PostMapping("meetingDeviceList")
    public ApiResult<CommonPage<MeetingDevice>> meetingDeviceList(@RequestBody MeetingDeviceRequestVO requestVO){
        return ApiResult.success(meetingDeviceService.meetingDeviceList(requestVO));
    }

    /**
     * 新增
     * @param meetingDevice
     * @return
     */
    @PostMapping
    public ApiResult<Void> add(@RequestBody MeetingDevice meetingDevice){
        meetingDeviceService.add(meetingDevice);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param meetingDevice
     * @return
     */
    @PutMapping
    public ApiResult<Void> edit(@RequestBody MeetingDevice meetingDevice){
        meetingDeviceService.edit(meetingDevice);
        return ApiResult.success();
    }

    /**
     * 删除
     * @param deviceId
     * @return
     */
    @DeleteMapping
    public ApiResult<Void> remove(@RequestParam Long deviceId){
        meetingDeviceService.remove(deviceId);
        return ApiResult.success();
    }

}

