package com.ruoyi.abuwx.controller;

import com.ruoyi.abuwx.domain.UserFeedback;
import com.ruoyi.abuwx.service.IUserFeedbackService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 用户反馈管理Controller
 * 
 * @author lujie
 * @date 2025-01-20
 */
@RestController
@RequestMapping("/user/feedback")
public class UserFeedbackController extends BaseController
{
    @Autowired
    private IUserFeedbackService userFeedbackService;

    /**
     * 查询用户反馈管理列表
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserFeedback userFeedback)
    {
        startPage();
        List<UserFeedback> list = userFeedbackService.selectUserFeedbackList(userFeedback);
        return getDataTable(list);
    }

    /**
     * 导出用户反馈管理列表
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:export')")
    @Log(title = "用户反馈管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserFeedback userFeedback)
    {
        List<UserFeedback> list = userFeedbackService.selectUserFeedbackList(userFeedback);
        ExcelUtil<UserFeedback> util = new ExcelUtil<UserFeedback>(UserFeedback.class);
        util.exportExcel(response, list, "用户反馈管理数据");
    }

    /**
     * 获取用户反馈管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userFeedbackService.selectUserFeedbackById(id));
    }

    /**
     * 新增用户反馈管理
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:add')")
    @Log(title = "用户反馈管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserFeedback userFeedback)
    {
        return toAjax(userFeedbackService.insertUserFeedback(userFeedback));
    }

    /**
     * 修改用户反馈管理
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:edit')")
    @Log(title = "用户反馈管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserFeedback userFeedback)
    {
        return toAjax(userFeedbackService.updateUserFeedback(userFeedback));
    }

    /**
     * 删除用户反馈管理
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:remove')")
    @Log(title = "用户反馈管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userFeedbackService.deleteUserFeedbackByIds(ids));
    }
}
