package com.ruoyi.szxc.controller;

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.szxc.domain.SzxcWorkGuide;
import com.ruoyi.szxc.service.ISzxcWorkGuideService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 办事指南Controller
 * 
 * @author hs
 * @date 2024-03-20
 */
@RestController
@RequestMapping("/szxc/guide")
public class SzxcWorkGuideController extends BaseController
{
    @Autowired
    private ISzxcWorkGuideService szxcWorkGuideService;

    /**
     * 查询办事指南列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:guide:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzxcWorkGuide szxcWorkGuide)
    {
        startPage();
        List<SzxcWorkGuide> list = szxcWorkGuideService.selectSzxcWorkGuideList(szxcWorkGuide);
        return getDataTable(list);
    }

    /**
     * 导出办事指南列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:guide:export')")
    @Log(title = "办事指南", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzxcWorkGuide szxcWorkGuide)
    {
        List<SzxcWorkGuide> list = szxcWorkGuideService.selectSzxcWorkGuideList(szxcWorkGuide);
        ExcelUtil<SzxcWorkGuide> util = new ExcelUtil<SzxcWorkGuide>(SzxcWorkGuide.class);
        util.exportExcel(response, list, "办事指南数据");
    }

    /**
     * 获取办事指南详细信息
     */
    @PreAuthorize("@ss.hasPermi('szxc:guide:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(szxcWorkGuideService.selectSzxcWorkGuideById(id));
    }

    /**
     * 新增办事指南
     */
    @PreAuthorize("@ss.hasPermi('szxc:guide:add')")
    @Log(title = "办事指南", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzxcWorkGuide szxcWorkGuide)
    {
        return toAjax(szxcWorkGuideService.insertSzxcWorkGuide(szxcWorkGuide));
    }

    /**
     * 修改办事指南
     */
    @PreAuthorize("@ss.hasPermi('szxc:guide:edit')")
    @Log(title = "办事指南", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzxcWorkGuide szxcWorkGuide)
    {
        return toAjax(szxcWorkGuideService.updateSzxcWorkGuide(szxcWorkGuide));
    }

    /**
     * 删除办事指南
     */
    @PreAuthorize("@ss.hasPermi('szxc:guide:remove')")
    @Log(title = "办事指南", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szxcWorkGuideService.deleteSzxcWorkGuideByIds(ids));
    }
}
