package com.usky.meeting.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
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
     */
    @Log(title = "新增-会议屏设备", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult<Void> add(@RequestBody MeetingDevice meetingDevice){
        meetingDeviceService.add(meetingDevice);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param meetingDevice
     * @return
     */
    @Log(title = "修改-会议设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult<Void> edit(@RequestBody MeetingDevice meetingDevice){
        meetingDeviceService.edit(meetingDevice);
        return ApiResult.success();
    }

    /**
     * 删除
     * @param deviceUuid
     * @return
     */
    @Log(title = "删除-会议设备", businessType = BusinessType.DELETE)
    @DeleteMapping
    public ApiResult<Void> remove(@RequestParam Long deviceUuid){
        meetingDeviceService.remove(deviceUuid);
        return ApiResult.success();
    }

}

