package com.ruoyi.project.plant.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.plant.domain.TConfRoom;
import com.ruoyi.project.plant.service.ITConfRoomService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 会议室管理Controller
 *
 * @author ssy
 * @date 2024-04-29
 */
@RestController
@RequestMapping("/plant/confRoom")
public class TConfRoomController extends BaseController
{
    @Autowired
    private ITConfRoomService tConfRoomService;

    /**
     * 查询会议室管理列表
     */
    @PreAuthorize("@ss.hasPermi('plant:confRoom:list')")
    @GetMapping("/list")
    public TableDataInfo list(TConfRoom tConfRoom)
    {
        startPage();
        List<TConfRoom> list = tConfRoomService.selectTConfRoomList(tConfRoom);
        return getDataTable(list);
    }

    /**
     * 导出会议室管理列表
     */
    @PreAuthorize("@ss.hasPermi('plant:confRoom:export')")
    @Log(title = "会议室管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TConfRoom tConfRoom)
    {
        List<TConfRoom> list = tConfRoomService.selectTConfRoomList(tConfRoom);
        ExcelUtil<TConfRoom> util = new ExcelUtil<TConfRoom>(TConfRoom.class);
        return util.exportExcel(list, "confRoom");
    }

    /**
     * 获取会议室管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('plant:confRoom:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tConfRoomService.selectTConfRoomById(id));
    }

    /**
     * 新增会议室管理
     */
    @PreAuthorize("@ss.hasPermi('plant:confRoom:add')")
    @Log(title = "会议室管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TConfRoom tConfRoom)
    {
        return toAjax(tConfRoomService.insertTConfRoom(tConfRoom));
    }

    /**
     * 修改会议室管理
     */
    @PreAuthorize("@ss.hasPermi('plant:confRoom:edit')")
    @Log(title = "会议室管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TConfRoom tConfRoom)
    {
        return toAjax(tConfRoomService.updateTConfRoom(tConfRoom));
    }

    /**
     * 删除会议室管理
     */
    @PreAuthorize("@ss.hasPermi('plant:confRoom:remove')")
    @Log(title = "会议室管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tConfRoomService.deleteTConfRoomByIds(ids));
    }
}
