package com.fs.his.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.domain.FsHisComplaint;
import com.fs.his.service.IFsHisComplaintService;
import com.fs.his.vo.FsUserComplaintVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户投诉Controller
 *
 * @author fs
 * @date 2025-06-09
 */
@RestController
@RequestMapping("/his/complaint")
public class FsHisComplaintController extends BaseController
{
    @Autowired
    private IFsHisComplaintService fsUserComplaintService;

    /**
     * 查询用户投诉列表
     */
    @PreAuthorize("@ss.hasPermi('his:complaint:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsHisComplaint fsHisComplaint)
    {
        startPage();
        List<FsUserComplaintVo> list = fsUserComplaintService.selectFsUserComplaintList(fsHisComplaint);
        return getDataTable(list);
    }

    /**
     * 导出用户投诉列表
     */
    @PreAuthorize("@ss.hasPermi('his:complaint:export')")
    @Log(title = "用户投诉", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsHisComplaint fsHisComplaint)
    {
        List<FsUserComplaintVo> list = fsUserComplaintService.selectFsUserComplaintList(fsHisComplaint);
        ExcelUtil<FsUserComplaintVo> util = new ExcelUtil<FsUserComplaintVo>(FsUserComplaintVo.class);
        return util.exportExcel(list, "用户投诉数据");
    }

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

    /**
     * 新增用户投诉
     */
    @PreAuthorize("@ss.hasPermi('his:complaint:add')")
    @Log(title = "用户投诉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsHisComplaint fsHisComplaint)
    {
        return toAjax(fsUserComplaintService.insertFsUserComplaint(fsHisComplaint));
    }

    /**
     * 修改用户投诉
     */
    @PreAuthorize("@ss.hasPermi('his:complaint:edit')")
    @Log(title = "用户投诉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsHisComplaint fsHisComplaint)
    {
        return toAjax(fsUserComplaintService.updateFsUserComplaint(fsHisComplaint));
    }

    /**
     * 删除用户投诉
     */
    @PreAuthorize("@ss.hasPermi('his:complaint:remove')")
    @Log(title = "用户投诉", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsUserComplaintService.deleteFsUserComplaintByIds(ids));
    }
}
