package com.fs.qw.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.qw.domain.QwUserComplainRecord;
import com.fs.qw.service.IQwUserComplainRecordService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 企微员工投诉记录Controller
 *
 * @author fs
 * @date 2025-10-22
 */
@RestController
@RequestMapping("/qw/record")
public class QwUserComplainRecordController extends BaseController
{
    @Autowired
    private IQwUserComplainRecordService qwUserComplainRecordService;

    /**
     * 查询企微员工投诉记录列表
     */
    @PreAuthorize("@ss.hasPermi('qw:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwUserComplainRecord qwUserComplainRecord)
    {
        startPage();
        List<QwUserComplainRecord> list = qwUserComplainRecordService.selectQwUserComplainRecordList(qwUserComplainRecord);
        return getDataTable(list);
    }

    /**
     * 导出企微员工投诉记录列表
     */
    @PreAuthorize("@ss.hasPermi('qw:record:export')")
    @Log(title = "企微员工投诉记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwUserComplainRecord qwUserComplainRecord)
    {
        List<QwUserComplainRecord> list = qwUserComplainRecordService.selectQwUserComplainRecordList(qwUserComplainRecord);
        ExcelUtil<QwUserComplainRecord> util = new ExcelUtil<QwUserComplainRecord>(QwUserComplainRecord.class);
        return util.exportExcel(list, "企微员工投诉记录数据");
    }

    /**
     * 获取企微员工投诉记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:record:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(qwUserComplainRecordService.selectQwUserComplainRecordByRecordId(recordId));
    }

    /**
     * 新增企微员工投诉记录
     */
    @PreAuthorize("@ss.hasPermi('qw:record:add')")
    @Log(title = "企微员工投诉记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwUserComplainRecord qwUserComplainRecord)
    {
        return toAjax(qwUserComplainRecordService.insertQwUserComplainRecord(qwUserComplainRecord));
    }

    /**
     * 修改企微员工投诉记录
     */
    @PreAuthorize("@ss.hasPermi('qw:record:edit')")
    @Log(title = "企微员工投诉记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwUserComplainRecord qwUserComplainRecord)
    {
        return toAjax(qwUserComplainRecordService.updateQwUserComplainRecord(qwUserComplainRecord));
    }

    /**
     * 删除企微员工投诉记录
     */
    @PreAuthorize("@ss.hasPermi('qw:record:remove')")
    @Log(title = "企微员工投诉记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(qwUserComplainRecordService.deleteQwUserComplainRecordByRecordIds(recordIds));
    }
}
