diff --git a/bawei-auth/src/main/resources/bootstrap.yml b/bawei-auth/src/main/resources/bootstrap.yml index 844e284..8d894ae 100644 --- a/bawei-auth/src/main/resources/bootstrap.yml +++ b/bawei-auth/src/main/resources/bootstrap.yml @@ -25,3 +25,4 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + diff --git a/bawei-base/base-es/base-es-remote/pom.xml b/bawei-base/base-es/base-es-remote/pom.xml new file mode 100644 index 0000000..820223a --- /dev/null +++ b/bawei-base/base-es/base-es-remote/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + com.bawei + base-es + 3.6.0 + + + base-es-remote + + + 17 + 17 + UTF-8 + + + diff --git a/bawei-base/base-es/base-es-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/bawei-base/base-es/base-es-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..78e39fb --- /dev/null +++ b/bawei-base/base-es/base-es-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.bawei.file.remote.factory.RemoteFileFallbackFactory diff --git a/bawei-base/base-es/base-es-server/pom.xml b/bawei-base/base-es/base-es-server/pom.xml new file mode 100644 index 0000000..66b1353 --- /dev/null +++ b/bawei-base/base-es/base-es-server/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + + com.bawei + base-es + 3.6.0 + + + base-es-server + + + 8 + 8 + UTF-8 + + + + org.elasticsearch.client + elasticsearch-rest-high-level-client + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + + + io.minio + minio + ${minio.version} + + + + + com.bawei + bawei-common-swagger + + + com.bawei + bawei-common-core + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/BaWeiEsApplication.java b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/BaWeiEsApplication.java new file mode 100644 index 0000000..700ebd8 --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/BaWeiEsApplication.java @@ -0,0 +1,24 @@ +package com.bawei.es; + +import com.bawei.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * es服务 + * + * @program: mall_cloud + * @ClassName: BaWeiEsApplication + * @author: Gyc + * @create: 2024-04-22 20:39 + **/ +@EnableCustomSwagger2 +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) +public class BaWeiEsApplication { + public static void main(String[] args) + { + SpringApplication.run(BaWeiEsApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ es服务模块启动成功 ლ(´ڡ`ლ)゙ "); + } +} diff --git a/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/controller/DocController.java b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/controller/DocController.java new file mode 100644 index 0000000..0d86fa0 --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/controller/DocController.java @@ -0,0 +1,58 @@ +package com.bawei.es.controller; + +import com.bawei.common.core.domain.R; +import com.bawei.es.service.DocService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +@RestController("/doc") +@Api(value = "es文档操作",tags = "首页") +public class DocController { + + @Autowired + private DocService docService; + + @ApiOperation(value = "根据索引名称和文档ID查询该索引文档") + @PostMapping("/getDocByIndexName/{indexName}/{id}") + public R getDocByIndexName(@PathVariable String indexName, @PathVariable String id){ + if (id!=null){ + return R.ok(docService.getDocByIndexName(indexName,id)); + } + throw new RuntimeException("文档ID不能为空"); + } + + + @ApiOperation(value = "增加es文档") + @PostMapping("/createDoc/{indexName}") + public R createDoc(@PathVariable String indexName, @RequestBody Map document){ + if (document!=null && !CollectionUtils.isEmpty(document)){ + return R.ok(docService.createDoc(indexName,document)); + } + throw new RuntimeException("添加失败,文档不可为空"); + } + + + @ApiOperation(value = "修改es文档") + @PutMapping("/putDoc/{indexName}") + public R putDoc(@PathVariable String indexName,@RequestBody Map document){ + if (document!=null && !CollectionUtils.isEmpty(document)){ + return R.ok(docService.putDoc(indexName,document)); + } + throw new RuntimeException("修改失败,文档不可为空"); + } + + + @ApiOperation(value = "删除es文档") + @DeleteMapping("/deleteDoc/{indexName}/{id}") + public R deleteDoc(@PathVariable String indexName, @PathVariable String id){ + if (id!=null){ + return R.ok(docService.deleteDoc(indexName,id)); + } + throw new RuntimeException("文档ID不能为空"); + } +} diff --git a/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/controller/IndexController.java b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/controller/IndexController.java new file mode 100644 index 0000000..c6f52f8 --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/controller/IndexController.java @@ -0,0 +1,47 @@ +package com.bawei.es.controller; + +import com.bawei.common.core.domain.R; +import com.bawei.es.service.IndexService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author gyc + */ +@RestController("/index") +@Api(value = "es索引操作",tags = "首页") +public class IndexController { + @Autowired + private IndexService indexService; + + @ApiOperation(value = "根据索引名称查询该索引是否存在") + @GetMapping("/index/{indexName}") + public R index(@PathVariable String indexName){ + return R.ok(indexService.exits(indexName)); + } + + + @ApiOperation(value = "创建索引") + @PostMapping("/create/{indexName}") + public R create(@PathVariable String indexName, @RequestBody Map mappings){ + return R.ok(indexService.create(indexName,mappings)); + } + + + @ApiOperation(value = "更新索引") + @PutMapping("/update/{indexName}") + public R update(@PathVariable String indexName,@RequestBody Map mappings){ + return R.ok(indexService.update(indexName,mappings)); + } + + + @ApiOperation(value = "删除索引") + @DeleteMapping("/delete/{indexName}") + public R delete(@PathVariable String indexName){ + return R.ok(indexService.delete(indexName)); + } +} diff --git a/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/DocService.java b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/DocService.java new file mode 100644 index 0000000..c6e91e3 --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/DocService.java @@ -0,0 +1,15 @@ +package com.bawei.es.service; + +import com.bawei.common.core.domain.R; + +import java.util.Map; + +public interface DocService { + R getDocByIndexName(String indexName, String id); + + R createDoc(String indexName, Map document); + + R putDoc(String indexName, Map document); + + R deleteDoc(String indexName, String id); +} diff --git a/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/IndexService.java b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/IndexService.java new file mode 100644 index 0000000..b69d033 --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/IndexService.java @@ -0,0 +1,15 @@ +package com.bawei.es.service; + +import com.bawei.common.core.domain.R; + +import java.util.Map; + +public interface IndexService { + Boolean exits(String indexName); + + R create(String indexName, Map mappings); + + R update(String indexName, Map mappings); + + R delete(String indexName); +} diff --git a/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/impl/DocServiceImpl.java b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/impl/DocServiceImpl.java new file mode 100644 index 0000000..d6192ba --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/impl/DocServiceImpl.java @@ -0,0 +1,136 @@ +package com.bawei.es.service.impl; + +import com.bawei.common.core.domain.R; +import com.bawei.es.service.DocService; +import org.elasticsearch.action.DocWriteResponse; +import org.elasticsearch.action.delete.DeleteRequest; +import org.elasticsearch.action.delete.DeleteResponse; +import org.elasticsearch.action.get.GetRequest; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.xcontent.XContentType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class DocServiceImpl implements DocService { + + @Autowired + private IndexServiceImpl indexServiceImpl; + + @Autowired + private RestHighLevelClient restHighLevelClient; + + /** + *根据索引名称和文档ID查询该索引文档 + * @param indexName 索引名称 + * @param id 文档ID + * @return 查询结果 + */ + @Override + public R getDocByIndexName(String indexName, String id) { + //判断索引是否存在 + if(!indexServiceImpl.exits(indexName)){ + throw new RuntimeException("该索引不存在"); + } + + //构造获取文档请求 + GetRequest getRequest = new GetRequest(indexName, id); + + try { + GetResponse getResponse = restHighLevelClient.get(getRequest, RequestOptions.DEFAULT); + + //判断文档是否存在 + if (getResponse.isExists()){ + //获取文档内容 + Map source = getResponse.getSource(); + + return R.ok(source); + }else { + throw new RuntimeException("该文档不存在"); + } + } catch (Exception e) { + throw new RuntimeException("获取文档异常,异常信息为: "+e.getMessage(),e); + } + } + + /** + * 增加es文档 + * @param indexName 索引名称 + * @param document 文档内容 + * @return 添加结果 + */ + @Override + public R createDoc(String indexName, Map document) { + if(!indexServiceImpl.exits(indexName)){ + throw new RuntimeException("该索引不存在"); + } + + //构建一个索引请求,并指定索引名称 + IndexRequest indexRequest = new IndexRequest(indexName); + indexRequest.source(document, XContentType.JSON); + + try { + IndexResponse indexResponse = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT); + if (indexResponse.getResult()== DocWriteResponse.Result.CREATED || indexResponse.getResult() == DocWriteResponse.Result.UPDATED){ + return R.ok("文档添加成功"); + }else { + throw new RuntimeException("文档添加失败"); + } + } catch (Exception e) { + throw new RuntimeException("索引请求处理异常,异常信息为: "+e.getMessage(),e); + } + } + + /** + * 修改es文档 + * @param indexName 索引名称 + * @param document 文档内容 + * @return 修改结果 + */ + @Override + public R putDoc(String indexName, Map document) { + if(!indexServiceImpl.exits(indexName)){ + throw new RuntimeException("该索引不存在"); + } + + R r = this.putDoc(indexName, document); + if (r.isSuccess()){ + return R.ok("修改成功"); + } + + throw new RuntimeException("修改失败"); + } + + /** + * 删除es文档 + * @param indexName 索引名称 + * @param id 文档ID + * @return 删除结果 + */ + @Override + public R deleteDoc(String indexName, String id) { + if(!indexServiceImpl.exits(indexName)){ + throw new RuntimeException("该索引不存在"); + } + + //构造删除文档请求 + DeleteRequest deleteRequest = new DeleteRequest(indexName, id); + + try { + DeleteResponse deleteResponse = restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT); + if (deleteResponse.getResult() == DocWriteResponse.Result.DELETED){ + return R.ok("删除成功"); + }else { + throw new RuntimeException("删除失败"); + } + } catch (Exception e) { + throw new RuntimeException("索引请求处理异常,异常信息为: "+e.getMessage(),e); + } + } +} diff --git a/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/impl/IndexServiceImpl.java b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/impl/IndexServiceImpl.java new file mode 100644 index 0000000..3e332cf --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/java/com/bawei/es/service/impl/IndexServiceImpl.java @@ -0,0 +1,127 @@ +package com.bawei.es.service.impl; + +import com.bawei.common.core.domain.R; +import com.bawei.es.service.IndexService; +import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.client.indices.CreateIndexRequest; +import org.elasticsearch.client.indices.CreateIndexResponse; +import org.elasticsearch.client.indices.GetIndexRequest; +import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class IndexServiceImpl implements IndexService { + + @Autowired + private RestHighLevelClient restHighLevelClient; + + /** + * 根据索引名称查询该索引是否存在 + * @param indexName 索引名称 + * @return 是/否 + */ + @Override + public Boolean exits(String indexName) { + GetIndexRequest indexRequest = new GetIndexRequest(indexName); + try { + boolean exists = restHighLevelClient.indices().exists(indexRequest, RequestOptions.DEFAULT); + if (exists){ + return true; + }else { + throw new RuntimeException("该索引不存在"); + } + } catch (Exception e) { + throw new RuntimeException("查找索引异常,异常信息为: "+e.getMessage(),e); + } + } + + /** + * 创建索引 + * @param indexName 索引名称 + * @param mappings 参数对象 + * @return 是/否 + */ + @Override + public R create(String indexName, Map mappings) { + Boolean exits = this.exits(indexName); + if (exits){ + throw new RuntimeException("该索引已存在"); + } + CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); + + // 将映射参数转换为 JSON 字符串并设置到索引请求中 + try { + XContentBuilder xContentBuilder = XContentFactory.jsonBuilder(); + xContentBuilder.map(mappings); + createIndexRequest.mapping(xContentBuilder); + } catch (Exception e) { + throw new RuntimeException("构建映射失败,失败原因: "+e.getMessage(),e); + } + + try { + CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT); + if (createIndexResponse.isAcknowledged()){ + return R.ok("创建成功"); + }else { + throw new RuntimeException("创建索引失败"); + } + } catch (Exception e) { + throw new RuntimeException("创建索引异常,异常信息为:"+e.getMessage(),e); + } + } + + /** + * 更新索引 + * @param indexName 索引名称 + * @param mappings 参数对象 + * @return + */ + @Override + public R update(String indexName, Map mappings) { + Boolean exits = this.exits(indexName); + if (!exits){ + throw new RuntimeException("该索引不存在"); + } + + R delete = delete(indexName); + if (delete.isSuccess()){ + create(indexName,mappings); + return R.ok("更新成功"); + }else { + throw new RuntimeException("更新失败"); + } + } + + /** + * 删除索引 + * @param indexName 索引名称 + * @return 是/否 + */ + @Override + public R delete(String indexName) { + Boolean exits = this.exits(indexName); + if (!exits){ + throw new RuntimeException("该索引不存在"); + } + try { + DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName); + AcknowledgedResponse delete = restHighLevelClient.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT); + if (delete.isAcknowledged()){ + return R.ok("删除成功"); + }else { + throw new RuntimeException("删除失败"); + } + } catch (Exception e) { + throw new RuntimeException("删除索引异常,异常信息为: "+e.getMessage(),e); + } + } + + +} diff --git a/bawei-base/base-es/base-es-server/src/main/resources/banner.txt b/bawei-base/base-es/base-es-server/src/main/resources/banner.txt new file mode 100644 index 0000000..27cacb9 --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ __ _ _ + (_) / _|(_)| | + _ __ _ _ ___ _ _ _ ______ | |_ _ | | ___ +| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \ +| | | |_| || (_) || |_| || | | | | || || __/ +|_| \__,_| \___/ \__, ||_| |_| |_||_| \___| + __/ | + |___/ \ No newline at end of file diff --git a/bawei-base/base-es/base-es-server/src/main/resources/bootstrap.yml b/bawei-base/base-es/base-es-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..ceed63e --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/resources/bootstrap.yml @@ -0,0 +1,27 @@ +# Tomcat +server: + port: 9003 + +# Spring +spring: + application: + # 应用名称 + name: bawei-es + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.220.46.186:8848 + namespace: 12345678 + config: + # 配置中心地址 + server-addr: 124.220.46.186:8848 + namespace: 12345678 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bawei-base/base-es/base-es-server/src/main/resources/logback.xml b/bawei-base/base-es/base-es-server/src/main/resources/logback.xml new file mode 100644 index 0000000..55159ec --- /dev/null +++ b/bawei-base/base-es/base-es-server/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/bawei-base/base-es/pom.xml b/bawei-base/base-es/pom.xml new file mode 100644 index 0000000..176246b --- /dev/null +++ b/bawei-base/base-es/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + com.bawei + bawei-base + 3.6.0 + + base-es + pom + + base-es es服务 + + + base-es-server + base-es-remote + + diff --git a/bawei-base/base-file/base-file-server/src/main/resources/bootstrap.yml b/bawei-base/base-file/base-file-server/src/main/resources/bootstrap.yml index 474cd96..46d7910 100644 --- a/bawei-base/base-file/base-file-server/src/main/resources/bootstrap.yml +++ b/bawei-base/base-file/base-file-server/src/main/resources/bootstrap.yml @@ -25,3 +25,14 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +api-docs: + path: v3/api-docs # 指定生成文档的路径,网关会访问这个路径来拉取文档 + group-configs: + - group: 'default' + paths-to-match: '/**' + packages-to-scan: com.keyl1me.edu.controller # 指定要扫描的包 + +knife4j: + enable: true # 开启knife4j接口文档美化 + setting: + language: zh_cn # 指定语言 diff --git a/bawei-base/base-gen/src/main/resources/bootstrap.yml b/bawei-base/base-gen/src/main/resources/bootstrap.yml index 2c345bb..efb35a9 100644 --- a/bawei-base/base-gen/src/main/resources/bootstrap.yml +++ b/bawei-base/base-gen/src/main/resources/bootstrap.yml @@ -31,3 +31,14 @@ mybatis: typeAliasesPackage: com.bawei.gen.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath:mapper/**/*.xml +api-docs: + path: v3/api-docs # 指定生成文档的路径,网关会访问这个路径来拉取文档 + group-configs: + - group: 'default' + paths-to-match: '/**' + packages-to-scan: com.keyl1me.edu.controller # 指定要扫描的包 + +knife4j: + enable: true # 开启knife4j接口文档美化 + setting: + language: zh_cn # 指定语言 diff --git a/bawei-base/base-job/src/main/resources/bootstrap.yml b/bawei-base/base-job/src/main/resources/bootstrap.yml index aa314f2..370604c 100644 --- a/bawei-base/base-job/src/main/resources/bootstrap.yml +++ b/bawei-base/base-job/src/main/resources/bootstrap.yml @@ -25,3 +25,14 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +api-docs: + path: v3/api-docs # 指定生成文档的路径,网关会访问这个路径来拉取文档 + group-configs: + - group: 'default' + paths-to-match: '/**' + packages-to-scan: com.keyl1me.edu.controller # 指定要扫描的包 + +knife4j: + enable: true # 开启knife4j接口文档美化 + setting: + language: zh_cn # 指定语言 diff --git a/bawei-base/base-system/base-system-server/src/main/resources/bootstrap.yml b/bawei-base/base-system/base-system-server/src/main/resources/bootstrap.yml index fce3afa..0c2ee44 100644 --- a/bawei-base/base-system/base-system-server/src/main/resources/bootstrap.yml +++ b/bawei-base/base-system/base-system-server/src/main/resources/bootstrap.yml @@ -25,3 +25,14 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +api-docs: + path: v3/api-docs # 指定生成文档的路径,网关会访问这个路径来拉取文档 + group-configs: + - group: 'default' + paths-to-match: '/**' + packages-to-scan: com.keyl1me.edu.controller # 指定要扫描的包 + +knife4j: + enable: true # 开启knife4j接口文档美化 + setting: + language: zh_cn # 指定语言 diff --git a/bawei-base/pom.xml b/bawei-base/pom.xml index 0d45043..5311dcd 100644 --- a/bawei-base/pom.xml +++ b/bawei-base/pom.xml @@ -13,6 +13,8 @@ base-gen base-job base-file + base-es + bawei-base diff --git a/bawei-common/bawei-common-swagger/pom.xml b/bawei-common/bawei-common-swagger/pom.xml index ec07c74..806bafc 100644 --- a/bawei-common/bawei-common-swagger/pom.xml +++ b/bawei-common/bawei-common-swagger/pom.xml @@ -29,6 +29,11 @@ springfox-swagger2 ${swagger.fox.version} + + + com.github.xiaoymin + knife4j-spring-boot-starter + diff --git a/bawei-gateway/pom.xml b/bawei-gateway/pom.xml index 4979068..358f599 100644 --- a/bawei-gateway/pom.xml +++ b/bawei-gateway/pom.xml @@ -87,7 +87,16 @@ springfox-swagger2 ${swagger.fox.version} - + + com.github.xiaoymin + knife4j-spring-boot-starter + + + + com.github.xiaoymin + knife4j-micro-spring-boot-starter + 3.0.3 + diff --git a/bawei-gateway/src/main/java/com/bawei/gateway/config/SwaggerProvider.java b/bawei-gateway/src/main/java/com/bawei/gateway/config/SwaggerProvider.java index 51476a1..73525e1 100644 --- a/bawei-gateway/src/main/java/com/bawei/gateway/config/SwaggerProvider.java +++ b/bawei-gateway/src/main/java/com/bawei/gateway/config/SwaggerProvider.java @@ -7,6 +7,7 @@ import org.springframework.cloud.gateway.config.GatewayProperties; import org.springframework.cloud.gateway.route.RouteLocator; import org.springframework.cloud.gateway.support.NameUtils; import org.springframework.context.annotation.Lazy; +import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import org.springframework.web.reactive.config.ResourceHandlerRegistry; import org.springframework.web.reactive.config.WebFluxConfigurer; @@ -19,6 +20,7 @@ import springfox.documentation.swagger.web.SwaggerResourcesProvider; * @author bawei */ @Component +@Primary public class SwaggerProvider implements SwaggerResourcesProvider, WebFluxConfigurer { /** diff --git a/bawei-mall/bawei-mall-product/bawei-mall-product-server/pom.xml b/bawei-mall/bawei-mall-product/bawei-mall-product-server/pom.xml index 02b7989..f5291d9 100644 --- a/bawei-mall/bawei-mall-product/bawei-mall-product-server/pom.xml +++ b/bawei-mall/bawei-mall-product/bawei-mall-product-server/pom.xml @@ -17,7 +17,11 @@ UTF-8 - + + com.github.xiaoymin + knife4j-spring-boot-starter + + com.alibaba.cloud diff --git a/bawei-mall/bawei-mall-product/bawei-mall-product-server/src/main/resources/bootstrap.yml b/bawei-mall/bawei-mall-product/bawei-mall-product-server/src/main/resources/bootstrap.yml index 2f158e5..097bc70 100644 --- a/bawei-mall/bawei-mall-product/bawei-mall-product-server/src/main/resources/bootstrap.yml +++ b/bawei-mall/bawei-mall-product/bawei-mall-product-server/src/main/resources/bootstrap.yml @@ -27,3 +27,14 @@ spring: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} rabbitmq: host: 124.220.46.186 +api-docs: + path: v3/api-docs # 指定生成文档的路径,网关会访问这个路径来拉取文档 + group-configs: + - group: 'default' + paths-to-match: '/**' + packages-to-scan: com.keyl1me.edu.controller # 指定要扫描的包 + +knife4j: + enable: true # 开启knife4j接口文档美化 + setting: + language: zh_cn # 指定语言 diff --git a/pom.xml b/pom.xml index 1213328..7e60288 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,8 @@ 4.1.2 3.2.2 2.13.2 + 2.0.9 + 2.0.9 @@ -302,19 +304,31 @@ 3.6.0 - + - org.elasticsearch.client - elasticsearch-rest-high-level-client - 7.17.3 + com.google.guava + guava + 20.0 + + + com.github.xiaoymin + knife4j-spring-boot-starter + + ${knife4j-spring.version} + com.bawei bawei-mall-product-cache 3.6.0 + + com.github.xiaoymin + knife4j-micro-spring-boot-starter + 3.0.3 +