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

/**
 * 心愿管理Controller
 * 
 * @author hs
 * @date 2024-04-03
 */
@RestController
@RequestMapping("/szxc/wish")
public class SzxcWishManageController extends BaseController
{
    @Autowired
    private ISzxcWishManageService szxcWishManageService;

    /**
     * 查询心愿管理列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:wish:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzxcWishManage szxcWishManage)
    {
        startPage();
        List<SzxcWishManage> list = szxcWishManageService.selectSzxcWishManageList(szxcWishManage);
        return getDataTable(list);
    }

    /**
     * 导出心愿管理列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:wish:export')")
    @Log(title = "心愿管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzxcWishManage szxcWishManage)
    {
        List<SzxcWishManage> list = szxcWishManageService.selectSzxcWishManageList(szxcWishManage);
        ExcelUtil<SzxcWishManage> util = new ExcelUtil<SzxcWishManage>(SzxcWishManage.class);
        util.exportExcel(response, list, "心愿管理数据");
    }

    /**
     * 获取心愿管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('szxc:wish:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(szxcWishManageService.selectSzxcWishManageById(id));
    }

    /**
     * 新增心愿管理
     */
    @PreAuthorize("@ss.hasPermi('szxc:wish:add')")
    @Log(title = "心愿管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzxcWishManage szxcWishManage)
    {
        return toAjax(szxcWishManageService.insertSzxcWishManage(szxcWishManage));
    }

    /**
     * 修改心愿管理
     */
    @PreAuthorize("@ss.hasPermi('szxc:wish:edit')")
    @Log(title = "心愿管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzxcWishManage szxcWishManage)
    {
        return toAjax(szxcWishManageService.updateSzxcWishManage(szxcWishManage));
    }

    /**
     * 删除心愿管理
     */
    @PreAuthorize("@ss.hasPermi('szxc:wish:remove')")
    @Log(title = "心愿管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szxcWishManageService.deleteSzxcWishManageByIds(ids));
    }
}
