package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.WyFeedback;
import com.ruoyi.system.service.IWyFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 意见反馈Controller
 * 
 * @author ruoyi
 * @date 2025-02-19
 */
@Api(tags = "意见反馈相关接口")
@RestController
@RequestMapping("/system/feedback")
public class WyFeedbackController extends BaseController
{
    @Autowired
    private IWyFeedbackService wyFeedbackService;

    /**
     * 查询意见反馈列表
     */
    @ApiOperation("查询意见反馈列表")
    @PreAuthorize("@ss.hasPermi('system:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyFeedback wyFeedback)
    {
        startPage();
        List<WyFeedback> list = wyFeedbackService.selectWyFeedbackList(wyFeedback);
        return getDataTable(list);
    }

    /**
     * 导出意见反馈列表
     */
    @ApiOperation("查询意见反馈列表")
    @PreAuthorize("@ss.hasPermi('system:feedback:export')")
    @Log(title = "意见反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyFeedback wyFeedback)
    {
        List<WyFeedback> list = wyFeedbackService.selectWyFeedbackList(wyFeedback);
        ExcelUtil<WyFeedback> util = new ExcelUtil<WyFeedback>(WyFeedback.class);
        util.exportExcel(response, list, "意见反馈数据");
    }

    /**
     * 获取意见反馈详细信息
     */
    @ApiOperation("查询意见反馈列表")
    @PreAuthorize("@ss.hasPermi('system:feedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyFeedbackService.selectWyFeedbackById(id));
    }

    /**
     * 新增意见反馈
     */
//    @ApiOperation("查询意见反馈列表")
//    @PreAuthorize("@ss.hasPermi('system:feedback:add')")
//    @Log(title = "意见反馈", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody WyFeedback wyFeedback)
//    {
//        return toAjax(wyFeedbackService.insertWyFeedback(wyFeedback));
//    }

    /**
     * 修改意见反馈
     */
    @ApiOperation("查询意见反馈列表")
    @PreAuthorize("@ss.hasPermi('system:feedback:edit')")
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyFeedback wyFeedback)
    {
        return toAjax(wyFeedbackService.updateWyFeedback(wyFeedback));
    }

    /**
     * 删除意见反馈
     */
    @ApiOperation("查询意见反馈列表")
    @PreAuthorize("@ss.hasPermi('system:feedback:remove')")
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyFeedbackService.deleteWyFeedbackByIds(ids));
    }
}
