package com.ruoyi.web.controller.system.meet;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdMeeting;
import com.ruoyi.web.controller.manager.TdMeetingManager;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * packageName com.ruoyi.web.controller.system.meet
 *
 * @author wangxy
 * @version JDK 8
 * @className TdMeetingController
 * @date 2024/8/6
 * @description 会议管理
 */
@Controller
@RequestMapping("/system/tdmeeting")
public class TdMeetingController extends BaseController {


    private String prefix = "system/tdmeeting";

    @Resource
    private TdMeetingManager meetingManager;


    @RequiresPermissions("system:tdmeeting:view")
    @GetMapping()
    public String tdmeeting() {
        return prefix + "/tdmeeting";
    }

    /**
     * 会议列表
     */
    @RequiresPermissions("system:tdmeeting:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TdMeeting tdMeeting) {
        startPage();
        List<TdMeeting> tdMeetings = meetingManager.selectTdMeetingList(tdMeeting);
        return getDataTable(tdMeetings);
    }


    /**
     * 新增会议
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增会议
     */
    @RequiresPermissions("system:tdmeeting:add")
    @Log(title = "涉密会议", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TdMeeting tdMeeting) {
        return toAjax(meetingManager.saveOrUpdate(tdMeeting));
    }

    /**
     * 修改会议
     */
    @RequiresPermissions("system:tdmeeting:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        TdMeeting meeting = meetingManager.selectTdMeeting(id);
        mmap.put("meeting", meeting);
        return prefix + "/edit";
    }

    /**
     * 修改会议
     */
    @RequiresPermissions("system:tdmeeting:edit")
    @Log(title = "涉密会议", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TdMeeting tdMeeting) {
        return toAjax(meetingManager.saveOrUpdate(tdMeeting));
    }

    /**
     * 删除会议
     */
    @RequiresPermissions("system:tdmeeting:remove")
    @Log(title = "涉密会议", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(meetingManager.deleteTdMeetingByids(ids));
    }


}
