package com.ruoyi.web.controller.branch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.branch.domain.TBranchActivityNotice;
import com.ruoyi.branch.service.ITBranchActivityNoticeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支部活动预告Controller
 * 
 * @author ruoyi
 * @date 2023-07-20
 */
@RestController
@RequestMapping("/branch/activitynotice")
public class TBranchActivityNoticeController extends BaseController
{
    @Autowired
    private ITBranchActivityNoticeService tBranchActivityNoticeService;

    /**
     * 查询支部活动预告列表
     */
    @PreAuthorize("@ss.hasPermi('branch:activitynotice:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBranchActivityNotice tBranchActivityNotice)
    {
        startPage();
        List<TBranchActivityNotice> list = tBranchActivityNoticeService.selectTBranchActivityNoticeList(tBranchActivityNotice);
        return getDataTable(list);
    }

    /**
     * 导出支部活动预告列表
     */
    @PreAuthorize("@ss.hasPermi('branch:activitynotice:export')")
    @Log(title = "支部活动预告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBranchActivityNotice tBranchActivityNotice)
    {
        List<TBranchActivityNotice> list = tBranchActivityNoticeService.selectTBranchActivityNoticeList(tBranchActivityNotice);
        ExcelUtil<TBranchActivityNotice> util = new ExcelUtil<TBranchActivityNotice>(TBranchActivityNotice.class);
        util.exportExcel(response, list, "支部活动预告数据");
    }

    /**
     * 获取支部活动预告详细信息
     */
    @PreAuthorize("@ss.hasPermi('branch:activitynotice:query')")
    @GetMapping(value = "/{noticeId}")
    public AjaxResult getInfo(@PathVariable("noticeId") Long noticeId)
    {
        return success(tBranchActivityNoticeService.selectTBranchActivityNoticeByNoticeId(noticeId));
    }

    /**
     * 新增支部活动预告
     */
    @PreAuthorize("@ss.hasPermi('branch:activitynotice:add')")
    @Log(title = "支部活动预告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBranchActivityNotice tBranchActivityNotice)
    {
        return toAjax(tBranchActivityNoticeService.insertTBranchActivityNotice(tBranchActivityNotice));
    }

    /**
     * 修改支部活动预告
     */
    @PreAuthorize("@ss.hasPermi('branch:activitynotice:edit')")
    @Log(title = "支部活动预告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBranchActivityNotice tBranchActivityNotice)
    {
        return toAjax(tBranchActivityNoticeService.updateTBranchActivityNotice(tBranchActivityNotice));
    }

    /**
     * 删除支部活动预告
     */
    @PreAuthorize("@ss.hasPermi('branch:activitynotice:remove')")
    @Log(title = "支部活动预告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticeIds}")
    public AjaxResult remove(@PathVariable Long[] noticeIds)
    {
        return toAjax(tBranchActivityNoticeService.deleteTBranchActivityNoticeByNoticeIds(noticeIds));
    }
}
