package com.ruoyi.system.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.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.system.domain.LzydNotice;
import com.ruoyi.system.service.ILzydNoticeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公告模块Controller
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/lzyd_notice")
public class LzydNoticeController extends BaseController
{
    @Autowired
    private ILzydNoticeService lzydNoticeService;

    /**
     * 查询公告模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:lzyd_notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(LzydNotice lzydNotice)
    {
        startPage();
        List<LzydNotice> list = lzydNoticeService.selectLzydNoticeList(lzydNotice);
        return getDataTable(list);
    }

    /**
     * 导出公告模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:lzyd_notice:export')")
    @Log(title = "公告模块", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LzydNotice lzydNotice)
    {
        List<LzydNotice> list = lzydNoticeService.selectLzydNoticeList(lzydNotice);
        ExcelUtil<LzydNotice> util = new ExcelUtil<LzydNotice>(LzydNotice.class);
        return util.exportExcel(list, "lzyd_notice");
    }

    /**
     * 获取公告模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:lzyd_notice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lzydNoticeService.selectLzydNoticeById(id));
    }

    /**
     * 新增公告模块
     */
    @PreAuthorize("@ss.hasPermi('system:lzyd_notice:add')")
    @Log(title = "公告模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LzydNotice lzydNotice)
    {
        return toAjax(lzydNoticeService.insertLzydNotice(lzydNotice));
    }

    /**
     * 修改公告模块
     */
    @PreAuthorize("@ss.hasPermi('system:lzyd_notice:edit')")
    @Log(title = "公告模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LzydNotice lzydNotice)
    {
        return toAjax(lzydNoticeService.updateLzydNotice(lzydNotice));
    }

    /**
     * 删除公告模块
     */
    @PreAuthorize("@ss.hasPermi('system:lzyd_notice:remove')")
    @Log(title = "公告模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lzydNoticeService.deleteLzydNoticeByIds(ids));
    }
}
