package com.ruoyi.abuwx.controller;

import com.ruoyi.abuwx.domain.UserFeedbackReply;
import com.ruoyi.abuwx.service.IUserFeedbackReplyService;
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/reply")
public class UserFeedbackReplyController extends BaseController
{
    @Autowired
    private IUserFeedbackReplyService userFeedbackReplyService;

    /**
     * 查询领导回复列表
     */
    @PreAuthorize("@ss.hasPermi('user:reply:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserFeedbackReply userFeedbackReply)
    {
        startPage();
        List<UserFeedbackReply> list = userFeedbackReplyService.selectUserFeedbackReplyList(userFeedbackReply);
        return getDataTable(list);
    }

    /**
     * 导出领导回复列表
     */
    @PreAuthorize("@ss.hasPermi('user:reply:export')")
    @Log(title = "领导回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserFeedbackReply userFeedbackReply)
    {
        List<UserFeedbackReply> list = userFeedbackReplyService.selectUserFeedbackReplyList(userFeedbackReply);
        ExcelUtil<UserFeedbackReply> util = new ExcelUtil<UserFeedbackReply>(UserFeedbackReply.class);
        util.exportExcel(response, list, "领导回复数据");
    }

    /**
     * 获取领导回复详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:reply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userFeedbackReplyService.selectUserFeedbackReplyById(id));
    }

    /**
     * 新增领导回复
     */
    @PreAuthorize("@ss.hasPermi('user:reply:add')")
    @Log(title = "领导回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserFeedbackReply userFeedbackReply)
    {
        return toAjax(userFeedbackReplyService.insertUserFeedbackReply(userFeedbackReply));
    }

    /**
     * 修改领导回复
     */
    @PreAuthorize("@ss.hasPermi('user:reply:edit')")
    @Log(title = "领导回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserFeedbackReply userFeedbackReply)
    {
        return toAjax(userFeedbackReplyService.updateUserFeedbackReply(userFeedbackReply));
    }

    /**
     * 删除领导回复
     */
    @PreAuthorize("@ss.hasPermi('user:reply:remove')")
    @Log(title = "领导回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userFeedbackReplyService.deleteUserFeedbackReplyByIds(ids));
    }
}
