package com.ruoyi.web.controller.branch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.branch.domain.TBranchMeeting;
import com.ruoyi.branch.service.ITBranchMeetingService;
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.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支部会议管理Controller
 * 
 * @author ruoyi
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/branch/meeting")
public class TBranchMeetingController extends BaseController
{
    @Autowired
    private ITBranchMeetingService tBranchMeetingMgrService;

    /**
     * 查询支部会议管理列表
     */
    @PreAuthorize("@ss.hasPermi('branch:meeting:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBranchMeeting tBranchMeeting)
    {
        startPage();
        List<TBranchMeeting> list = tBranchMeetingMgrService.selectTBranchMeetingMgrList(tBranchMeeting);
        return getDataTable(list);
    }

    /**
     * 导出支部会议管理列表
     */
    @PreAuthorize("@ss.hasPermi('branch:meeting:export')")
    @Log(title = "支部会议管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBranchMeeting tBranchMeeting)
    {
        List<TBranchMeeting> list = tBranchMeetingMgrService.selectTBranchMeetingMgrList(tBranchMeeting);
        ExcelUtil<TBranchMeeting> util = new ExcelUtil<TBranchMeeting>(TBranchMeeting.class);
        util.exportExcel(response, list, "支部会议管理数据");
    }

    /**
     * 获取支部会议管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('branch:meeting:query')")
    @GetMapping(value = "/{meetingId}")
    public AjaxResult getInfo(@PathVariable("meetingId") Long meetingId)
    {
        return success(tBranchMeetingMgrService.selectTBranchMeetingMgrByMeetingId(meetingId));
    }

    /**
     * 新增支部会议管理
     */
    @PreAuthorize("@ss.hasPermi('branch:meeting:add')")
    @Log(title = "支部会议管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBranchMeeting tBranchMeeting)
    {
        return toAjax(tBranchMeetingMgrService.insertTBranchMeetingMgr(tBranchMeeting));
    }

    /**
     * 修改支部会议管理
     */
    @PreAuthorize("@ss.hasPermi('branch:meeting:edit')")
    @Log(title = "支部会议管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBranchMeeting tBranchMeeting)
    {
        return toAjax(tBranchMeetingMgrService.updateTBranchMeetingMgr(tBranchMeeting));
    }

    /**
     * 删除支部会议管理
     */
    @PreAuthorize("@ss.hasPermi('branch:meeting:remove')")
    @Log(title = "支部会议管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{meetingIds}")
    public AjaxResult remove(@PathVariable Long[] meetingIds)
    {
        return toAjax(tBranchMeetingMgrService.deleteTBranchMeetingMgrByMeetingIds(meetingIds));
    }
}
