Merge branch '分段预览'
# Conflicts: # chat-client/src/views/datasets/components/DocumentList.vue
This commit is contained in:
commit
73b332de51
|
|
@ -0,0 +1,9 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getSegmentList(params: { datasetId: string; documentId: string }) {
|
||||||
|
return request({
|
||||||
|
url: '/brichat-service/documentSegment/selectSegments',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.bjtds.brichat.controller;
|
||||||
|
|
||||||
|
import com.bjtds.brichat.entity.dto.SegmentDto;
|
||||||
|
import com.bjtds.brichat.service.dify.DocumentSegmentService;
|
||||||
|
import com.bjtds.brichat.util.ResultUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.checkerframework.checker.units.qual.C;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@CrossOrigin(value = "*", maxAge = 3600)
|
||||||
|
@RequestMapping("/documentSegment")
|
||||||
|
public class DocumentSegmentController {
|
||||||
|
@Autowired
|
||||||
|
private DocumentSegmentService documentSegmentService;
|
||||||
|
|
||||||
|
@GetMapping("/selectSegments")
|
||||||
|
public ResultUtils SelectSegments(@RequestParam("documentId") String documentId, @RequestParam("datasetId") String datasetId) {
|
||||||
|
List<SegmentDto> segments = documentSegmentService.SelectSegments(documentId, datasetId);
|
||||||
|
segments.sort(Comparator.comparing(SegmentDto::getPosition));
|
||||||
|
return ResultUtils.success(segments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.bjtds.brichat.mapper.postgresql;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bjtds.brichat.entity.dto.SegmentDto;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DifyDocumentSegmentMapper {
|
||||||
|
|
||||||
|
List<SegmentDto> SelectSegmentsByDocumentIdAndDatasetId(String documentId, String datasetId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.bjtds.brichat.service.dify;
|
||||||
|
|
||||||
|
import com.bjtds.brichat.entity.dto.SegmentDto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DocumentSegmentService {
|
||||||
|
|
||||||
|
List<SegmentDto> SelectSegments(String documentId, String datasetId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.bjtds.brichat.service.dify.impl;
|
||||||
|
|
||||||
|
import com.bjtds.brichat.entity.dto.SegmentDto;
|
||||||
|
import com.bjtds.brichat.mapper.postgresql.DifyDocumentSegmentMapper;
|
||||||
|
import com.bjtds.brichat.service.dify.DocumentSegmentService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DocumentSegmentServiceImpl implements DocumentSegmentService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DifyDocumentSegmentMapper difyDocumentSegmentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SegmentDto> SelectSegments(String documentId, String datasetId) {
|
||||||
|
return difyDocumentSegmentMapper.SelectSegmentsByDocumentIdAndDatasetId(documentId, datasetId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bjtds.brichat.mapper.postgresql.DifyDocumentSegmentMapper">
|
||||||
|
<select id="SelectSegmentsByDocumentIdAndDatasetId" resultType="com.bjtds.brichat.entity.dto.SegmentDto">
|
||||||
|
select *
|
||||||
|
from document_segments
|
||||||
|
where
|
||||||
|
<if test="documentId != null">
|
||||||
|
document_id = CAST(#{documentId} as uuid) and
|
||||||
|
</if>
|
||||||
|
<if test="datasetId != null">
|
||||||
|
dataset_id = CAST(#{datasetId} as uuid)
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue