package com.ruoyi.web.controller.llm;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.llm.domain.CmcDocument;
import com.ruoyi.llm.service.ICmcDocumentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * cmc聊天附件Controller
 * 
 * @author cmc
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/llm/document")
public class CmcDocumentController extends BaseController
{
    @Autowired
    private ICmcDocumentService cmcDocumentService;

    /**
     * 查询cmc聊天附件列表
     */
    @PreAuthorize("@ss.hasPermi('llm:document:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmcDocument cmcDocument)
    {
        startPage();
        List<CmcDocument> list = cmcDocumentService.selectCmcDocumentList(cmcDocument);
        return getDataTable(list);
    }

    /**
     * 导出cmc聊天附件列表
     */
    @PreAuthorize("@ss.hasPermi('llm:document:export')")
    @Log(title = "cmc聊天附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcDocument cmcDocument)
    {
        List<CmcDocument> list = cmcDocumentService.selectCmcDocumentList(cmcDocument);
        ExcelUtil<CmcDocument> util = new ExcelUtil<CmcDocument>(CmcDocument.class);
        util.exportExcel(response, list, "cmc聊天附件数据");
    }

    /**
     * 获取cmc聊天附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('llm:document:query')")
    @GetMapping(value = "/{documentId}")
    public AjaxResult getInfo(@PathVariable("documentId") String documentId)
    {
        return success(cmcDocumentService.selectCmcDocumentByDocumentId(documentId));
    }

    /**
     * 新增cmc聊天附件
     */
    @PreAuthorize("@ss.hasPermi('llm:document:add')")
    @Log(title = "cmc聊天附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcDocument cmcDocument)
    {
        return toAjax(cmcDocumentService.insertCmcDocument(cmcDocument));
    }

    /**
     * 修改cmc聊天附件
     */
    @PreAuthorize("@ss.hasPermi('llm:document:edit')")
    @Log(title = "cmc聊天附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcDocument cmcDocument)
    {
        return toAjax(cmcDocumentService.updateCmcDocument(cmcDocument));
    }

    /**
     * 删除cmc聊天附件
     */
    @PreAuthorize("@ss.hasPermi('llm:document:remove')")
    @Log(title = "cmc聊天附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{documentIds}")
    public AjaxResult remove(@PathVariable String[] documentIds)
    {
        return toAjax(cmcDocumentService.deleteCmcDocumentByDocumentIds(documentIds));
    }
}
