package com.phm.manage.controller;

import com.phm.common.annotation.Log;
import com.phm.common.core.controller.BaseController;
import com.phm.common.core.domain.AjaxResult;
import com.phm.common.core.page.TableDataInfo;
import com.phm.common.enums.BusinessType;
import com.phm.common.utils.poi.ExcelUtil;
import com.phm.manage.domain.FeedbackRawData;
import com.phm.manage.service.IFeedbackRawDataService;
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 phm
 * @date 2023-08-22
 */
@RestController
@RequestMapping("/manage/feedbackRawData")
public class FeedbackRawDataController extends BaseController {
    @Autowired
    private IFeedbackRawDataService feedbackRawDataService;

    /**
     * 查询反馈的源数据列表
     */
    @PreAuthorize("@ss.hasPermi('manage:feedbackRawData:list')")
    @GetMapping("/list")
    public TableDataInfo list(FeedbackRawData feedbackRawData) {
        startPage();
        List<FeedbackRawData> list = feedbackRawDataService.selectFeedbackRawDataList(feedbackRawData);
        return getDataTable(list);
    }

    /**
     * 导出反馈的源数据列表
     */
    @PreAuthorize("@ss.hasPermi('manage:feedbackRawData:export')")
    @Log(title = "反馈的源数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeedbackRawData feedbackRawData) {
        List<FeedbackRawData> list = feedbackRawDataService.selectFeedbackRawDataList(feedbackRawData);
        ExcelUtil<FeedbackRawData> util = new ExcelUtil<FeedbackRawData>(FeedbackRawData.class);
        util.exportExcel(response, list, "反馈的源数据数据");
    }

    /**
     * 获取反馈的源数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:feedbackRawData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(feedbackRawDataService.selectFeedbackRawDataById(id));
    }

    /**
     * 新增反馈的源数据
     */
    @PreAuthorize("@ss.hasPermi('manage:feedbackRawData:add')")
    @Log(title = "反馈的源数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeedbackRawData feedbackRawData) {
        return toAjax(feedbackRawDataService.insertFeedbackRawData(feedbackRawData));
    }

    /**
     * 修改反馈的源数据
     */
    @PreAuthorize("@ss.hasPermi('manage:feedbackRawData:edit')")
    @Log(title = "反馈的源数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeedbackRawData feedbackRawData) {
        return toAjax(feedbackRawDataService.updateFeedbackRawData(feedbackRawData));
    }

    /**
     * 删除反馈的源数据
     */
    @PreAuthorize("@ss.hasPermi('manage:feedbackRawData:remove')")
    @Log(title = "反馈的源数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(feedbackRawDataService.deleteFeedbackRawDataByIds(ids));
    }
}
