From 764d883b5ea3bdc06abbec548b6df0511e567978 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Tue, 03 Sep 2024 09:46:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/binlog' into binlog
---
src/main/java/org/springblade/es/controller/EsController.java | 84 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/es/controller/EsController.java b/src/main/java/org/springblade/es/controller/EsController.java
new file mode 100644
index 0000000..7aa4a08
--- /dev/null
+++ b/src/main/java/org/springblade/es/controller/EsController.java
@@ -0,0 +1,84 @@
+package org.springblade.es.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.annotation.PreAuth;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.constant.RoleConstant;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.es.service.ElasticsearchDocumentService;
+import org.springblade.es.vo.EsParam;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * es 全文检索
+ */
+@RestController
+@RequestMapping("/es/es")
+@AllArgsConstructor
+@Api(value = "es 全文检索", tags = "es 全文检索")
+public class EsController {
+
+ private final ElasticsearchDocumentService elasticsearchDocumentService;
+
+ /**
+ * 查询
+ */
+ @GetMapping("/page")
+ @ApiOperationSupport(order = 1)
+ public R page(EsParam esParam, Query query) {
+ return R.data(elasticsearchDocumentService.selectDocumentPage(Condition.getPage(query), esParam));
+ }
+
+ /**
+ * 初始化
+ */
+ @GetMapping("/init")
+ @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
+ @ApiOperationSupport(order = 2)
+ public R init(EsParam esParam) {
+ return R.status(elasticsearchDocumentService.init(esParam));
+ }
+
+// /**
+// * 新增数据
+// */
+// @GetMapping("/add")
+// @ApiOperationSupport(order = 3)
+// public R add(EsParam esParam) {
+// return R.status(elasticsearchDocumentService.add(esParam,null));
+// }
+//
+// /**
+// * 修改数据
+// */
+// @GetMapping("/update")
+// @ApiOperationSupport(order = 4)
+// public R update(EsParam esParam) {
+// elasticsearchDocumentService.update(esParam,null,null);
+// return R.status(true);
+// }
+
+ /**
+ * 根据索引删除
+ */
+ @PostMapping("/removeBatchByIndexNames")
+ @ApiOperationSupport(order = 5)
+ @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
+ public R removeBatchByIndexNames(@RequestParam String indexNames) {
+ return R.status(elasticsearchDocumentService.removeBatchByIndexNames(Func.toStrList(indexNames)));
+ }
+
+ /**
+ * 根据条件删除
+ */
+ @PostMapping("/removeByQuery")
+ @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
+ @ApiOperationSupport(order = 6)
+ public R removeByQuery(EsParam esParam) {
+ return R.status(elasticsearchDocumentService.removeByQuery(esParam));
+ }
+}
--
Gitblit v1.9.3