mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-14 05:03:43 +08:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a178d0ef8 | ||
|
|
b64b758263 | ||
|
|
a68c6481ba | ||
|
|
3cbacb5ed9 | ||
|
|
38667797d3 | ||
|
|
9a6acb84a4 | ||
|
|
e3c8a84849 | ||
|
|
cc349f5954 | ||
|
|
e4b78e0510 | ||
|
|
15c6cd272e | ||
|
|
1614eff008 | ||
|
|
c86e88ebd1 | ||
|
|
39ebd85f58 | ||
|
|
bde82fe516 | ||
|
|
2ca650db76 | ||
|
|
e3da640737 | ||
|
|
e1dea1d9e2 | ||
|
|
84b8d6f675 | ||
|
|
8563428bf9 | ||
|
|
7b3b727c0e | ||
|
|
08098ff3f3 | ||
|
|
fb492d41f3 | ||
|
|
9c2586ab43 | ||
|
|
1bddf5df3b | ||
|
|
57b2f833f8 | ||
|
|
7907cbeb7f | ||
|
|
9cfcdd2b9b | ||
|
|
980df20752 | ||
|
|
aa92d232bb | ||
|
|
81c0bb5738 | ||
|
|
1a645c6e10 | ||
|
|
731f6ceb6e | ||
|
|
8e21245348 | ||
|
|
936e157e4a | ||
|
|
256f72c487 | ||
|
|
009aa5f1a5 | ||
|
|
d22d2cb708 | ||
|
|
59104028b6 | ||
|
|
c2f6a8321a |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,6 +13,8 @@ target/
|
||||
|
||||
ruoyi-modules/ruoyi-generator/src/main/resources/vm/vben5
|
||||
|
||||
README.md
|
||||
|
||||
######################################################################
|
||||
# IDE
|
||||
|
||||
|
||||
64
README.md
64
README.md
@@ -59,24 +59,16 @@
|
||||
### 系统体验
|
||||
- 用户端:https://web.pandarobot.chat
|
||||
- 管理端:https://admin.pandarobot.chat
|
||||
|
||||
用户名: admin 密码:admin123
|
||||
- 用户名: admin 密码:admin123
|
||||
|
||||
### 源码地址
|
||||
|
||||
[1]gitee
|
||||
- 前端服务-用户端: https://gitee.com/ageerle/ruoyi-web
|
||||
- 前端服务-管理端: https://gitee.com/ageerle/ruoyi-admin
|
||||
- 前端服务-小程序端: https://gitee.com/ageerle/ruoyi-uniapp
|
||||
- 后端服务:https://gitee.com/ageerle/ruoyi-ai
|
||||
|
||||
[2]github
|
||||
[1]github
|
||||
- 前端服务-用户端: https://github.com/ageerle/ruoyi-web
|
||||
- 前端服务-管理端: https://github.com/ageerle/ruoyi-admin
|
||||
- 前端服务-小程序端: https://github.com/ageerle/ruoyi-uniapp
|
||||
- 后端服务:https://github.com/ageerle/ruoyi-ai
|
||||
|
||||
[3]gitcode
|
||||
[2]gitcode
|
||||
- 前端服务-用户端:https://gitcode.com/ageerle/ruoyi-web
|
||||
- 前端服务-管理端: https://gitcode.com/ageerle/ruoyi-admin
|
||||
- 前端服务-小程序端: https://gitcode.com/ageerle/ruoyi-uniapp
|
||||
@@ -86,27 +78,25 @@
|
||||
- 配套文档: https://doc.pandarobot.chat
|
||||
- 项目部署文档:https://doc.pandarobot.chat/guide/introduction/
|
||||
|
||||
### 核心功能
|
||||
1. 全套开源系统:提供完整的前端应用、后台管理以及小程序应用,基于MIT协议,开箱即用。
|
||||
2. 本地RAG方案:集成Milvus/Weaviate向量库、本地向量化模型与Ollama,实现本地化RAG。
|
||||
3. 丰富插件功能:支持联网、SQL查询插件及Text2API插件,扩展系统能力与应用场景。
|
||||
4. 内置SSE、websocket等网络协议,支持对接多种大语言模型,同时还集成了MidJourney和DALLE AI绘画功能。
|
||||
5. 强大的多媒体功能:支持AI翻译、PPT制作、语音克隆和翻唱等。
|
||||
6. 扩展功能:支持将大模型接入个人或企业微信。
|
||||
7. 支付功能:支持易支付、微信支付等多种支付方式。
|
||||
### 核心功能与技术亮点
|
||||
#### 1. 全栈式开源系统
|
||||
- 全套开源系统:提供完整的前端应用、后台管理以及小程序应用,基于MIT协议,开箱即用。
|
||||
#### 2. 本地化 RAG 方案
|
||||
- 基于 **Langchain4j** 框架,支持 Milvus/Weaviate/Qdrant 向量库,结合 BGE-large-zh-v1.5 本地向量化模型 实现高效文档检索与知识库构建。
|
||||
- 支持 本地 LLM 接入,结合私有知识库实现安全可控的问答系统,避免依赖云端服务的隐私风险。
|
||||
#### 3. 多模态 AI 引擎与工具集成
|
||||
- 智能对话:支持 OpenAI GPT-4、Azure、ChatGLM 等主流模型,内置 SSE/WebSocket 协议实现低延迟交互,兼容 **扣子**、**DIFY** 等平台 API 调用。
|
||||
- **Spring AI MCP** 支持:通过注解快速定义本地工具,支持调用 MCP 广场 的海量 MCP Server 服务,扩展模型能力边界。
|
||||
#### 4. 企业级扩展与商业化支持
|
||||
- 即时通讯集成:支持对接个人微信、企业微信及微信公众号,实现消息自动回复、用户管理与智能客服。
|
||||
- 支付系统:集成易支付、微信支付、Stripe 国际信用卡支付,满足商业化场景需求。
|
||||
#### 5. 多媒体处理与创新功能
|
||||
- AI 绘画:集成 DALL·E-3、MidJourney、Stable Diffusion,支持文生图、图生图及风格化创作,适用于营销素材生成与创意设计。
|
||||
- PPT 制作:根据文本输入自动生成结构化幻灯片,支持自定义模板(需要使用三方平台 如:文多多)。
|
||||
|
||||
### 项目演示
|
||||
|
||||
#### mcp支持
|
||||
|
||||
### 如何使用
|
||||
1. ruoyi-admin\src\main\resources\application.yml中mcp.client.enabled改为true
|
||||
2. application.yml中配置openai api-key(用于推理使用那个工具,并构建工具所需参数)
|
||||
3. 启动[ruoyi-mcp-server]
|
||||
4. [mcp-server.json]中配置fileSystem.command(npx本地安装路径)
|
||||
5. 指定fileSystem操作目录(本地必须存在指定的目录)
|
||||
6. 配置search1api.env.SEARCH1API_KEY 申请地址:https://www.search1api.com/
|
||||
7. 详情教程:https://blog.csdn.net/weixin_42416319/article/details/147385808
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;">
|
||||
<img src="image/mcp-01.png" alt="drawing" style="width: 600px; height: 300px; border: 2px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"/>
|
||||
<img src="image/mcp-02.png" alt="drawing" style="width: 600px; height: 300px; border: 2px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"/>
|
||||
@@ -122,7 +112,6 @@
|
||||
<img src="image/05.png" alt="drawing" style="width: 600px; height: 300px; border: 2px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"/>
|
||||
</div>
|
||||
|
||||
|
||||
#### 用户端
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;">
|
||||
<img src="image/08.png" alt="drawing" style="width: 600px; height: 300px; border: 2px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"/>
|
||||
@@ -204,7 +193,6 @@
|
||||
### 注意事项
|
||||
- vben模板
|
||||
|
||||
|
||||
Q:vben5 的模板默认是没有的吗?
|
||||
|
||||
A:vben模板是收费的 请联系vben-vue-plus作者获取。
|
||||
@@ -214,7 +202,6 @@
|
||||
该项目使用Git进行版本管理。您可以在repository参看当前可用版本。
|
||||
|
||||
|
||||
|
||||
### 版权说明
|
||||
|
||||
该项目使用了MIT授权许可,详情请参阅 [LICENSE.txt](https://github.com/ageerle/ruoyi-ai/blob/main/LICENSE)
|
||||
@@ -251,7 +238,7 @@
|
||||
|
||||
#### 项目文档
|
||||
1. 项目文档基于vitepress构建
|
||||
2. 按照[如何参与开源项目](#如何参与开源项目)拉取 https://github.com/ageerle/ruoyi-doc
|
||||
2. 按照[如何参与开源项目](#如何参与开源项目)拉取https://github.com/ageerle/ruoyi-doc
|
||||
3. 安装依赖:npm install
|
||||
4. 启动项目:npm run docs:dev
|
||||
5. 主页路径:docs/guide/introduction/index.md
|
||||
@@ -277,12 +264,16 @@
|
||||
[license-url]: https://github.com/ageerle/ruoyi-ai/blob/master/LICENSE.txt
|
||||
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
|
||||
|
||||
## 🌿 第三方生态
|
||||
- [PPIO 派欧云:一键调用高性价比的开源模型 API 和 GPU 容器](https://ppinfra.com/user/register?invited_by=P8QTUY&utm_source=github_ruoyi-ai)
|
||||
|
||||
### 附:技术讨论群
|
||||
|
||||
#### 全面开放,欢迎加入
|
||||
#### 进群学习
|
||||
🏠 wx:ruoyi-ai(加人备注:ruoyi-ai)
|
||||
|
||||
<img src="image/小助手wx.png" alt="drawing" style="width: 400px; height: 400px; border: 2px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"/>
|
||||
|
||||
🏠 qq:1603234088 (加人备注:ruoyi-ai)
|
||||
|
||||
👏👏👏 ruoyi-ai官方交流1群(qq区):1034554687
|
||||
@@ -291,10 +282,3 @@
|
||||
<img src="image/QQ区-官方交流1群.png" alt="drawing" style="width: 400px; height: 400px; border: 2px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"/>
|
||||
</div>
|
||||
|
||||
👏👏👏 ruoyi-ai官方交流4群(微信区):
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;">
|
||||
<img src="image/WX区-官方交流4群.jpg" alt="drawing" style="width: 400px; height: 400px; border: 2px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
image/小助手wx.png
Normal file
BIN
image/小助手wx.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 302 KiB |
2
pom.xml
2
pom.xml
@@ -20,7 +20,7 @@
|
||||
<java.version>17</java.version>
|
||||
<mysql.version>8.0.33</mysql.version>
|
||||
<mybatis.version>3.5.16</mybatis.version>
|
||||
<springdoc.version>2.1.0</springdoc.version>
|
||||
<springdoc.version>2.8.5</springdoc.version>
|
||||
<therapi-javadoc.version>0.15.0</therapi-javadoc.version>
|
||||
<poi.version>5.2.3</poi.version>
|
||||
<easyexcel.version>3.2.1</easyexcel.version>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package org.ruoyi.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@@ -215,13 +215,18 @@ mybatis-encryptor:
|
||||
publicKey:
|
||||
privateKey:
|
||||
|
||||
# Swagger配置
|
||||
swagger:
|
||||
springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: true
|
||||
# swagger-ui:
|
||||
# # 持久化认证数据
|
||||
# persistAuthorization: true
|
||||
info:
|
||||
# 标题
|
||||
title: '标题:${ruoyi.name}多租户管理系统_接口文档'
|
||||
title: '标题:RuoYi-Vue-Plus多租户管理系统_接口文档'
|
||||
# 描述
|
||||
description: '描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...'
|
||||
description: ' 用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...'
|
||||
# 版本
|
||||
version: '版本号: ${ruoyi.version}'
|
||||
# 作者信息
|
||||
@@ -236,24 +241,10 @@ swagger:
|
||||
type: APIKEY
|
||||
in: HEADER
|
||||
name: ${sa-token.token-name}
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: true
|
||||
swagger-ui:
|
||||
# 持久化认证数据
|
||||
persistAuthorization: true
|
||||
#这里定义了两个分组,可定义多个,也可以不定义
|
||||
group-configs:
|
||||
- group: 1.演示模块
|
||||
packages-to-scan: org.ruoyi.demo
|
||||
- group: 2.通用模块
|
||||
packages-to-scan: org.ruoyi.web
|
||||
- group: 3.系统模块
|
||||
- group: 1.系统模块
|
||||
packages-to-scan: org.ruoyi.system
|
||||
- group: 4.代码生成模块
|
||||
packages-to-scan: org.ruoyi.generator
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
|
||||
BIN
ruoyi-admin/src/main/resources/static/favicon.ico
Normal file
BIN
ruoyi-admin/src/main/resources/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
@@ -159,12 +159,20 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 微信模块 -->
|
||||
<dependency>
|
||||
<groupId>org.ruoyi</groupId>
|
||||
<artifactId>ruoyi-chat</artifactId>
|
||||
<artifactId>ruoyi-common-wechat</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 支付模块 -->
|
||||
<dependency>
|
||||
<groupId>org.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-pay</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -6,7 +6,6 @@ import cn.hutool.core.date.DateUnit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @date 2023-03-10
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.ruoyi.common.chat.constant;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-06
|
||||
@@ -10,6 +9,8 @@ public class OpenAIConst {
|
||||
|
||||
public final static String OPENAI_HOST = "https://api.openai.com/";
|
||||
|
||||
public final static String apiUrl = "v1/chat/completions";
|
||||
|
||||
public final static int SUCCEED_CODE = 200;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:金额消耗信息
|
||||
* 金额消耗信息
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-08
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 描述:余额查询接口返回值
|
||||
* 余额查询接口返回值
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-18
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:金额消耗列表
|
||||
* 金额消耗列表
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-08
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-18
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-18
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 描述:金额消耗列表
|
||||
* 金额消耗列表
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-08
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-08
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 描述:账户信息
|
||||
* 账户信息
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-08
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
import static org.ruoyi.common.chat.entity.chat.BaseChatCompletion.Model.GPT_3_5_TURBO;
|
||||
|
||||
/**
|
||||
* 描述: chat模型基础类
|
||||
* chat模型基础类
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 1.1.2
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 1.1.2
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-02
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: chat模型参数
|
||||
* chat模型参数
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-03-02
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: chat答案类
|
||||
* chat答案类
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-03-02
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: chat模型附带图片的参数
|
||||
* : chat模型附带图片的参数
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 1.1.2
|
||||
|
||||
@@ -6,7 +6,6 @@ import lombok.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https://www.unfbx.com
|
||||
* @since 1.1.2
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 描述:函数调用返回值
|
||||
* 函数调用返回值
|
||||
*
|
||||
* @author https://www.unfbx.com
|
||||
* @since 2023-06-14
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:方法参数实体类,实例数据如下
|
||||
* 方法参数实体类,实例数据如下
|
||||
* <pre>
|
||||
* {
|
||||
* "name": "get_current_weather",
|
||||
|
||||
@@ -8,7 +8,6 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https://www.unfbx.com
|
||||
* 2023-11-10
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-02
|
||||
|
||||
@@ -10,8 +10,6 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-02
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 描述:方法参数类,扩展参数可以继承Parameters自己实现
|
||||
* 方法参数类,扩展参数可以继承Parameters自己实现
|
||||
* 参考:
|
||||
* <pre>
|
||||
* {
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 描述: 问题类
|
||||
* 问题类
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-11
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.ruoyi.common.chat.entity.common.Usage;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述: 答案类
|
||||
* 答案类
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-11
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.ruoyi.common.chat.entity.common.Usage;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -11,7 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Getter;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Getter;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述:文本审核,敏感词鉴别
|
||||
* 文本审核,敏感词鉴别
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Getter;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:语音转文字
|
||||
* 语音转文字
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-02
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-02
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.web.socket.WebSocketSession;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述:OpenAI流式输出Socket接收
|
||||
* OpenAI流式输出Socket接收
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @date 2023-03-23
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 描述: open ai官方api接口
|
||||
* open ai官方api接口
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -56,7 +56,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* 描述: open ai 客户端
|
||||
* open ai 客户端
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-02-11
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 描述: open ai 客户端
|
||||
* open ai 客户端
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-28
|
||||
@@ -71,6 +71,11 @@ public class OpenAiStreamClient {
|
||||
*/
|
||||
private String apiHost;
|
||||
|
||||
/**
|
||||
* 自定义url 兼容多个平台
|
||||
*/
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* 自定义的okHttpClient
|
||||
* 如果不自定义 ,就是用sdk默认的OkHttpClient实例
|
||||
@@ -112,6 +117,11 @@ public class OpenAiStreamClient {
|
||||
}
|
||||
apiHost = builder.apiHost;
|
||||
|
||||
if (StrUtil.isBlank(builder.apiUrl)) {
|
||||
builder.apiUrl = OpenAIConst.apiUrl;
|
||||
}
|
||||
apiUrl = builder.apiUrl;
|
||||
|
||||
if (Objects.isNull(builder.keyStrategy)) {
|
||||
builder.keyStrategy = new KeyRandomStrategy();
|
||||
}
|
||||
@@ -136,12 +146,12 @@ public class OpenAiStreamClient {
|
||||
}
|
||||
okHttpClient = builder.okHttpClient;
|
||||
|
||||
this.openAiApi = new Retrofit.Builder()
|
||||
.baseUrl(apiHost)
|
||||
.client(okHttpClient)
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.addConverterFactory(JacksonConverterFactory.create())
|
||||
.build().create(OpenAiApi.class);
|
||||
// this.openAiApi = new Retrofit.Builder()
|
||||
// .baseUrl(apiHost)
|
||||
// .client(okHttpClient)
|
||||
// .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
// .addConverterFactory(JacksonConverterFactory.create())
|
||||
// .build().create(OpenAiApi.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +190,7 @@ public class OpenAiStreamClient {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String requestBody = mapper.writeValueAsString(chatCompletion);
|
||||
Request request = new Request.Builder()
|
||||
.url(this.apiHost + "v1/chat/completions")
|
||||
.url(this.apiHost)
|
||||
.post(RequestBody.create(MediaType.parse(ContentType.JSON.getValue()), requestBody))
|
||||
.build();
|
||||
factory.newEventSource(request, eventSourceListener);
|
||||
@@ -334,7 +344,6 @@ public class OpenAiStreamClient {
|
||||
|
||||
BillingUsage billingUsage = billingUsage(start.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), end.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
||||
double totalUsage = billingUsage.getTotalUsage().doubleValue() / 100;
|
||||
System.out.println(totalUsage);
|
||||
Subscription subscription = subscription();
|
||||
KeyInfo keyInfo = new KeyInfo();
|
||||
String start_key = key.substring(0, 6);
|
||||
@@ -611,6 +620,8 @@ public class OpenAiStreamClient {
|
||||
*/
|
||||
private String apiHost;
|
||||
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* 自定义OkhttpClient
|
||||
*/
|
||||
@@ -645,6 +656,16 @@ public class OpenAiStreamClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val 自定义请求后缀
|
||||
* @return Builder
|
||||
* @see OpenAIConst
|
||||
*/
|
||||
public Builder apiUrl(String val) {
|
||||
apiUrl = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder keyStrategy(KeyStrategyFunction val) {
|
||||
keyStrategy = val;
|
||||
return this;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class TestOpenAIAPI {
|
||||
.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
System.out.println(response.body().string());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.ruoyi.common.chat.openai.exception;
|
||||
|
||||
/**
|
||||
* 描述: 错误
|
||||
* 错误
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-11
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.ruoyi.common.chat.openai.exception;
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-11
|
||||
|
||||
@@ -5,7 +5,7 @@ import cn.hutool.core.util.RandomUtil;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:随机策略
|
||||
* 随机策略
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-03
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.ruoyi.common.chat.openai.function;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 描述:key 的获取策略
|
||||
* key 的获取策略
|
||||
* jdk默认实现
|
||||
* @see Function
|
||||
*
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 描述:请求增加header apikey
|
||||
* 请求增加header apikey
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-23
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述:动态处理key的鉴权拦截器
|
||||
* 动态处理key的鉴权拦截器
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-25
|
||||
|
||||
@@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
|
||||
/**
|
||||
* 描述: 日志
|
||||
* 日志
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-28
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述:openai 返回值处理Interceptor
|
||||
* openai 返回值处理Interceptor
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-23
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package org.ruoyi.common.chat.plugin;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.ruoyi.common.chat.openai.plugin.PluginParam;
|
||||
|
||||
@Data
|
||||
public class CmdReq extends PluginParam {
|
||||
/**
|
||||
* 指令
|
||||
*/
|
||||
private String cmd;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.ruoyi.common.chat.plugin;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CmdResp {
|
||||
|
||||
/**
|
||||
* 返回结果
|
||||
*/
|
||||
private String result;
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package org.ruoyi.common.chat.plugin;
|
||||
|
||||
import org.ruoyi.common.chat.openai.plugin.PluginAbstract;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
/**
|
||||
* @author ageer
|
||||
*/
|
||||
public class SqlPlugin extends PluginAbstract<SqlReq, SqlResp> {
|
||||
|
||||
public SqlPlugin(Class<?> r) {
|
||||
super(r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SqlResp func(SqlReq args) {
|
||||
SqlResp resp = new SqlResp();
|
||||
resp.setUserBalance(getBalance(args.getUsername()));
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String content(SqlResp resp) {
|
||||
return "用户余额:"+resp.getUserBalance();
|
||||
}
|
||||
|
||||
|
||||
public String getBalance(String userName) {
|
||||
// MySQL 8.0 以下版本 - JDBC 驱动名及数据库 URL
|
||||
String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
String DB_URL = "jdbc:mysql://43.139.70.230:3306/ry-vue";
|
||||
// 数据库的用户名与密码,需要根据自己的设置
|
||||
String USER = "ry-vue";
|
||||
String PASS = "BXZiGsY35K523Xfx";
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
String balance = "0.1";
|
||||
|
||||
try{
|
||||
// 注册 JDBC 驱动
|
||||
Class.forName(JDBC_DRIVER);
|
||||
|
||||
// 打开链接
|
||||
System.out.println("连接数据库...");
|
||||
conn = DriverManager.getConnection(DB_URL,USER,PASS);
|
||||
|
||||
// 执行查询
|
||||
System.out.println(" 实例化Statement对象...");
|
||||
stmt = conn.createStatement();
|
||||
String sql;
|
||||
sql = "SELECT user_balance FROM sys_user where user_name ='" + userName + "'";
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
// 展开结果集数据库
|
||||
while(rs.next()){
|
||||
// 通过字段检索
|
||||
balance = rs.getString("user_balance");
|
||||
// 输出数据
|
||||
System.out.print("余额: " + balance);
|
||||
System.out.print("\n");
|
||||
}
|
||||
// 完成后关闭
|
||||
rs.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}catch(SQLException se){
|
||||
// 处理 JDBC 错误
|
||||
se.printStackTrace();
|
||||
}catch(Exception e){
|
||||
// 处理 Class.forName 错误
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
// 关闭资源
|
||||
try{
|
||||
if(stmt!=null) stmt.close();
|
||||
}catch(SQLException se2){
|
||||
}// 什么都不做
|
||||
try{
|
||||
if(conn!=null) conn.close();
|
||||
}catch(SQLException se){
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
return balance;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package org.ruoyi.common.chat.plugin;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.ruoyi.common.chat.openai.plugin.PluginParam;
|
||||
|
||||
@Data
|
||||
public class SqlReq extends PluginParam {
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String username;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.ruoyi.common.chat.plugin;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SqlResp {
|
||||
|
||||
/**
|
||||
* 用户余额
|
||||
*/
|
||||
private String userBalance;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import org.ruoyi.common.chat.entity.chat.Message;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:对话请求对象
|
||||
* 对话请求对象
|
||||
*
|
||||
* @author ageerle
|
||||
* @sine 2023-04-08
|
||||
@@ -56,6 +56,12 @@ public class ChatRequest {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
private Long sessionId;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @sine 2023-04-08
|
||||
|
||||
@@ -10,7 +10,7 @@ import okhttp3.sse.EventSourceListener;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述: sse
|
||||
* sse
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-28
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.ruoyi.common.chat.openai.OpenAiStreamClient;
|
||||
import org.ruoyi.common.chat.openai.plugin.PluginAbstract;
|
||||
|
||||
/**
|
||||
* 描述: 插件开发返回信息收集sse监听器
|
||||
* 插件开发返回信息收集sse监听器
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-08-18
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.ruoyi.common.chat.openai.plugin.PluginParam;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 插件开发返回信息收集sse监听器
|
||||
* 插件开发返回信息收集sse监听器
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-08-18
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 描述:token计算工具类
|
||||
* token计算工具类
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-04-04
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.ruoyi.common.core.event;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 描述:定义一个事件类,用于通知配置变化
|
||||
* 定义一个事件类,用于通知配置变化
|
||||
*
|
||||
* @author ageerle@163.com
|
||||
* date 2024/5/19
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
import org.ruoyi.common.doc.config.properties.SwaggerProperties;
|
||||
import org.ruoyi.common.doc.config.properties.SpringDocProperties;
|
||||
import org.ruoyi.common.doc.handler.OpenApiHandler;
|
||||
import org.springdoc.core.configuration.SpringDocConfiguration;
|
||||
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
|
||||
@@ -36,26 +36,26 @@ import java.util.Set;
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@AutoConfiguration(before = SpringDocConfiguration.class)
|
||||
@EnableConfigurationProperties(SwaggerProperties.class)
|
||||
@EnableConfigurationProperties(SpringDocProperties.class)
|
||||
@ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class SwaggerConfig {
|
||||
public class SpringDocConfig {
|
||||
|
||||
private final ServerProperties serverProperties;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(OpenAPI.class)
|
||||
public OpenAPI openApi(SwaggerProperties swaggerProperties) {
|
||||
public OpenAPI openApi(SpringDocProperties properties) {
|
||||
OpenAPI openApi = new OpenAPI();
|
||||
// 文档基本信息
|
||||
SwaggerProperties.InfoProperties infoProperties = swaggerProperties.getInfo();
|
||||
SpringDocProperties.InfoProperties infoProperties = properties.getInfo();
|
||||
Info info = convertInfo(infoProperties);
|
||||
openApi.info(info);
|
||||
// 扩展文档信息
|
||||
openApi.externalDocs(swaggerProperties.getExternalDocs());
|
||||
openApi.tags(swaggerProperties.getTags());
|
||||
openApi.paths(swaggerProperties.getPaths());
|
||||
openApi.components(swaggerProperties.getComponents());
|
||||
Set<String> keySet = swaggerProperties.getComponents().getSecuritySchemes().keySet();
|
||||
openApi.externalDocs(properties.getExternalDocs());
|
||||
openApi.tags(properties.getTags());
|
||||
openApi.paths(properties.getPaths());
|
||||
openApi.components(properties.getComponents());
|
||||
Set<String> keySet = properties.getComponents().getSecuritySchemes().keySet();
|
||||
List<SecurityRequirement> list = new ArrayList<>();
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||
keySet.forEach(securityRequirement::addList);
|
||||
@@ -65,7 +65,7 @@ public class SwaggerConfig {
|
||||
return openApi;
|
||||
}
|
||||
|
||||
private Info convertInfo(SwaggerProperties.InfoProperties infoProperties) {
|
||||
private Info convertInfo(SpringDocProperties.InfoProperties infoProperties) {
|
||||
Info info = new Info();
|
||||
info.setTitle(infoProperties.getTitle());
|
||||
info.setDescription(infoProperties.getDescription());
|
||||
@@ -18,8 +18,8 @@ import java.util.List;
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "swagger")
|
||||
public class SwaggerProperties {
|
||||
@ConfigurationProperties(prefix = "springdoc")
|
||||
public class SpringDocProperties {
|
||||
|
||||
/**
|
||||
* 文档基本信息
|
||||
@@ -11,6 +11,7 @@ import io.swagger.v3.oas.models.Paths;
|
||||
import io.swagger.v3.oas.models.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.ruoyi.common.core.utils.StreamUtils;
|
||||
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
|
||||
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
|
||||
import org.springdoc.core.properties.SpringDocConfigProperties;
|
||||
@@ -154,11 +155,11 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
|
||||
if (!CollectionUtils.isEmpty(tagsStr))
|
||||
tagsStr = tagsStr.stream()
|
||||
.map(str -> propertyResolverUtils.resolve(str, locale))
|
||||
.collect(Collectors.toSet());
|
||||
.map(str -> propertyResolverUtils.resolve(str, locale))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (springdocTags.containsKey(handlerMethod)) {
|
||||
Tag tag = springdocTags.get(handlerMethod);
|
||||
io.swagger.v3.oas.models.tags.Tag tag = springdocTags.get(handlerMethod);
|
||||
tagsStr.add(tag.getName());
|
||||
if (openAPI.getTags() == null || !openAPI.getTags().contains(tag)) {
|
||||
openAPI.addTagsItem(tag);
|
||||
@@ -182,7 +183,7 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
if (javadocProvider.isPresent()) {
|
||||
String description = javadocProvider.get().getClassJavadoc(handlerMethod.getBeanType());
|
||||
if (StringUtils.isNotBlank(description)) {
|
||||
Tag tag = new Tag();
|
||||
io.swagger.v3.oas.models.tags.Tag tag = new io.swagger.v3.oas.models.tags.Tag();
|
||||
|
||||
// 自定义部分 修改使用java注释当tag名
|
||||
List<String> list = IoUtil.readLines(new StringReader(description), new ArrayList<>());
|
||||
@@ -203,7 +204,7 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
|
||||
if (!CollectionUtils.isEmpty(tags)) {
|
||||
// Existing tags
|
||||
List<Tag> openApiTags = openAPI.getTags();
|
||||
List<io.swagger.v3.oas.models.tags.Tag> openApiTags = openAPI.getTags();
|
||||
if (!CollectionUtils.isEmpty(openApiTags))
|
||||
tags.addAll(openApiTags);
|
||||
openAPI.setTags(new ArrayList<>(tags));
|
||||
@@ -211,7 +212,7 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
|
||||
// Handle SecurityRequirement at operation level
|
||||
io.swagger.v3.oas.annotations.security.SecurityRequirement[] securityRequirements = securityParser
|
||||
.getSecurityRequirements(handlerMethod);
|
||||
.getSecurityRequirements(handlerMethod);
|
||||
if (securityRequirements != null) {
|
||||
if (securityRequirements.length == 0)
|
||||
operation.setSecurity(Collections.emptyList());
|
||||
@@ -222,23 +223,23 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
return operation;
|
||||
}
|
||||
|
||||
private void buildTagsFromMethod(Method method, Set<Tag> tags, Set<String> tagsStr, Locale locale) {
|
||||
private void buildTagsFromMethod(Method method, Set<io.swagger.v3.oas.models.tags.Tag> tags, Set<String> tagsStr, Locale locale) {
|
||||
// method tags
|
||||
Set<Tags> tagsSet = AnnotatedElementUtils
|
||||
.findAllMergedAnnotations(method, Tags.class);
|
||||
.findAllMergedAnnotations(method, Tags.class);
|
||||
Set<io.swagger.v3.oas.annotations.tags.Tag> methodTags = tagsSet.stream()
|
||||
.flatMap(x -> Stream.of(x.value())).collect(Collectors.toSet());
|
||||
.flatMap(x -> Stream.of(x.value())).collect(Collectors.toSet());
|
||||
methodTags.addAll(AnnotatedElementUtils.findAllMergedAnnotations(method, io.swagger.v3.oas.annotations.tags.Tag.class));
|
||||
if (!CollectionUtils.isEmpty(methodTags)) {
|
||||
tagsStr.addAll(methodTags.stream().map(tag -> propertyResolverUtils.resolve(tag.name(), locale)).collect(Collectors.toSet()));
|
||||
tagsStr.addAll(StreamUtils.toSet(methodTags, tag -> propertyResolverUtils.resolve(tag.name(), locale)));
|
||||
List<io.swagger.v3.oas.annotations.tags.Tag> allTags = new ArrayList<>(methodTags);
|
||||
addTags(allTags, tags, locale);
|
||||
}
|
||||
}
|
||||
|
||||
private void addTags(List<io.swagger.v3.oas.annotations.tags.Tag> sourceTags, Set<Tag> tags, Locale locale) {
|
||||
Optional<Set<Tag>> optionalTagSet = AnnotationsUtils
|
||||
.getTags(sourceTags.toArray(new io.swagger.v3.oas.annotations.tags.Tag[0]), true);
|
||||
private void addTags(List<io.swagger.v3.oas.annotations.tags.Tag> sourceTags, Set<io.swagger.v3.oas.models.tags.Tag> tags, Locale locale) {
|
||||
Optional<Set<io.swagger.v3.oas.models.tags.Tag>> optionalTagSet = AnnotationsUtils
|
||||
.getTags(sourceTags.toArray(new io.swagger.v3.oas.annotations.tags.Tag[0]), true);
|
||||
optionalTagSet.ifPresent(tagsSet -> {
|
||||
tagsSet.forEach(tag -> {
|
||||
tag.name(propertyResolverUtils.resolve(tag.getName(), locale));
|
||||
|
||||
@@ -1 +1 @@
|
||||
org.ruoyi.common.doc.config.SwaggerConfig
|
||||
org.ruoyi.common.doc.config.SpringDocConfig
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-02
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: chat答案类
|
||||
* chat答案类
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-03-02
|
||||
|
||||
@@ -45,11 +45,7 @@ import tech.ordinaryroad.live.chat.client.douyu.netty.handler.DouyuConnectionHan
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@@ -95,12 +91,9 @@ class DouyuLiveChatClientTest implements IDouyuConnectionListener, IDouyuMsgList
|
||||
.build();
|
||||
|
||||
long startTime = System.currentTimeMillis(); // 获取开始时间的毫秒数
|
||||
System.out.println("执行前.......");
|
||||
Thread.sleep(3000);
|
||||
System.out.println("执行后.......");
|
||||
long endTime = System.currentTimeMillis(); // 获取结束时间的毫秒数
|
||||
long timeDiff = endTime - startTime; // 计算时间差
|
||||
System.out.println("执行时间 " + timeDiff / 1000 + " 秒。");
|
||||
|
||||
try (Response response = okClient.newCall(request).execute()) {
|
||||
if (response.body() != null) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.Getter;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* @since 2023-03-02
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
*
|
||||
* @author https:www.unfbx.com
|
||||
* 2023-02-15
|
||||
|
||||
@@ -48,7 +48,6 @@ class DouyuCodecUtilTest {
|
||||
Map<String, Object> stringObjectMap = DouyuCodecUtil.parseDouyuSttStringToMap(mapkb);
|
||||
assertNotNull(stringObjectMap);
|
||||
stringObjectMap.forEach((string, o) -> {
|
||||
System.out.println(string);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,7 +57,6 @@ class DouyuCodecUtilTest {
|
||||
Map<String, Object> stringObjectMap = DouyuCodecUtil.parseDouyuSttStringToMap(pdrinfo);
|
||||
assertNotNull(stringObjectMap);
|
||||
stringObjectMap.forEach((string, o) -> {
|
||||
System.out.println(string);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,7 +76,6 @@ class DouyuCodecUtilTest {
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
System.out.println(douyuSttString);
|
||||
assertEquals("key1@=value1/key2@=2/key3@=11@AA=11@AS12@AA=12@AS@S22@AA=22@AS21@AA=21@AS@S/".length(), douyuSttString.length());
|
||||
}
|
||||
|
||||
@@ -87,8 +84,6 @@ class DouyuCodecUtilTest {
|
||||
String mapkb = "type@=mapkb/pk_time@=600/teams@=team@AA=5@ASres@AA=1@ASsc@AA=660000@ASbf@AA=0@AS@Steam@AA=6@ASres@AA=2@ASsc@AA=600000@ASbf@AA=0@AS@Steam@AA=4@ASres@AA=3@ASsc@AA=456000@ASbf@AA=0@AS@Steam@AA=2@ASres@AA=4@ASsc@AA=302000@ASbf@AA=0@AS@Steam@AA=3@ASres@AA=5@ASsc@AA=100000@ASbf@AA=0@AS@Steam@AA=1@ASres@AA=6@ASsc@AA=200@ASbf@AA=0@AS@S/";
|
||||
IDouyuMsg iDouyuMsg = DouyuCodecUtil.parseDouyuSttString(mapkb, DouyuCodecUtil.MSG_TYPE_RECEIVE);
|
||||
String douyuSttString = DouyuCodecUtil.toDouyuSttString(iDouyuMsg);
|
||||
System.out.println(mapkb);
|
||||
System.out.println(douyuSttString);
|
||||
assertEquals(mapkb.length(), douyuSttString.length());
|
||||
IDouyuMsg douyuSttStringMsg = DouyuCodecUtil.parseDouyuSttString(douyuSttString, DouyuCodecUtil.MSG_TYPE_RECEIVE);
|
||||
assertNotNull(douyuSttStringMsg);
|
||||
@@ -97,6 +92,5 @@ class DouyuCodecUtilTest {
|
||||
@Test
|
||||
void unescape() {
|
||||
String unescape = DouyuCodecUtil.unescape("team@AA=5@ASres@AA=1@ASsc@AA=660000@ASbf@AA=0@AS@Steam@AA=6@ASres@AA=2@ASsc@AA=600000@ASbf@AA=0@AS@Steam@AA=4@ASres@AA=3@ASsc@AA=456000@ASbf@AA=0@AS@Steam@AA=2@ASres@AA=4@ASsc@AA=302000@ASbf@AA=0@AS@Steam@AA=3@ASres@AA=5@ASsc@AA=100000@ASbf@AA=0@AS@Steam@AA=1@ASres@AA=6@ASsc@AA=200@ASbf@AA=0@AS@S");
|
||||
System.out.println(unescape);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ class HuyaCodecUtilTest {
|
||||
ConnectParaInfo wsConnectParaInfo = ConnectParaInfo.newWSConnectParaInfo(ver, exp, appSrc);
|
||||
byte[] byteArray = wsConnectParaInfo.toByteArray();
|
||||
String s = HuyaCodecUtil.ab2str(byteArray);
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -36,7 +35,6 @@ class HuyaCodecUtilTest {
|
||||
String s = HuyaCodecUtil.ab2str(byteArray);
|
||||
|
||||
String btoa = HuyaCodecUtil.btoa(s);
|
||||
System.out.println(btoa);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +65,6 @@ class HuyaCodecUtilTest {
|
||||
LiveLaunchReq liveLaunchReq = new LiveLaunchReq();
|
||||
liveLaunchReq = wupReq.getUniAttribute().getByClass("tReq", liveLaunchReq);
|
||||
UserId tId = liveLaunchReq.getTId();
|
||||
System.out.println(wupReq.getTarsServantRequest().getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,4 +93,4 @@ class HuyaCodecUtilTest {
|
||||
|
||||
UserId tId = getLivingInfoReq.getTId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,5 @@ class KuaishouApisTest {
|
||||
|
||||
@Test
|
||||
void sendComment() {
|
||||
System.out.println(KuaishouApis.sendComment(System.getenv("cookie"),
|
||||
"3x6pb6bcmjrarvs",
|
||||
KuaishouApis.SendCommentRequest
|
||||
.builder()
|
||||
.liveStreamId("XKLoBv2mAEo")
|
||||
.content("666666a")
|
||||
.build()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 描述:创建一个监听器,用于处理配置变化事件
|
||||
* 创建一个监听器,用于处理配置变化事件
|
||||
*
|
||||
* @author ageerle@163.com
|
||||
* date 2024/5/19
|
||||
|
||||
@@ -84,7 +84,6 @@ public class SingleHttpClient {
|
||||
if (params != null) {
|
||||
String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(params, Consts.UTF_8));
|
||||
httpGet = new HttpGet(url + "?" + paramStr);
|
||||
// System.out.println(url + "?" + paramStr);
|
||||
} else {
|
||||
httpGet = new HttpGet(url);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user