package org.jk.rag.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.jk.common.core.domain.R;
import org.jk.common.excel.utils.ExcelUtil;
import org.jk.common.idempotent.annotation.RepeatSubmit;
import org.jk.common.log.annotation.Log;
import org.jk.common.log.enums.BusinessType;
import org.jk.common.mybatis.core.page.PageQuery;
import org.jk.common.mybatis.core.page.TableDataInfo;
import org.jk.common.web.core.BaseController;
import org.jk.rag.domain.dto.ReviseSliceDTO;
import org.jk.rag.domain.entity.SliceInfo;
import org.jk.rag.domain.vo.JkReviseDocumentVo;
import org.jk.rag.domain.vo.JkReviseVo;
import org.jk.rag.domain.vo.ReviseHistoryVo;
import org.jk.rag.service.IJkReviseService;
import org.jk.system.domain.SysProject;
import org.jk.system.domain.vo.SysProjectExportVo;
import org.jk.system.service.ISysProjectService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【修订工具】Controller
 *
 * @author takai
 * @date 2025-05-28
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/deepseek/revise")
public class JkReviseController extends BaseController
{
    private final IJkReviseService reviseService;

    /**
     * 查询修正列表
     */

    @GetMapping("/pageList")
    public TableDataInfo<JkReviseVo> pageList(String knowledgeName, PageQuery pageQuery)
    {
        Page<JkReviseVo> list = reviseService.selectRevisePageList(knowledgeName,pageQuery);
        return TableDataInfo.build(list);
    }

    @GetMapping("/list")
    public R<List<JkReviseDocumentVo>> list(String documentName,String knowledgeId)
    {
        List<JkReviseDocumentVo> list = reviseService.selectReviseList(documentName,knowledgeId);
        return R.ok(list);
    }

    @GetMapping("/sliceList")
    public R<List<SliceInfo>> sliceList(String sliceText, String documentId)
    {
        List<SliceInfo> list = reviseService.selectReviseSliceList(sliceText,documentId);
        return R.ok(list);
    }

    @PutMapping("/reviseSlice")
    @RepeatSubmit
    public R<String> reviseSlice(@RequestBody ReviseSliceDTO reviseSliceDTO)
    {
        reviseService.updateReviseSlice(reviseSliceDTO);
        return R.ok("成功");
    }

    @GetMapping("/reviseHistoryList")
    public TableDataInfo reviseHistoryList(String knowledgeId,String knowledgeName,String documentName,String refDocumentName,PageQuery pageQuery)
    {
        Page<ReviseHistoryVo> list = reviseService.selectReviseHistoryList(knowledgeId,knowledgeName,documentName,refDocumentName,pageQuery);
        return TableDataInfo.build(list);
    }


}
