haungxing
3 months ago
4 changed files with 105 additions and 25 deletions
@ -0,0 +1,38 @@
|
||||
package com.hnac.hzims.bigmodel.database.controller; |
||||
|
||||
import com.hnac.hzims.bigmodel.database.dto.WeaviateSaveDTO; |
||||
import com.hnac.hzims.bigmodel.database.service.WeaviateService; |
||||
import io.weaviate.client.v1.data.model.WeaviateObject; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/09/04 14:16 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/weaviate") |
||||
public class WeaviateController { |
||||
|
||||
private final WeaviateService weaviateService; |
||||
|
||||
@PostMapping("/saveBatch") |
||||
public R<Boolean> saveBatch(@RequestBody WeaviateSaveDTO req) { |
||||
weaviateService.saveBatch(req.getEntities(), req.getClassName(), req.getAttrsMap()); |
||||
return R.success("操作成功!"); |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
public R<List<WeaviateObject>> list(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) { |
||||
return R.data(weaviateService.list(id,className)); |
||||
} |
||||
|
||||
@DeleteMapping("/removeById") |
||||
public R<Boolean> removeById(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) { |
||||
return R.status(weaviateService.delete(id,className)); |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.hnac.hzims.bigmodel.database.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/09/04 14:36 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class WeaviateSaveDTO implements Serializable { |
||||
|
||||
/** |
||||
* 向量数据库表名 |
||||
*/ |
||||
private String className; |
||||
|
||||
/** |
||||
* 向量数据库属性名 |
||||
*/ |
||||
private Map<String,String> attrsMap; |
||||
|
||||
/** |
||||
* 向量数据库存入对象列表 |
||||
*/ |
||||
private List entities; |
||||
|
||||
} |
Loading…
Reference in new issue