package com.ruoyi.web.controller.urge;

import javax.servlet.http.HttpServletResponse;

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

import java.util.List;

/**
 * 政协催办Controller
 *
 * @author boman
 * @date 2024-03-12
 */
@RestController
@RequestMapping("/zxUrge/urge")
public class ZxUrgeController extends BaseController
{
    @Autowired
    private IZxUrgeService zxUrgeService;

/**
 * 查询政协催办列表
 */
@PreAuthorize("@ss.hasPermi('zxUrge:urge:list')")
@GetMapping("/list")
    public TableDataInfo list(ZxUrge zxUrge)
    {
        startPage();
        List<ZxUrge> list = zxUrgeService.selectZxUrgeList(zxUrge);
        return getDataTable(list);
    }

    /**
     * 导出政协催办列表
     */
    @PreAuthorize("@ss.hasPermi('zxUrge:urge:export')")
    @Log(title = "政协催办", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxUrge zxUrge)
    {
        List<ZxUrge> list = zxUrgeService.selectZxUrgeList(zxUrge);
        ExcelUtil<ZxUrge> util = new ExcelUtil<ZxUrge>(ZxUrge.class);
        util.exportExcel(response, list, "政协催办数据");
    }

    /**
     * 获取政协催办详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxUrge:urge:query')")
    @GetMapping(value = "/{zxUrgeId}")
    public AjaxResult getInfo(@PathVariable("zxUrgeId") Long zxUrgeId)
    {
        return success(zxUrgeService.selectZxUrgeByZxUrgeId(zxUrgeId));
    }

    /**
     * 新增政协催办
     */
    @PreAuthorize("@ss.hasPermi('zxUrge:urge:add')")
    @Log(title = "政协催办", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxUrge zxUrge)
    {
        return toAjax(zxUrgeService.insertZxUrge(zxUrge));
    }

    /**
     * 修改政协催办
     */
    @PreAuthorize("@ss.hasPermi('zxUrge:urge:edit')")
    @Log(title = "政协催办", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ZxUrge zxUrge)
    {
        return toAjax(zxUrgeService.updateZxUrge(zxUrge));
    }

    /**
     * 删除政协催办
     */
    @PreAuthorize("@ss.hasPermi('zxUrge:urge:remove')")
    @Log(title = "政协催办", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{zxUrgeIds}")
    public AjaxResult remove(@PathVariable Long[] zxUrgeIds)
    {
        return toAjax(zxUrgeService.deleteZxUrgeByZxUrgeIds(zxUrgeIds));
    }
}
