package com.ruoyi.web.bst;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.complaint.domain.ComplaintQuery;
import com.ruoyi.bst.complaint.domain.ComplaintVO;
import com.ruoyi.bst.complaint.service.ComplaintService;
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;

/**
 * 投诉Controller
 *
 * @author ruoyi
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/bst/complaint")
public class ComplaintController extends BaseController
{
    @Autowired
    private ComplaintService complaintService;

    /**
     * 查询投诉列表
     */
    @PreAuthorize("@ss.hasPermi('bst:complaint:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComplaintQuery query)
    {
        startPage();
        startOrderBy();
        List<ComplaintVO> list = complaintService.selectComplaintList(query);
        return getDataTable(list);
    }

    /**
     * 导出投诉列表
     */
    @PreAuthorize("@ss.hasPermi('bst:complaint:export')")
    @Log(title = "投诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ComplaintQuery query)
    {
        List<ComplaintVO> list = complaintService.selectComplaintList(query);
        ExcelUtil<ComplaintVO> util = new ExcelUtil<ComplaintVO>(ComplaintVO.class);
        util.exportExcel(response, list, "投诉数据");
    }

    /**
     * 获取投诉详细信息
     */
    @PreAuthorize("@ss.hasPermi('bst:complaint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(complaintService.selectComplaintById(id));
    }
}
