From 04d2e4b493964baa0827849ca14823d2ddb78459 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 10:43:12 +0800 Subject: [PATCH] =?UTF-8?q?add:=E7=9F=A5=E8=AF=86=E5=BA=93=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=96=87=E4=BB=B6=E7=BA=A7=E8=81=94=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=86=E6=AE=B5=E4=BF=A1=E6=81=AF=E5=92=8C?= =?UTF-8?q?=E5=90=91=E9=87=8F=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/KnowledgeFileInfoController.java | 8 +++++++- .../maintenance/service/KnowledgeFileInfoService.java | 7 ++++++- .../service/impl/KnowledgeFileInfoServiceImpl.java | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java index 3e6a8f8..ba97c55 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java @@ -1,8 +1,11 @@ package com.hnac.gglm.bigmodel.maintenance.controller; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; +import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileFragmentService; import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileInfoService; import com.hnac.gglm.bigmodel.maintenance.vo.IdRequest; import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; @@ -21,6 +24,8 @@ import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import java.util.List; + /** * @Author: ypj * @Date: 2024/9/10 16:44 @@ -66,7 +71,8 @@ public class KnowledgeFileInfoController { @ApiOperation(value = "删除") @ApiOperationSupport(order = 5) public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(knowledgeFileInfoService.removeByIds(Func.toLongList(",", ids))); + List idsList = Func.toLongList(",", ids); + return R.status(knowledgeFileInfoService.removeRecursive( idsList)); } @PostMapping(value = "/upload", produces = MediaType.APPLICATION_PROBLEM_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java index fb2f232..1d30668 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java @@ -9,12 +9,15 @@ import org.springblade.core.oss.model.BladeFile; import org.springblade.core.tool.api.R; import org.springframework.web.multipart.MultipartFile; +import java.util.List; + /** * @Author: ypj * @Date: 2024/9/10 16:42 */ public interface KnowledgeFileInfoService extends IService { - String SEGMENT_URL= "/kn/doc_segment"; + String SEGMENT_URL = "/kn/doc_segment"; + String VICTOR_DATABASE_NAME = "knowledge_data"; Boolean store(IdRequest req); @@ -23,4 +26,6 @@ public interface KnowledgeFileInfoService extends IService { IPage listPage(IPage page, KnowledgeFileInfo req); R upload(MultipartFile file); + + Boolean removeRecursive(List idsList); } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java index 4f4179b..309faab 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java @@ -8,12 +8,16 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.gglm.bigmodel.configuration.BigModelInvokeApi; import com.hnac.gglm.bigmodel.maintenance.constants.StoreStatus; +import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper; +import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileFragmentService; import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileInfoService; import com.hnac.gglm.bigmodel.maintenance.vo.IdRequest; import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.gglm.bigmodel.utils.RequestClientUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.oss.model.BladeFile; @@ -41,7 +45,9 @@ import java.util.Map; @DS("hznlm") public class KnowledgeFileInfoServiceImpl extends ServiceImpl implements KnowledgeFileInfoService { private final KnowledgeFileInfoMapper knowledgeFileInfoMapper; + private final KnowledgeFileFragmentService fileFragmentService; private final IOssClient ossClient; + private final BigModelInvokeApi invokeApi; @Value("${gglm.url}") private String interactionUrl; @@ -110,4 +116,16 @@ public class KnowledgeFileInfoServiceImpl extends ServiceImpl upload(MultipartFile file) { return ossClient.putFile(file); } + + @Override + public Boolean removeRecursive(List idsList) { + Boolean result = removeByIds(idsList); + if (result) { + fileFragmentService.remove(Wrappers.lambdaQuery().in(KnowledgeFileFragment::getDocId, idsList)); + Map deleteTableParams = new HashMap<>(1); + deleteTableParams.put("table_name", VICTOR_DATABASE_NAME); + RequestClientUtil.postCall(interactionUrl + invokeApi.getDeleteTable(), deleteTableParams); + } + return result; + } }