package com.ruoyi.web.controller.business;

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

/**
 * 小程序党建福利信息Controller
 * 
 * @author ruoyi
 * @date 2022-07-14
 */
@RestController
@RequestMapping("/system/welfare")
public class WelfareGuideController extends BaseController
{
    @Autowired
    private IWelfareGuideService welfareGuideService;

    /**
     * 查询小程序党建福利信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WelfareGuide welfareGuide)
    {
        startPage();
        List<WelfareGuide> list = welfareGuideService.selectWelfareGuideList(welfareGuide);
        return getDataTable(list);
    }

    /**
     * 导出小程序党建福利信息列表
     */
    @Log(title = "小程序党建福利信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WelfareGuide welfareGuide)
    {
        List<WelfareGuide> list = welfareGuideService.selectWelfareGuideList(welfareGuide);
        ExcelUtil<WelfareGuide> util = new ExcelUtil<WelfareGuide>(WelfareGuide.class);
        util.exportExcel(response, list, "小程序党建福利信息数据");
    }

    /**
     * 获取小程序党建福利信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(welfareGuideService.selectWelfareGuideById(id));
    }

    /**
     * 新增小程序党建福利信息
     */
    @Log(title = "小程序党建福利信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WelfareGuide welfareGuide)
    {
        return toAjax(welfareGuideService.insertWelfareGuide(welfareGuide));
    }

    /**
     * 修改小程序党建福利信息
     */
    @Log(title = "小程序党建福利信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WelfareGuide welfareGuide)
    {
        return toAjax(welfareGuideService.updateWelfareGuide(welfareGuide));
    }

    /**
     * 删除小程序党建福利信息
     */
    @Log(title = "小程序党建福利信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(welfareGuideService.deleteWelfareGuideByIds(ids));
    }

    /**
     * 获取最新的小程序党建福利详细信息
     */
    @GetMapping(value = "/new")
    public AjaxResult getInfoNew()
    {
        return welfareGuideService.getInfoNew();
    }
}
