package com.ruoyi.web.controller.system;

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

/**
 * 政协_附件Controller
 *
 * @author boman
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/zx/fj")
public class ZxFjController extends BaseController
{
    @Autowired
    private IZxFjService zxFjService;

/**
 * 查询政协_附件列表
 */
@PreAuthorize("@ss.hasPermi('system:fj:list')")
@GetMapping("/list")
    public TableDataInfo list(ZxFj zxFj)
    {
        startPage();
        List<ZxFj> list = zxFjService.selectZxFjList(zxFj);
        return getDataTable(list);
    }

    /**
     * 导出政协_附件列表
     */
    @PreAuthorize("@ss.hasPermi('system:fj:export')")
    @Log(title = "政协_附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxFj zxFj)
    {
        List<ZxFj> list = zxFjService.selectZxFjList(zxFj);
        ExcelUtil<ZxFj> util = new ExcelUtil<ZxFj>(ZxFj.class);
        util.exportExcel(response, list, "政协_附件数据");
    }

    /**
     * 获取政协_附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zxFjService.selectZxFjById(id));
    }

    /**
     * 新增政协_附件
     */
    @PreAuthorize("@ss.hasPermi('system:fj:add')")
    @Log(title = "政协_附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxFj zxFj)
    {
        return toAjax(zxFjService.insertZxFj(zxFj));
    }

    /**
     * 修改政协_附件
     */
    @PreAuthorize("@ss.hasPermi('system:fj:edit')")
    @Log(title = "政协_附件", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ZxFj zxFj)
    {
        return toAjax(zxFjService.updateZxFj(zxFj));
    }

    /**
     * 删除政协_附件
     */
    @PreAuthorize("@ss.hasPermi('system:fj:remove')")
    @Log(title = "政协_附件", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zxFjService.deleteZxFjByIds(ids));
    }
}
