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

/**
 * 公益报名情况Controller
 * 
 * @author hs
 * @date 2024-03-20
 */
@RestController
@RequestMapping("/szxc/apply")
public class SzxcGyApplyController extends BaseController
{
    @Autowired
    private ISzxcGyApplyService szxcGyApplyService;

    /**
     * 查询公益报名情况列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:apply:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzxcGyApply szxcGyApply)
    {
        startPage();
        List<SzxcGyApply> list = szxcGyApplyService.selectSzxcGyApplyList(szxcGyApply);
        return getDataTable(list);
    }

    /**
     * 导出公益报名情况列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:apply:export')")
    @Log(title = "公益报名情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzxcGyApply szxcGyApply)
    {
        List<SzxcGyApply> list = szxcGyApplyService.selectSzxcGyApplyList(szxcGyApply);
        ExcelUtil<SzxcGyApply> util = new ExcelUtil<SzxcGyApply>(SzxcGyApply.class);
        util.exportExcel(response, list, "公益报名情况数据");
    }

    /**
     * 获取公益报名情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('szxc:apply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(szxcGyApplyService.selectSzxcGyApplyById(id));
    }

    /**
     * 新增公益报名情况
     */
    @PreAuthorize("@ss.hasPermi('szxc:apply:add')")
    @Log(title = "公益报名情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzxcGyApply szxcGyApply)
    {
        return toAjax(szxcGyApplyService.insertSzxcGyApply(szxcGyApply));
    }

    /**
     * 修改公益报名情况
     */
    @PreAuthorize("@ss.hasPermi('szxc:apply:edit')")
    @Log(title = "公益报名情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzxcGyApply szxcGyApply)
    {
        return toAjax(szxcGyApplyService.updateSzxcGyApply(szxcGyApply));
    }

    /**
     * 删除公益报名情况
     */
    @PreAuthorize("@ss.hasPermi('szxc:apply:remove')")
    @Log(title = "公益报名情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szxcGyApplyService.deleteSzxcGyApplyByIds(ids));
    }
}
