新增真实删除(批量)、恢复删除(批量)接口,原逻辑删除接口中的知识库删除操作移动到真实删除接口中

topo_dev
DESKTOP-DDTUS3E\yaxin 9 months ago
parent cf178bd016
commit 184302cb9d

@ -62,6 +62,16 @@ public class ModelCaseController {
return modelCaseService.addOrUpd(modelCaseBase); return modelCaseService.addOrUpd(modelCaseBase);
} }
@DeleteMapping("/realDeleteByIds")
public R<?> realDeleteByIds(@RequestBody List<String> ids) {
return modelCaseService.realDeleteByIds(ids);
}
@PostMapping("/resetDataStatusByIds")
public R<?> resetDataStatusByIds(@RequestBody List<String> ids) {
return modelCaseService.resetDataStatusByIds(ids);
}
/** /**
* *
* @param id * @param id

@ -28,6 +28,10 @@ public interface ModelCaseService extends IService<ModelCase> {
R<?> del(String id); R<?> del(String id);
R<?> realDeleteByIds(List<String> ids);
R<?> resetDataStatusByIds(List<String> ids);
R<List<CasePerson>> getPerson(String caseId, String name); R<List<CasePerson>> getPerson(String caseId, String name);
R<?> addPerson(CasePerson person); R<?> addPerson(CasePerson person);

@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.chat.UploadParamEnum;
import com.supervision.chat.client.LangChainChatService; import com.supervision.chat.client.LangChainChatService;
import com.supervision.chat.client.dto.CreateBaseDTO; import com.supervision.chat.client.dto.CreateBaseDTO;
import com.supervision.chat.client.dto.LangChainChatRes; import com.supervision.chat.client.dto.LangChainChatRes;
@ -55,6 +54,8 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ModelCaseServiceImpl extends ServiceImpl<ModelCaseMapper, ModelCase> implements ModelCaseService { public class ModelCaseServiceImpl extends ServiceImpl<ModelCaseMapper, ModelCase> implements ModelCaseService {
private static final String DATA_STATUS_DEFAULT = "1";
private final ComDictionaryService comDictionaryService; private final ComDictionaryService comDictionaryService;
private final ModelCaseMapper modelCaseMapper; private final ModelCaseMapper modelCaseMapper;
@ -177,12 +178,7 @@ public class ModelCaseServiceImpl extends ServiceImpl<ModelCaseMapper, ModelCase
@Override @Override
public R<?> del(String id) { public R<?> del(String id) {
ModelCase modelCase = modelCaseMapper.selectById(id); ModelCase modelCase = modelCaseMapper.selectById(id);
LangChainChatRes langChainChatRes = langChainChatService.deleteBase(modelCase.getCaseNo());
if (200 != langChainChatRes.getCode()){
log.info("删除知识库失败");
}
modelCase.setDataStatus(DataStatus.NOT_AVAILABLE.getCode()); modelCase.setDataStatus(DataStatus.NOT_AVAILABLE.getCode());
int i = modelCaseMapper.updateById(modelCase); int i = modelCaseMapper.updateById(modelCase);
if (i > 0) { if (i > 0) {
@ -192,6 +188,46 @@ public class ModelCaseServiceImpl extends ServiceImpl<ModelCaseMapper, ModelCase
} }
} }
@Override
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public R<?> realDeleteByIds(List<String> ids) {
List<ModelCase> modelCases = modelCaseMapper.selectBatchIds(ids);
if (modelCases != null && !modelCases.isEmpty()) {
modelCases.forEach(modelCase -> {
LangChainChatRes<Object> langChainChatRes = langChainChatService.deleteBase(modelCase.getCaseNo());
if (200 != langChainChatRes.getCode()) {
log.error("删除知识库失败:{}, caseNo:{}", langChainChatRes.getMsg(), modelCase.getCaseNo());
throw new BusinessException("删除知识库失败");
}
});
}
int i = modelCaseMapper.deleteBatchIds(ids);
if (i > 0) {
return R.okMsg("删除成功");
} else {
return R.fail("删除失败");
}
}
@Override
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public R<?> resetDataStatusByIds(List<String> ids) {
boolean result = false;
//批量查出案件,并更新案件状态
List<ModelCase> modelCases = modelCaseMapper.selectBatchIds(ids);
if (modelCases != null && !modelCases.isEmpty()) {
modelCases.forEach(modelCase -> {
modelCase.setDataStatus(DATA_STATUS_DEFAULT);
});
result = updateBatchById(modelCases);
}
if (result) {
return R.okMsg("恢复成功");
} else {
return R.fail("恢复失败");
}
}
@Override @Override
public R<List<CasePerson>> getPerson(String caseId, String name) { public R<List<CasePerson>> getPerson(String caseId, String name) {
LambdaQueryWrapper<CasePerson> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<CasePerson> wrapper = Wrappers.lambdaQuery();

Loading…
Cancel
Save