package com.fs.doc.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.doc.domain.DocRecordReply;
import com.fs.doc.service.IDocRecordReplyService;
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 2023-01-09
 */
@RestController
@RequestMapping("/doc/docRecordReply")
public class DocRecordReplyController extends BaseController
{
    @Autowired
    private IDocRecordReplyService docRecordReplyService;

    /**
     * 查询回复列表
     */
    @PreAuthorize("@ss.hasPermi('doc:docRecordReply:list')")
    @GetMapping("/list")
    public TableDataInfo list(DocRecordReply docRecordReply)
    {
        startPage();
        List<DocRecordReply> list = docRecordReplyService.selectDocRecordReplyList(docRecordReply);
        return getDataTable(list);
    }

    /**
     * 导出回复列表
     */
    @PreAuthorize("@ss.hasPermi('doc:docRecordReply:export')")
    @Log(title = "回复", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DocRecordReply docRecordReply)
    {
        List<DocRecordReply> list = docRecordReplyService.selectDocRecordReplyList(docRecordReply);
        ExcelUtil<DocRecordReply> util = new ExcelUtil<DocRecordReply>(DocRecordReply.class);
        return util.exportExcel(list, "docRecordReply");
    }

    /**
     * 获取回复详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:docRecordReply:query')")
    @GetMapping(value = "/{replyId}")
    public AjaxResult getInfo(@PathVariable("replyId") Long replyId)
    {
        return AjaxResult.success(docRecordReplyService.selectDocRecordReplyById(replyId));
    }

    /**
     * 新增回复
     */
    @PreAuthorize("@ss.hasPermi('doc:docRecordReply:add')")
    @Log(title = "回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocRecordReply docRecordReply)
    {
        return toAjax(docRecordReplyService.insertDocRecordReply(docRecordReply));
    }

    /**
     * 修改回复
     */
    @PreAuthorize("@ss.hasPermi('doc:docRecordReply:edit')")
    @Log(title = "回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocRecordReply docRecordReply)
    {
        return toAjax(docRecordReplyService.updateDocRecordReply(docRecordReply));
    }

    /**
     * 删除回复
     */
    @PreAuthorize("@ss.hasPermi('doc:docRecordReply:remove')")
    @Log(title = "回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{replyIds}")
    public AjaxResult remove(@PathVariable Long[] replyIds)
    {
        return toAjax(docRecordReplyService.deleteDocRecordReplyByIds(replyIds));
    }
}
