mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c93e60ced7 | ||
|
|
3cb8f53aec | ||
|
|
86b93876c7 | ||
|
|
2732d8fee1 | ||
|
|
6c7c1ffbeb | ||
|
|
c3d3b1146b | ||
|
|
b1952d64ab | ||
|
|
27283001a8 | ||
|
|
ef7c37a8da | ||
|
|
aa0a100a85 | ||
|
|
6951eada9d | ||
|
|
c9baed6c4e | ||
|
|
4693785738 | ||
|
|
a0a466fe07 | ||
|
|
23f3d50796 | ||
|
|
bdae7ebefa | ||
|
|
7c99829052 | ||
|
|
0ac652c5d9 | ||
|
|
e2b2d31429 | ||
|
|
078a81038f | ||
|
|
6492316e23 | ||
|
|
041daad1e4 | ||
|
|
a0869dc7bd | ||
|
|
c40efebc7a | ||
|
|
75e15f4c50 | ||
|
|
d551fcd6d2 | ||
|
|
404163f391 | ||
|
|
5ffd617431 | ||
|
|
ef4fca9671 | ||
|
|
291187229c | ||
|
|
ad83e752b9 | ||
|
|
805a59dddd | ||
|
|
8639c23dc4 | ||
|
|
7c57a1cb33 | ||
|
|
bab8b67217 | ||
|
|
b9890d1fd3 | ||
|
|
358d5e5288 | ||
|
|
8adecd0b58 | ||
|
|
df74c62ac9 | ||
|
|
9c9d7382fe | ||
|
|
e4266d37ab | ||
|
|
3f6af3b1fb | ||
|
|
c97456c718 | ||
|
|
95a698b875 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,3 +13,5 @@ assembly/runtime/*
|
|||||||
**/dist/
|
**/dist/
|
||||||
*.umi/
|
*.umi/
|
||||||
/assembly/deploy
|
/assembly/deploy
|
||||||
|
/runtime
|
||||||
|
**/.flattened-pom.xml
|
||||||
10
CHANGELOG
10
CHANGELOG
@@ -1,10 +0,0 @@
|
|||||||
davinci 0.3.0 change log
|
|
||||||
1) add data portal
|
|
||||||
2) add metric trend chart
|
|
||||||
3) add feedback component
|
|
||||||
4) add tab component
|
|
||||||
5) add page setting
|
|
||||||
6) modify permission process
|
|
||||||
7) optimize css style
|
|
||||||
8) optimize filter
|
|
||||||
9) delete view module
|
|
||||||
116
CHANGELOG.md
Normal file
116
CHANGELOG.md
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
# SuperSonic Changelog
|
||||||
|
|
||||||
|
- All notable changes to this project will be documented in this file.
|
||||||
|
- "Breaking Changes" describes any changes that may break existing functionality or cause
|
||||||
|
compatibility issues with previous versions.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## SuperSonic [0.7.2] - 2023-08-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Support asynchronous query - return parse information to user before executing result
|
||||||
|
- Add Model as the basic data structure of the semantic definitions - this will repalce the old conception of subdomain
|
||||||
|
|
||||||
|
### Updated
|
||||||
|
- improve knowledge word similarity algorithm
|
||||||
|
- improve embedding plugin chooser
|
||||||
|
- improve DSLQuery field correction and parser
|
||||||
|
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix mapper error that detectWord text is shorter than word
|
||||||
|
- Fix MetricDomainQuery inherit context
|
||||||
|
|
||||||
|
## SuperSonic [0.7.0] - 2023-07-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Add function call parser and embedding recall parser
|
||||||
|
- Add plugin management
|
||||||
|
- Add web page query and web service query
|
||||||
|
- Metric filter query support querying metrics and comparing them in different dimensions
|
||||||
|
- Support dimension value mapping
|
||||||
|
- Support dimension/metric invisible, chat filter related data
|
||||||
|
- Add user guide docs
|
||||||
|
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix the data problem of getDomainList interface in standalone mode
|
||||||
|
|
||||||
|
## SuperSonic [0.6.0] - 2023-07-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support llm parser and llm api server - users can query data through complex natural language.
|
||||||
|
- Support fuzzy query dimension and metric name - users can set the 'metric.dimension.threshold'
|
||||||
|
parameter to control the fuzzy threshold.
|
||||||
|
- Support query filter and domain filter in query and search - users can specify domainId and query
|
||||||
|
filter to filter the results in search and query.
|
||||||
|
- Support standalone mode - users can integrate semantic and chat services in one process for easy
|
||||||
|
management and debugging.
|
||||||
|
- Support dsl query in semantic - users can specify DSL language to query data in Semantic. In the
|
||||||
|
past, data querying was limited to struct language.
|
||||||
|
- Add unit and integration testing - add integration tests for single-turn and multi-turn
|
||||||
|
conversations, to efficiently validate the code.
|
||||||
|
- Support dimension and metric alias - users can specify one or multiple aliases to expand search
|
||||||
|
and query.
|
||||||
|
- Add scheduled semantic metadata update functionality in chat.
|
||||||
|
- Support create datasource by table name in the web page.
|
||||||
|
- Add the ability to set permissions for domain.
|
||||||
|
- Add a local/Remote implementation to the SemanticLayer interface.
|
||||||
|
|
||||||
|
### Updated
|
||||||
|
|
||||||
|
- Code architecture adjustment in chat.
|
||||||
|
|
||||||
|
1) Abstracting into three modules, namely api, core, and knowledge. Providing four core interfaces:
|
||||||
|
SchemaMapper, SemanticLayer, SemanticParser, and SemanticQuery.
|
||||||
|
2) Add RuleSemanticQuery and LLMSemanticQuery implement to SemanticQuery.
|
||||||
|
3) Add all possible queries to the candidate queries, and then select the most suitable query from
|
||||||
|
the candidate queries.
|
||||||
|
|
||||||
|
- Code architecture adjustment in semantic.
|
||||||
|
|
||||||
|
1) Refactor semantic layer SQL parsing code through Calcite.
|
||||||
|
2) Add QueryOptimizer interface.
|
||||||
|
|
||||||
|
- Chat config subdivided into detailed and metric scenarios - users can set different parameters in these two scenarios.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Resolved last word not be recognized in SchemaMapper.
|
||||||
|
- Fix context inheritance problem.
|
||||||
|
- Fix the error of querying H2 database by month unit.
|
||||||
|
- Set faker user to context when authentication disable.
|
||||||
|
|
||||||
|
## SuperSonic [0.5.0] - 2023-06-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add the search and query feature in chat according to rules in an extensible way.
|
||||||
|
- Add semantic/chat independent service for users.
|
||||||
|
- Add Modeling Interface - users can visually define and maintain semantic models in the web page.
|
||||||
|
- Add a unified semantic parsing layer - user can query data by struct language.
|
||||||
|
|
||||||
|
# Davinci Changelog
|
||||||
|
|
||||||
|
## Davinci [0.3.0] - 2023-06-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- add data portal
|
||||||
|
- add metric trend chart
|
||||||
|
- add feedback component
|
||||||
|
- add tab component
|
||||||
|
- add page setting
|
||||||
|
|
||||||
|
### Updated
|
||||||
|
|
||||||
|
- modify permission process
|
||||||
|
- optimize css style
|
||||||
|
- optimize filter
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- delete view module
|
||||||
47
README.md
47
README.md
@@ -2,49 +2,60 @@ English | [中文](README_CN.md)
|
|||||||
|
|
||||||
# SuperSonic (超音数)
|
# SuperSonic (超音数)
|
||||||
|
|
||||||
**SuperSonic is an out-of-the-box yet highly extensible framework for building a data chatbot**. SuperSonic provides a chat interface that empowers users to query data using natural language and visualize the results with suitable charts. To enable such experience, the only thing necessary is to build a logical semantic model (definition of metrics, dimensions, relationships, etc) on top of the physical data stores, and no data modification or copying is required. Meanwhile SuperSonic is designed to be plug-and-play, allowing new functionalities to be added through plugins and core components to be integrated into other systems.
|
**SuperSonic is an out-of-the-box yet highly extensible framework for building a data chatbot**. SuperSonic provides a chat interface that empowers users to query data using natural language and visualize the results with suitable charts. To enable such experience, the only thing necessary is to build logical semantic models (definition of metrics/dimensions/entities, along with their meaning, context and relationships) on top of physical data models, and no data modification or copying is required. Meanwhile, SuperSonic is designed to be pluggable, allowing new functionalities to be added through plugins and core components to be integrated with other systems.
|
||||||
|
|
||||||
|
<img src="./docs/images/supersonic_demo.gif" height="100%" width="100%" align="center"/>
|
||||||
|
|
||||||
## Motivation
|
## Motivation
|
||||||
|
|
||||||
The emergence of Large Language Models (LLMs) like ChatGPT is reshaping the way information is retrieved. In the field of data analytics, both academia and industry are primarily focused on leveraging deep learning models to convert natural language queries into SQL queries. While some works show promising results, they are not applicable to real-world scenarios.
|
The emergence of Large Language Model (LLM) like ChatGPT is reshaping the way information is retrieved. In the field of data analytics, both academia and industry are primarily focused on leveraging LLM to convert natural language queries into SQL queries. While some works show promising results, they are still not applicable to real-world scenarios.
|
||||||
|
|
||||||
From our perspective, the key to filling the real-world gap lies in two aspects:
|
From our perspective, the key to filling the real-world gap lies in two aspects:
|
||||||
1. Utilize a combination of rule-based and model-based semantic parsers to deal with different scenarios
|
1. Utilize a combination of rule-based and model-based semantic parsers to deal with different scenarios.
|
||||||
2. Introduce a semantic model layer to encapsulate underlying complexity thus simplify the semantic parsers
|
2. Introduce a semantic model layer encapsulating the underlying data complexity(joins, formulas, etc) to simplify semantic parsing.
|
||||||
|
|
||||||
With these ideas in mind, we developed SuperSonic as a reference implementation and used it to power our real-world products. Additionally, to encourage further development of data chatbots, we decided to open source SuperSonic as an extensible framework.
|
With these ideas in mind, we develop SuperSonic as a practical reference implementation and use it to power our real-world products. Additionally, to facilitate further development of data chatbot, we decide to open source SuperSonic as an extensible framework.
|
||||||
|
|
||||||
## Out-of-the-box Features
|
## Out-of-the-box Features
|
||||||
|
|
||||||
- Built-in graphical interface for business users to enter data queries
|
- Built-in graphical interface for business users to enter data queries
|
||||||
- Built-in graphical interface for analytics engineers to manage semantic models
|
- Built-in graphical interface for analytics engineers to manage semantic models
|
||||||
- Support input auto-completion as well as query recommendation
|
- Support input auto-completion as well as query recommendation
|
||||||
- Support multi-turn conversation and switch context automatically
|
- Support multi-turn conversation and history context management
|
||||||
- Support three-level permission control: domain-level, column-level and row-level
|
- Support three-level permission control: domain-level, column-level and row-level
|
||||||
|
|
||||||
## Extensible Components
|
## Extensible Components
|
||||||
|
|
||||||
SuperSonic contains four core components, each of which can be extended or integrated:
|
The high-level architecture and main process flow is shown in below diagram:
|
||||||
|
|
||||||
<img src="./docs/images/supersonic_components.png" height="50%" width="50%" align="center"/>
|
<img src="./docs/images/supersonic_components.png" height="80%" width="80%" align="center"/>
|
||||||
|
|
||||||
- **Chat interface:** accepts user queries and answer results with approriate visualization charts. It supports input auto-completion as well as multi-turn conversation.
|
- **Chat Interface:** accepts natural language queries and answer results with appropriate visualization charts. It supports input auto-completion as well as multi-turn conversation.
|
||||||
|
|
||||||
- **Schema mapper:** identifies references to schema elements in natural language queries. It matches queries against the knowledage base which is constructed using the schema of semantic models.
|
- **Modeling Interface:** empowers analytics engineers to visually define and maintain semantic models. The configurations related to access permission and chat conversation can also be set on the UI.
|
||||||
|
|
||||||
- **Semantic parser chain:** resolves query mode and choose the most suitable semantic model. It is composed of a group of rule-based and model-based parsers, each of which deals with specific scenarios.
|
- **Schema Mapper Chain:** identifies references to schema elements(metrics/dimensions/entities/values) in user queries. It matches the query text against a knowledge base constructed from the semantic models.
|
||||||
|
|
||||||
- **Semantic model layer:** manages semantic models and generate SQL statement given specific semantic model and related semantic items. It encapsulates technical concepts, calculation formulas and entity relationships of the underlying data.
|
- **Semantic Parser Chain:** understands user queries and extract semantic information. It consists of a combination of rule-based and model-based parsers, each of which deals with specific scenarios.
|
||||||
|
|
||||||
|
- **Semantic Query:** performs execution according to extracted semantic information. It generates SQL queries and executes them against physical data models.
|
||||||
|
|
||||||
## Quick Demo
|
## Quick Demo
|
||||||
|
|
||||||
SuperSonic comes with a sample semantic data model as well as sample chat that can be used as a starting point. Please follow the steps:
|
SuperSonic comes with sample semantic models as well as chat conversations that can be used as a starting point. Please follow the steps:
|
||||||
|
|
||||||
- Download the latest prebuilt binary from the release page
|
- Download the latest prebuilt binary from the [release page](https://github.com/tencentmusic/supersonic/releases)
|
||||||
- Run script "bin/start-all.sh" to start services
|
- Run script "bin/start-standalone.sh" to start a standalone server
|
||||||
- Visit http://localhost:9080 in browser to explore chat interface
|
- Visit http://localhost:9080 in browser to start exploration
|
||||||
- Visit http://localhost:9081 in browser to explore modeling interface
|
|
||||||
|
|
||||||
## How to Build
|
## How to Build
|
||||||
|
|
||||||
Download the source code and run script "assembly/bin/build-all.sh" to build both front-end webapp and back-end services
|
SuperSonic can be deployed in two modes: standalone (intended for quick demo) and distributed (intended for production).
|
||||||
|
|
||||||
|
### Build for Standalone Mode
|
||||||
|
|
||||||
|
Pull the source code and run script "assembly/bin/build-standalone.sh" to build a single packages.
|
||||||
|
|
||||||
|
### Build for Distributed Mode
|
||||||
|
|
||||||
|
Pull the source code and run scripts "assembly/bin/build-chat.sh" and "assembly/bin/build-semantic.sh" separately to build packages.
|
||||||
|
|||||||
49
README_CN.md
49
README_CN.md
@@ -1,48 +1,59 @@
|
|||||||
# 超音数(SuperSonic)
|
# 超音数(SuperSonic)
|
||||||
|
|
||||||
**超音数是一个开箱即用且易于扩展的数据问答对话框架**。通过超音数的问答对话界面,用户能够使用自然语言查询数据,系统会选择合适的可视化图表呈现结果。超音数不需要修改或复制数据,只需要在物理数据库之上构建逻辑语义模型(定义指标、维度、相互间关系等),即可开启数据问答体验。与此同时,超音数被设计为可插拔式框架,允许以插件形式来扩展新功能,或者将核心组件与其他系统集成。
|
**超音数是一个开箱即用且易于扩展的数据问答对话框架**。通过超音数的问答对话界面,用户能够使用自然语言查询数据,系统会选择合适的可视化图表呈现结果。超音数不需要修改或复制数据,只需要在物理数据模型之上构建逻辑语义模型(指标/维度/实体的定义,以及他们的业务含义、相互间关系等),即可开启数据问答体验。与此同时,超音数被设计为可插拔式的框架,允许以插件形式来扩展新功能,或者将核心组件与其他系统集成。
|
||||||
|
|
||||||
|
<img src="./docs/images/supersonic_demo.gif" height="100%" width="100%" align="center"/>
|
||||||
|
|
||||||
## 项目动机
|
## 项目动机
|
||||||
|
|
||||||
大型语言模型(LLMs)如ChatGPT的出现正在重塑信息检索的方式。在数据分析领域,学术界和工业界主要关注利用深度学习模型将自然语言查询转换为SQL查询。虽然一些工作显示出有前景的结果,但它们还并不适用于实际场景。
|
大型语言模型(LLMs)如ChatGPT的出现正在重塑信息检索的方式。在数据分析领域,学术界和工业界主要关注利用深度学习模型将自然语言查询转换为SQL查询。虽然一些工作显示出有前景的结果,但它们还并不适用于实际场景。
|
||||||
|
|
||||||
在我们看来,为了在实际场景发挥价值,有两个关键点:
|
在我们看来,为了在实际场景发挥价值,有两个关键点:
|
||||||
1. 将基于规则和基于模型的语义解析器相结合,发挥各自优势,以便处理不同的场景
|
1. 将基于规则和基于模型的语义解析器相结合,发挥各自优势,以便处理不同的场景。
|
||||||
2. 引入语义模型层来封装数据底层的复杂性,从而简化语义解析器的问题求解空间
|
2. 引入语义模型层来封装数据底层的复杂性(关联、公式等),从而简化语义解析的求解空间。
|
||||||
|
|
||||||
为了验证上述想法,我们开发了超音数项目,并将其应用在实际的内部产品中。与此同时,我们决定将超音数作为一个可扩展的框架开源,希望能够促进数据问答对话领域的进一步发展。
|
为了验证上述想法,我们开发了超音数项目,并将其应用在实际的内部产品中。与此同时,我们将超音数作为一个可扩展的框架开源,希望能够促进数据问答对话领域的进一步发展。
|
||||||
|
|
||||||
## 开箱即用的特性
|
## 开箱即用的特性
|
||||||
|
|
||||||
- 内置图形界面以便业务用户输入数据查询
|
- 内置图形界面以便业务用户输入数据查询。
|
||||||
- 内置图形界面以便分析工程师管理语义模型
|
- 内置图形界面以便分析工程师管理语义模型。
|
||||||
- 支持文本输入的联想和查询问题的推荐
|
- 支持文本输入的联想和查询问题的推荐。
|
||||||
- 支持多轮对话,根据语境自动切换上下文
|
- 支持多轮对话,根据语境自动切换上下文。
|
||||||
- 支持三级权限控制:主题域级、列级、行级
|
- 支持三级权限控制:主题域级、列级、行级。
|
||||||
|
|
||||||
## 易于扩展的组件
|
## 易于扩展的组件
|
||||||
|
|
||||||
超音数包含四个核心组件,每个都易于扩展或被集成:
|
超音数的整体架构和主流程如下图所示:
|
||||||
|
|
||||||
<img src="./docs/images/supersonic_components.png" height="50%" width="50%" align="center"/>
|
<img src="./docs/images/supersonic_components.png" height="80%" width="80%" align="center"/>
|
||||||
|
|
||||||
- **问答对话界面(chat interface)**:接受用户查询并选择合适的可视化图表呈现结果,支持输入联想和多轮对话。
|
- **问答对话界面(chat interface)**:接受用户查询并选择合适的可视化图表呈现结果,支持输入联想和多轮对话。
|
||||||
|
|
||||||
- **模式映射器(schema mapper)**:基于语义模型的schema构建知识库,然后将自然语言查询在知识库中进行匹配,为后续的语义解析提供相关信息。
|
- **语义建模界面(modeling interface)**:使分析工程师能够通过可视化方式定义和维护语义模型,与访问权限和聊天对话相关的配置也可以在用户界面上设置。
|
||||||
|
|
||||||
- **语义解析器链(semantic parser chain)**:识别查询模式并选择最匹配的语义模型,其由一组基于规则或模型的解析器组成,每个解析器可用于应对不同的特定场景。
|
- **模式映射器(schema mapper chain)**:基于语义模型构建知识库,然后将自然语言文本在知识库中进行匹配,为后续的语义解析提供相关信息。
|
||||||
|
|
||||||
- **语义模型层(semantic model layer)**:建模阶段,负责构建与管理语义模型;查询阶段,依据给定的语义模型来生成SQL语句。
|
- **语义解析器(semantic parser chain)**:理解用户查询并抽取语义信息,其由一组基于规则和基于模型的解析器组成,每个解析器可应对不同的特定场景。
|
||||||
|
|
||||||
|
- **语义查询(semantic query)**: 根据语义信息生成物理SQL执行查询。
|
||||||
|
|
||||||
## 快速体验
|
## 快速体验
|
||||||
|
|
||||||
超音数自带样例的语义模型和问答对话,只需以下三步即可快速体验:
|
超音数自带样例的语义模型和问答对话,只需以下三步即可快速体验:
|
||||||
|
|
||||||
- 从release page下载预先构建好的发行包
|
- 从[release page](https://github.com/tencentmusic/supersonic/releases)下载预先构建好的发行包
|
||||||
- 运行 "bin/start-all.sh"启动前后端服务
|
- 运行 "bin/start-standalone.sh"启动服务
|
||||||
- 在浏览器访问http://localhost:9080 开启数据问答探索
|
- 在浏览器访问http://localhost:9080 开启探索
|
||||||
- 在浏览器访问http://localhost:9081 开启语义建模探索
|
|
||||||
|
|
||||||
## 如何构建
|
## 如何构建
|
||||||
|
|
||||||
下载源码包,运行脚本"assembly/bin/build-all.sh",会将前后端一起编译打包
|
超音数可以运行在两个模式:standalone(一般用于快速演示)和distributed(一般用于生产环境)。
|
||||||
|
|
||||||
|
### Standalone模式构建
|
||||||
|
|
||||||
|
下载源码包,运行脚本"assembly/bin/build-standalone.sh",将所有服务一起编译打包
|
||||||
|
|
||||||
|
### Distributed模式构建
|
||||||
|
|
||||||
|
下载源码包,分别运行脚本"assembly/bin/build-chat.sh"、"assembly/bin/build-semantic.sh",为问答层服务和语义层服务编译打包
|
||||||
12
assembly/bin/build-chat.sh
Executable file
12
assembly/bin/build-chat.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
baseDir=$(readlink -f $sbinDir/../)
|
||||||
|
runtimeDir=$baseDir/runtime
|
||||||
|
buildDir=$baseDir/build
|
||||||
|
|
||||||
|
cd $baseDir
|
||||||
|
|
||||||
|
#1. move package to build
|
||||||
|
cp $baseDir/../launchers/chat/target/*.tar.gz ${buildDir}/supersonic-chat.tar.gz
|
||||||
|
|
||||||
13
assembly/bin/build-ide.sh
Executable file
13
assembly/bin/build-ide.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
baseDir=$(readlink -f $sbinDir/../)
|
||||||
|
buildDir=$baseDir/build
|
||||||
|
|
||||||
|
cd $baseDir/bin
|
||||||
|
sh build-standalone.sh
|
||||||
|
|
||||||
|
cd $buildDir
|
||||||
|
tar xvf supersonic-webapp.tar.gz
|
||||||
|
mv supersonic-webapp webapp
|
||||||
|
mv webapp ../../launchers/standalone/target/classes
|
||||||
@@ -7,14 +7,13 @@ buildDir=$baseDir/build
|
|||||||
|
|
||||||
cd $baseDir
|
cd $baseDir
|
||||||
|
|
||||||
#1. build semantic chat service
|
#1. build semantic service
|
||||||
rm -fr ${buildDir}/*.tar.gz
|
rm -fr ${buildDir}/*.tar.gz
|
||||||
rm -fr dist
|
rm -fr dist
|
||||||
|
|
||||||
mvn -f $baseDir/../ clean package -DskipTests
|
mvn -f $baseDir/../ clean package -DskipTests
|
||||||
|
|
||||||
#2. move package to build
|
#2. move package to build
|
||||||
cp $baseDir/../launchers/chat/target/*.tar.gz ${buildDir}/supersonic-chat.tar.gz
|
|
||||||
cp $baseDir/../launchers/semantic/target/*.tar.gz ${buildDir}/supersonic-semantic.tar.gz
|
cp $baseDir/../launchers/semantic/target/*.tar.gz ${buildDir}/supersonic-semantic.tar.gz
|
||||||
|
|
||||||
#3. build webapp
|
#3. build webapp
|
||||||
23
assembly/bin/build-standalone.sh
Executable file
23
assembly/bin/build-standalone.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
baseDir=$(readlink -f $sbinDir/../)
|
||||||
|
runtimeDir=$baseDir/runtime
|
||||||
|
buildDir=$baseDir/build
|
||||||
|
|
||||||
|
cd $baseDir
|
||||||
|
|
||||||
|
#1. build semantic chat service
|
||||||
|
rm -fr ${buildDir}/*.tar.gz
|
||||||
|
rm -fr dist
|
||||||
|
|
||||||
|
mvn -f $baseDir/../ clean package -DskipTests
|
||||||
|
|
||||||
|
#2. move package to build
|
||||||
|
cp $baseDir/../launchers/standalone/target/*.tar.gz ${buildDir}/supersonic.tar.gz
|
||||||
|
|
||||||
|
#3. build webapp
|
||||||
|
chmod +x $baseDir/../webapp/start-fe-prod.sh
|
||||||
|
cd ../webapp
|
||||||
|
sh ./start-fe-prod.sh
|
||||||
|
cp -fr ./supersonic-webapp.tar.gz ${buildDir}/
|
||||||
35
assembly/bin/start-chat.sh
Executable file
35
assembly/bin/start-chat.sh
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
baseDir=$(readlink -f $sbinDir/../)
|
||||||
|
runtimeDir=$baseDir/../runtime
|
||||||
|
buildDir=$baseDir/build
|
||||||
|
|
||||||
|
cd $baseDir
|
||||||
|
|
||||||
|
#2. package lib
|
||||||
|
|
||||||
|
tar -zxvf ${buildDir}/supersonic-chat.tar.gz -C ${runtimeDir}
|
||||||
|
|
||||||
|
mv ${runtimeDir}/launchers-chat-* ${runtimeDir}/supersonic-chat
|
||||||
|
|
||||||
|
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
||||||
|
|
||||||
|
mkdir -p ${runtimeDir}/supersonic-chat/webapp
|
||||||
|
|
||||||
|
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-chat/webapp
|
||||||
|
|
||||||
|
rm -fr ${buildDir}/supersonic-webapp
|
||||||
|
|
||||||
|
json=$(cat ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json)
|
||||||
|
json=$(echo $json | jq '.env="chat"')
|
||||||
|
echo $json > ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json
|
||||||
|
|
||||||
|
#3. start service
|
||||||
|
#3.1 start chat service
|
||||||
|
echo ${runtimeDir}
|
||||||
|
sh ${runtimeDir}/supersonic-chat/bin/service.sh restart
|
||||||
|
|
||||||
|
#3.2 start llm service
|
||||||
|
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh restart
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||||
baseDir=$(readlink -f $sbinDir/../)
|
baseDir=$(readlink -f $sbinDir/../)
|
||||||
runtimeDir=$baseDir/runtime
|
runtimeDir=$baseDir/../runtime
|
||||||
buildDir=$baseDir/build
|
buildDir=$baseDir/build
|
||||||
|
|
||||||
cd $baseDir
|
cd $baseDir
|
||||||
@@ -14,23 +14,23 @@ rm -fr ${runtimeDir}/*
|
|||||||
#2. package lib
|
#2. package lib
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic-semantic.tar.gz -C ${runtimeDir}
|
tar -zxvf ${buildDir}/supersonic-semantic.tar.gz -C ${runtimeDir}
|
||||||
tar -zxvf ${buildDir}/supersonic-chat.tar.gz -C ${runtimeDir}
|
|
||||||
|
|
||||||
mv ${runtimeDir}/launchers-chat-* ${runtimeDir}/supersonic-chat
|
|
||||||
mv ${runtimeDir}/launchers-semantic-* ${runtimeDir}/supersonic-semantic
|
mv ${runtimeDir}/launchers-semantic-* ${runtimeDir}/supersonic-semantic
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
||||||
|
|
||||||
mkdir -p ${runtimeDir}/supersonic-semantic/webapp
|
mkdir -p ${runtimeDir}/supersonic-semantic/webapp
|
||||||
mkdir -p ${runtimeDir}/supersonic-chat/webapp
|
|
||||||
|
|
||||||
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-semantic/webapp
|
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-semantic/webapp
|
||||||
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-chat/webapp
|
|
||||||
|
|
||||||
rm -fr ${buildDir}/supersonic-webapp
|
rm -fr ${buildDir}/supersonic-webapp
|
||||||
|
|
||||||
|
|
||||||
|
json=$(cat ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json)
|
||||||
|
json=$(echo $json | jq '.env="semantic"')
|
||||||
|
echo $json > ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json
|
||||||
|
|
||||||
#3. start service
|
#3. start service
|
||||||
sh ${runtimeDir}/supersonic-semantic/bin/service.sh restart
|
sh ${runtimeDir}/supersonic-semantic/bin/service.sh restart
|
||||||
sleep 5
|
|
||||||
sh ${runtimeDir}/supersonic-chat/bin/service.sh restart
|
|
||||||
|
|
||||||
32
assembly/bin/start-standalone.sh
Executable file
32
assembly/bin/start-standalone.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
baseDir=$(readlink -f $sbinDir/../)
|
||||||
|
runtimeDir=$baseDir/../runtime
|
||||||
|
buildDir=$baseDir/build
|
||||||
|
|
||||||
|
cd $baseDir
|
||||||
|
|
||||||
|
#1. clear file
|
||||||
|
mkdir -p ${runtimeDir}
|
||||||
|
rm -fr ${runtimeDir}/*
|
||||||
|
|
||||||
|
#2. package lib
|
||||||
|
|
||||||
|
tar -zxvf ${buildDir}/supersonic.tar.gz -C ${runtimeDir}
|
||||||
|
|
||||||
|
mv ${runtimeDir}/launchers-standalone-* ${runtimeDir}/supersonic-standalone
|
||||||
|
|
||||||
|
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
||||||
|
|
||||||
|
mkdir -p ${runtimeDir}/supersonic-standalone/webapp
|
||||||
|
|
||||||
|
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-standalone/webapp
|
||||||
|
|
||||||
|
rm -fr ${buildDir}/supersonic-webapp
|
||||||
|
|
||||||
|
#3. start service
|
||||||
|
#start standalone service
|
||||||
|
sh ${runtimeDir}/supersonic-standalone/bin/service.sh restart
|
||||||
|
#start llm service
|
||||||
|
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh restart
|
||||||
@@ -28,6 +28,12 @@
|
|||||||
<include>*.jar</include>
|
<include>*.jar</include>
|
||||||
</includes>
|
</includes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.basedir}/../../chat/core/src/main/python</directory>
|
||||||
|
<outputDirectory>llm</outputDirectory>
|
||||||
|
<fileMode>0777</fileMode>
|
||||||
|
<directoryMode>0755</directoryMode>
|
||||||
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
|
|
||||||
<dependencySets>
|
<dependencySets>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tencent.supersonic</groupId>
|
<groupId>com.tencent.supersonic</groupId>
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.tencent.supersonic.auth.api.authentication.adaptor;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.Organization;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public interface UserAdaptor {
|
||||||
|
|
||||||
|
List<String> getUserNames();
|
||||||
|
|
||||||
|
List<User> getUserList();
|
||||||
|
|
||||||
|
List<Organization> getOrganizationTree();
|
||||||
|
|
||||||
|
void register(UserReq userReq);
|
||||||
|
|
||||||
|
String login(UserReq userReq);
|
||||||
|
|
||||||
|
List<User> getUserByOrg(String key);
|
||||||
|
|
||||||
|
Set<String> getUserAllOrgId(String userName);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.tencent.supersonic.auth.api.authentication.pojo;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Organization {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String parentId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String fullName;
|
||||||
|
|
||||||
|
private List<Organization> subOrganizations = Lists.newArrayList();
|
||||||
|
|
||||||
|
private boolean isRoot;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package com.tencent.supersonic.auth.api.authentication.service;
|
package com.tencent.supersonic.auth.api.authentication.service;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.Organization;
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
|
|
||||||
@@ -14,4 +15,10 @@ public interface UserService {
|
|||||||
void register(UserReq userCmd);
|
void register(UserReq userCmd);
|
||||||
|
|
||||||
String login(UserReq userCmd);
|
String login(UserReq userCmd);
|
||||||
|
|
||||||
|
Set<String> getUserAllOrgId(String userName);
|
||||||
|
|
||||||
|
List<User> getUserByOrg(String key);
|
||||||
|
|
||||||
|
List<Organization> getOrganizationTree();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.tencent.supersonic.auth.api.authentication.service;
|
package com.tencent.supersonic.auth.api.authentication.service;
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authorization.domain.pojo;
|
package com.tencent.supersonic.auth.api.authorization.pojo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class AuthGroup {
|
public class AuthGroup {
|
||||||
|
|
||||||
private String domainId;
|
private String modelId;
|
||||||
private String name;
|
private String name;
|
||||||
private Integer groupId;
|
private Integer groupId;
|
||||||
private List<AuthRule> authRules;
|
private List<AuthRule> authRules;
|
||||||
@@ -7,14 +7,14 @@ import lombok.ToString;
|
|||||||
@ToString
|
@ToString
|
||||||
public class AuthRes {
|
public class AuthRes {
|
||||||
|
|
||||||
private String domainId;
|
private String modelId;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public AuthRes() {
|
public AuthRes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthRes(String domainId, String name) {
|
public AuthRes(String modelId, String name) {
|
||||||
this.domainId = domainId;
|
this.modelId = modelId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authorization.domain.pojo;
|
package com.tencent.supersonic.auth.api.authorization.pojo;
|
||||||
|
|
||||||
import java.beans.Transient;
|
import java.beans.Transient;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.tencent.supersonic.auth.api.authorization.request;
|
package com.tencent.supersonic.auth.api.authorization.request;
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authorization.pojo.AuthRes;
|
import com.tencent.supersonic.auth.api.authorization.pojo.AuthRes;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@@ -11,6 +11,10 @@ import lombok.ToString;
|
|||||||
public class QueryAuthResReq {
|
public class QueryAuthResReq {
|
||||||
|
|
||||||
private String user;
|
private String user;
|
||||||
|
|
||||||
|
private List<String> departmentIds = new ArrayList<>();
|
||||||
|
|
||||||
private List<AuthRes> resources;
|
private List<AuthRes> resources;
|
||||||
private String domainId;
|
|
||||||
|
private String modelId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tencent.supersonic.auth.api.authorization.request;
|
package com.tencent.supersonic.auth.api.authorization.request;
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.common.request.PageBaseReq;
|
import com.tencent.supersonic.common.pojo.PageBaseReq;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.tencent.supersonic.auth.api.authorization.pojo.AuthResGrp;
|
|||||||
import com.tencent.supersonic.auth.api.authorization.pojo.DimensionFilter;
|
import com.tencent.supersonic.auth.api.authorization.pojo.DimensionFilter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
package com.tencent.supersonic.auth.api.authorization.service;
|
package com.tencent.supersonic.auth.api.authorization.service;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authorization.pojo.AuthGroup;
|
||||||
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
||||||
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public interface AuthService {
|
public interface AuthService {
|
||||||
|
|
||||||
AuthorizedResourceResp queryAuthorizedResources(HttpServletRequest request, QueryAuthResReq req);
|
List<AuthGroup> queryAuthGroups(String domainId, Integer groupId);
|
||||||
|
|
||||||
|
void updateAuthGroup(AuthGroup group);
|
||||||
|
|
||||||
|
void removeAuthGroup(AuthGroup group);
|
||||||
|
|
||||||
|
AuthorizedResourceResp queryAuthorizedResources(QueryAuthResReq req, HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>auth</artifactId>
|
<artifactId>auth</artifactId>
|
||||||
|
|||||||
@@ -1,67 +1,58 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.application;
|
package com.tencent.supersonic.auth.authentication.adaptor;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.adaptor.UserAdaptor;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.Organization;
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
||||||
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
||||||
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
import com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO;
|
||||||
import com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO;
|
import com.tencent.supersonic.auth.authentication.persistence.repository.UserRepository;
|
||||||
import com.tencent.supersonic.auth.authentication.domain.repository.UserRepository;
|
import com.tencent.supersonic.auth.authentication.utils.UserTokenUtils;
|
||||||
import com.tencent.supersonic.auth.authentication.domain.utils.UserTokenUtils;
|
import com.tencent.supersonic.common.util.ContextUtils;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class UserServiceImpl implements UserService {
|
|
||||||
|
|
||||||
private UserRepository userRepository;
|
|
||||||
|
|
||||||
private UserTokenUtils userTokenUtils;
|
|
||||||
|
|
||||||
public UserServiceImpl(UserRepository userRepository, UserTokenUtils userTokenUtils) {
|
|
||||||
this.userRepository = userRepository;
|
|
||||||
this.userTokenUtils = userTokenUtils;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public class DefaultUserAdaptor implements UserAdaptor {
|
||||||
|
|
||||||
private List<UserDO> getUserDOList() {
|
private List<UserDO> getUserDOList() {
|
||||||
|
UserRepository userRepository = ContextUtils.getBean(UserRepository.class);
|
||||||
return userRepository.getUserList();
|
return userRepository.getUserList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserDO getUser(String name) {
|
private UserDO getUser(String name) {
|
||||||
|
UserRepository userRepository = ContextUtils.getBean(UserRepository.class);
|
||||||
return userRepository.getUser(name);
|
return userRepository.getUser(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkExist(UserWithPassword user) {
|
|
||||||
UserDO userDO = getUser(user.getName());
|
|
||||||
if (userDO == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return userDO.getPassword().equals(user.getPassword());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getUserNames() {
|
public List<String> getUserNames() {
|
||||||
return getUserDOList().stream().map(UserDO::getName).collect(Collectors.toList());
|
return getUserDOList().stream().map(UserDO::getName).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUserList() {
|
public List<User> getUserList() {
|
||||||
List<UserDO> userDOS = getUserDOList();
|
List<UserDO> userDOS = getUserDOList();
|
||||||
return userDOS.stream().map(this::convert).collect(Collectors.toList());
|
return userDOS.stream().map(this::convert).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Organization> getOrganizationTree() {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
private User convert(UserDO userDO) {
|
private User convert(UserDO userDO) {
|
||||||
User user = new User();
|
User user = new User();
|
||||||
BeanUtils.copyProperties(userDO, user);
|
BeanUtils.copyProperties(userDO, user);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(UserReq userReq) {
|
public void register(UserReq userReq) {
|
||||||
|
UserRepository userRepository = ContextUtils.getBean(UserRepository.class);
|
||||||
List<String> userDOS = getUserNames();
|
List<String> userDOS = getUserNames();
|
||||||
if (userDOS.contains(userReq.getName())) {
|
if (userDOS.contains(userReq.getName())) {
|
||||||
throw new RuntimeException(String.format("user %s exist", userReq.getName()));
|
throw new RuntimeException(String.format("user %s exist", userReq.getName()));
|
||||||
@@ -73,6 +64,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String login(UserReq userReq) {
|
public String login(UserReq userReq) {
|
||||||
|
UserTokenUtils userTokenUtils = ContextUtils.getBean(UserTokenUtils.class);
|
||||||
UserDO userDO = getUser(userReq.getName());
|
UserDO userDO = getUser(userReq.getName());
|
||||||
if (userDO == null) {
|
if (userDO == null) {
|
||||||
throw new RuntimeException("user not exist,please register");
|
throw new RuntimeException("user not exist,please register");
|
||||||
@@ -85,5 +77,14 @@ public class UserServiceImpl implements UserService {
|
|||||||
throw new RuntimeException("password not correct, please try again");
|
throw new RuntimeException("password not correct, please try again");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> getUserByOrg(String key) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getUserAllOrgId(String userName) {
|
||||||
|
return Sets.newHashSet();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.tencent.supersonic.auth.authentication.config;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
public class TppConfig {
|
||||||
|
|
||||||
|
@Value(value = "${auth.app.secret:}")
|
||||||
|
private String appSecret;
|
||||||
|
|
||||||
|
@Value(value = "${auth.app.key:}")
|
||||||
|
private String appKey;
|
||||||
|
|
||||||
|
@Value(value = "${auth.oa.url:}")
|
||||||
|
private String tppOaUrl;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.interceptor;
|
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
|
||||||
import com.tencent.supersonic.auth.authentication.application.UserServiceImpl;
|
|
||||||
import com.tencent.supersonic.auth.authentication.domain.utils.UserTokenUtils;
|
|
||||||
import com.tencent.supersonic.common.exception.AccessException;
|
|
||||||
import com.tencent.supersonic.common.util.context.ContextUtils;
|
|
||||||
import com.tencent.supersonic.common.util.context.S2ThreadContext;
|
|
||||||
import com.tencent.supersonic.common.util.context.ThreadContext;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
|
||||||
throws AccessException {
|
|
||||||
authenticationConfig = ContextUtils.getBean(AuthenticationConfig.class);
|
|
||||||
userServiceImpl = ContextUtils.getBean(UserServiceImpl.class);
|
|
||||||
userTokenUtils = ContextUtils.getBean(UserTokenUtils.class);
|
|
||||||
s2ThreadContext = ContextUtils.getBean(S2ThreadContext.class);
|
|
||||||
if (!authenticationConfig.isEnabled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (isInternalRequest(request)) {
|
|
||||||
String token = userTokenUtils.generateAdminToken();
|
|
||||||
reflectSetparam(request, authenticationConfig.getTokenHttpHeaderKey(), token);
|
|
||||||
}
|
|
||||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
|
||||||
Method method = handlerMethod.getMethod();
|
|
||||||
AuthenticationIgnore ignore = method.getAnnotation(AuthenticationIgnore.class);
|
|
||||||
if (ignore != null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String uri = request.getServletPath();
|
|
||||||
if (isExcludedUri(uri)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserWithPassword user = userTokenUtils.getUserWithPassword(request);
|
|
||||||
if (StringUtils.isNotBlank(user.getName())) {
|
|
||||||
ThreadContext threadContext = ThreadContext.builder()
|
|
||||||
.token(request.getHeader(authenticationConfig.getTokenHttpHeaderKey()))
|
|
||||||
.userName(user.getName())
|
|
||||||
.build();
|
|
||||||
s2ThreadContext.set(threadContext);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
throw new AccessException("authentication failed, please login");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.infrastructure.mapper;
|
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO;
|
|
||||||
import com.tencent.supersonic.auth.authentication.domain.dataobject.UserDOExample;
|
|
||||||
import java.util.List;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface UserDOMapper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
long countByExample(UserDOExample example);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
int deleteByPrimaryKey(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
int insert(UserDO record);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
int insertSelective(UserDO record);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
List<UserDO> selectByExample(UserDOExample example);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
UserDO selectByPrimaryKey(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
int updateByPrimaryKeySelective(UserDO record);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
int updateByPrimaryKey(UserDO record);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.interceptor;
|
package com.tencent.supersonic.auth.authentication.interceptor;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.interceptor;
|
package com.tencent.supersonic.auth.authentication.interceptor;
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
||||||
import com.tencent.supersonic.auth.api.authentication.constant.UserConstants;
|
import com.tencent.supersonic.auth.api.authentication.constant.UserConstants;
|
||||||
import com.tencent.supersonic.auth.authentication.application.UserServiceImpl;
|
import com.tencent.supersonic.auth.authentication.service.UserServiceImpl;
|
||||||
import com.tencent.supersonic.auth.authentication.domain.utils.UserTokenUtils;
|
import com.tencent.supersonic.auth.authentication.utils.UserTokenUtils;
|
||||||
import com.tencent.supersonic.common.util.context.S2ThreadContext;
|
import com.tencent.supersonic.common.util.S2ThreadContext;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.tencent.supersonic.auth.authentication.interceptor;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
||||||
|
import com.tencent.supersonic.auth.authentication.service.UserServiceImpl;
|
||||||
|
import com.tencent.supersonic.auth.authentication.utils.UserTokenUtils;
|
||||||
|
import com.tencent.supersonic.common.pojo.exception.AccessException;
|
||||||
|
import com.tencent.supersonic.common.util.ContextUtils;
|
||||||
|
import com.tencent.supersonic.common.util.S2ThreadContext;
|
||||||
|
import com.tencent.supersonic.common.util.ThreadContext;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||||
|
throws AccessException {
|
||||||
|
authenticationConfig = ContextUtils.getBean(AuthenticationConfig.class);
|
||||||
|
userServiceImpl = ContextUtils.getBean(UserServiceImpl.class);
|
||||||
|
userTokenUtils = ContextUtils.getBean(UserTokenUtils.class);
|
||||||
|
s2ThreadContext = ContextUtils.getBean(S2ThreadContext.class);
|
||||||
|
if (!authenticationConfig.isEnabled()) {
|
||||||
|
setFakerUser(request);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isInternalRequest(request)) {
|
||||||
|
setFakerUser(request);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler instanceof HandlerMethod) {
|
||||||
|
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||||
|
Method method = handlerMethod.getMethod();
|
||||||
|
AuthenticationIgnore ignore = method.getAnnotation(AuthenticationIgnore.class);
|
||||||
|
if (ignore != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String uri = request.getServletPath();
|
||||||
|
if (isExcludedUri(uri)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserWithPassword user = userTokenUtils.getUserWithPassword(request);
|
||||||
|
if (StringUtils.isNotBlank(user.getName())) {
|
||||||
|
setContext(user.getName(), request);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
throw new AccessException("authentication failed, please login");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFakerUser(HttpServletRequest request) {
|
||||||
|
String token = userTokenUtils.generateAdminToken();
|
||||||
|
reflectSetparam(request, authenticationConfig.getTokenHttpHeaderKey(), token);
|
||||||
|
setContext(User.getFakeUser().getName(), request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setContext(String userName, HttpServletRequest request) {
|
||||||
|
ThreadContext threadContext = ThreadContext.builder()
|
||||||
|
.token(request.getHeader(authenticationConfig.getTokenHttpHeaderKey()))
|
||||||
|
.userName(userName)
|
||||||
|
.build();
|
||||||
|
s2ThreadContext.set(threadContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.interceptor;
|
package com.tencent.supersonic.auth.authentication.interceptor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class InterceptorFactory implements WebMvcConfigurer {
|
public class InterceptorFactory implements WebMvcConfigurer {
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ public class InterceptorFactory implements WebMvcConfigurer {
|
|||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
for (AuthenticationInterceptor authenticationInterceptor : authenticationInterceptors) {
|
for (AuthenticationInterceptor authenticationInterceptor : authenticationInterceptors) {
|
||||||
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**")
|
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**")
|
||||||
.excludePathPatterns("/", "/webapp/**","/error");
|
.excludePathPatterns("/", "/webapp/**", "/error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.dataobject;
|
package com.tencent.supersonic.auth.authentication.persistence.dataobject;
|
||||||
|
|
||||||
public class UserDO {
|
public class UserDO {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.dataobject;
|
package com.tencent.supersonic.auth.authentication.persistence.dataobject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -37,13 +37,6 @@ public class UserDOExample {
|
|||||||
oredCriteria = new ArrayList<Criteria>();
|
oredCriteria = new ArrayList<Criteria>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
public void setOrderByClause(String orderByClause) {
|
|
||||||
this.orderByClause = orderByClause;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mbg.generated
|
* @mbg.generated
|
||||||
*/
|
*/
|
||||||
@@ -54,8 +47,8 @@ public class UserDOExample {
|
|||||||
/**
|
/**
|
||||||
* @mbg.generated
|
* @mbg.generated
|
||||||
*/
|
*/
|
||||||
public void setDistinct(boolean distinct) {
|
public void setOrderByClause(String orderByClause) {
|
||||||
this.distinct = distinct;
|
this.orderByClause = orderByClause;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +58,13 @@ public class UserDOExample {
|
|||||||
return distinct;
|
return distinct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mbg.generated
|
||||||
|
*/
|
||||||
|
public void setDistinct(boolean distinct) {
|
||||||
|
this.distinct = distinct;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mbg.generated
|
* @mbg.generated
|
||||||
*/
|
*/
|
||||||
@@ -116,13 +116,6 @@ public class UserDOExample {
|
|||||||
distinct = false;
|
distinct = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @mbg.generated
|
|
||||||
*/
|
|
||||||
public void setLimitStart(Integer limitStart) {
|
|
||||||
this.limitStart = limitStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mbg.generated
|
* @mbg.generated
|
||||||
*/
|
*/
|
||||||
@@ -133,8 +126,8 @@ public class UserDOExample {
|
|||||||
/**
|
/**
|
||||||
* @mbg.generated
|
* @mbg.generated
|
||||||
*/
|
*/
|
||||||
public void setLimitEnd(Integer limitEnd) {
|
public void setLimitStart(Integer limitStart) {
|
||||||
this.limitEnd = limitEnd;
|
this.limitStart = limitStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,6 +137,13 @@ public class UserDOExample {
|
|||||||
return limitEnd;
|
return limitEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mbg.generated
|
||||||
|
*/
|
||||||
|
public void setLimitEnd(Integer limitEnd) {
|
||||||
|
this.limitEnd = limitEnd;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* s2_user null
|
* s2_user null
|
||||||
*/
|
*/
|
||||||
@@ -561,38 +561,6 @@ public class UserDOExample {
|
|||||||
|
|
||||||
private String typeHandler;
|
private String typeHandler;
|
||||||
|
|
||||||
public String getCondition() {
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSecondValue() {
|
|
||||||
return secondValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNoValue() {
|
|
||||||
return noValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSingleValue() {
|
|
||||||
return singleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBetweenValue() {
|
|
||||||
return betweenValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isListValue() {
|
|
||||||
return listValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeHandler() {
|
|
||||||
return typeHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Criterion(String condition) {
|
protected Criterion(String condition) {
|
||||||
super();
|
super();
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
@@ -628,5 +596,37 @@ public class UserDOExample {
|
|||||||
protected Criterion(String condition, Object value, Object secondValue) {
|
protected Criterion(String condition, Object value, Object secondValue) {
|
||||||
this(condition, value, secondValue, null);
|
this(condition, value, secondValue, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getSecondValue() {
|
||||||
|
return secondValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoValue() {
|
||||||
|
return noValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSingleValue() {
|
||||||
|
return singleValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBetweenValue() {
|
||||||
|
return betweenValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isListValue() {
|
||||||
|
return listValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeHandler() {
|
||||||
|
return typeHandler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.tencent.supersonic.auth.authentication.persistence.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO;
|
||||||
|
import com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDOExample;
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserDOMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mbg.generated
|
||||||
|
*/
|
||||||
|
int insert(UserDO record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mbg.generated
|
||||||
|
*/
|
||||||
|
List<UserDO> selectByExample(UserDOExample example);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.infrastructure.repository;
|
package com.tencent.supersonic.auth.authentication.persistence.repository.Impl;
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO;
|
import com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO;
|
||||||
import com.tencent.supersonic.auth.authentication.domain.dataobject.UserDOExample;
|
import com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDOExample;
|
||||||
import com.tencent.supersonic.auth.authentication.domain.repository.UserRepository;
|
import com.tencent.supersonic.auth.authentication.persistence.mapper.UserDOMapper;
|
||||||
import com.tencent.supersonic.auth.authentication.infrastructure.mapper.UserDOMapper;
|
import com.tencent.supersonic.auth.authentication.persistence.repository.UserRepository;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.repository;
|
package com.tencent.supersonic.auth.authentication.persistence.repository;
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO;
|
import com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface UserRepository {
|
public interface UserRepository {
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.rest;
|
package com.tencent.supersonic.auth.authentication.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.Organization;
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
||||||
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||||
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -32,7 +35,6 @@ public class UserController {
|
|||||||
return UserHolder.findUser(httpServletRequest, httpServletResponse);
|
return UserHolder.findUser(httpServletRequest, httpServletResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/getUserNames")
|
@GetMapping("/getUserNames")
|
||||||
public List<String> getUserNames() {
|
public List<String> getUserNames() {
|
||||||
return userService.getUserNames();
|
return userService.getUserNames();
|
||||||
@@ -43,6 +45,21 @@ public class UserController {
|
|||||||
return userService.getUserList();
|
return userService.getUserList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getOrganizationTree")
|
||||||
|
public List<Organization> getOrganizationTree() {
|
||||||
|
return userService.getOrganizationTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getUserAllOrgId/{userName}")
|
||||||
|
public Set<String> getUserAllOrgId(@PathVariable("userName") String userName) {
|
||||||
|
return userService.getUserAllOrgId(userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getUserByOrg/{org}")
|
||||||
|
public List<User> getUserByOrg(@PathVariable("org") String org) {
|
||||||
|
return userService.getUserByOrg(org);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public void register(@RequestBody UserReq userCmd) {
|
public void register(@RequestBody UserReq userCmd) {
|
||||||
userService.register(userCmd);
|
userService.register(userCmd);
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.tencent.supersonic.auth.authentication.service;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.Organization;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||||
|
import com.tencent.supersonic.auth.authentication.utils.ComponentFactory;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getUserNames() {
|
||||||
|
return ComponentFactory.getUserAdaptor().getUserNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> getUserList() {
|
||||||
|
return ComponentFactory.getUserAdaptor().getUserList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getUserAllOrgId(String userName) {
|
||||||
|
return ComponentFactory.getUserAdaptor().getUserAllOrgId(userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> getUserByOrg(String key) {
|
||||||
|
return ComponentFactory.getUserAdaptor().getUserByOrg(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Organization> getOrganizationTree() {
|
||||||
|
return ComponentFactory.getUserAdaptor().getOrganizationTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(UserReq userReq) {
|
||||||
|
ComponentFactory.getUserAdaptor().register(userReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String login(UserReq userReq) {
|
||||||
|
return ComponentFactory.getUserAdaptor().login(userReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.strategy;
|
package com.tencent.supersonic.auth.authentication.strategy;
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.strategy;
|
package com.tencent.supersonic.auth.authentication.strategy;
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
import com.tencent.supersonic.auth.api.authentication.service.UserStrategy;
|
import com.tencent.supersonic.auth.api.authentication.service.UserStrategy;
|
||||||
import com.tencent.supersonic.auth.authentication.domain.utils.UserTokenUtils;
|
import com.tencent.supersonic.auth.authentication.utils.UserTokenUtils;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.strategy;
|
package com.tencent.supersonic.auth.authentication.strategy;
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.tencent.supersonic.auth.authentication.utils;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.adaptor.UserAdaptor;
|
||||||
|
import java.util.Objects;
|
||||||
|
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||||
|
|
||||||
|
public class ComponentFactory {
|
||||||
|
|
||||||
|
private static UserAdaptor userAdaptor;
|
||||||
|
|
||||||
|
public static UserAdaptor getUserAdaptor() {
|
||||||
|
if (Objects.isNull(userAdaptor)) {
|
||||||
|
userAdaptor = init(UserAdaptor.class);
|
||||||
|
}
|
||||||
|
return userAdaptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T init(Class<T> factoryType) {
|
||||||
|
return SpringFactoriesLoader.loadFactories(factoryType,
|
||||||
|
Thread.currentThread().getContextClassLoader()).get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.domain.utils;
|
package com.tencent.supersonic.auth.authentication.utils;
|
||||||
|
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_ALGORITHM;
|
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_ALGORITHM;
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_CREATE_TIME;
|
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_CREATE_TIME;
|
||||||
@@ -13,7 +13,7 @@ import static com.tencent.supersonic.auth.api.authentication.constant.UserConsta
|
|||||||
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
||||||
import com.tencent.supersonic.common.exception.AccessException;
|
import com.tencent.supersonic.common.pojo.exception.AccessException;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
@@ -1,145 +1,159 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<mapper namespace="com.tencent.supersonic.auth.authentication.infrastructure.mapper.UserDOMapper">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<resultMap id="BaseResultMap" type="com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO">
|
<mapper namespace="com.tencent.supersonic.auth.authentication.persistence.mapper.UserDOMapper">
|
||||||
<id column="id" jdbcType="BIGINT" property="id" />
|
<resultMap id="BaseResultMap"
|
||||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
type="com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO">
|
||||||
<result column="password" jdbcType="VARCHAR" property="password" />
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||||
<result column="display_name" jdbcType="VARCHAR" property="displayName" />
|
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||||
<result column="email" jdbcType="VARCHAR" property="email" />
|
<result column="password" jdbcType="VARCHAR" property="password"/>
|
||||||
</resultMap>
|
<result column="display_name" jdbcType="VARCHAR" property="displayName"/>
|
||||||
<sql id="Example_Where_Clause">
|
<result column="email" jdbcType="VARCHAR" property="email"/>
|
||||||
<where>
|
</resultMap>
|
||||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
<sql id="Example_Where_Clause">
|
||||||
<if test="criteria.valid">
|
<where>
|
||||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||||
<foreach collection="criteria.criteria" item="criterion">
|
<if test="criteria.valid">
|
||||||
<choose>
|
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||||
<when test="criterion.noValue">
|
<foreach collection="criteria.criteria" item="criterion">
|
||||||
and ${criterion.condition}
|
<choose>
|
||||||
</when>
|
<when test="criterion.noValue">
|
||||||
<when test="criterion.singleValue">
|
and ${criterion.condition}
|
||||||
and ${criterion.condition} #{criterion.value}
|
</when>
|
||||||
</when>
|
<when test="criterion.singleValue">
|
||||||
<when test="criterion.betweenValue">
|
and ${criterion.condition} #{criterion.value}
|
||||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
</when>
|
||||||
</when>
|
<when test="criterion.betweenValue">
|
||||||
<when test="criterion.listValue">
|
and ${criterion.condition} #{criterion.value} and
|
||||||
and ${criterion.condition}
|
#{criterion.secondValue}
|
||||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
</when>
|
||||||
#{listItem}
|
<when test="criterion.listValue">
|
||||||
</foreach>
|
and ${criterion.condition}
|
||||||
</when>
|
<foreach close=")" collection="criterion.value" item="listItem"
|
||||||
</choose>
|
open="(" separator=",">
|
||||||
|
#{listItem}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
</trim>
|
||||||
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
</trim>
|
</where>
|
||||||
|
</sql>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id
|
||||||
|
, name, password, display_name, email
|
||||||
|
</sql>
|
||||||
|
<select id="selectByExample"
|
||||||
|
parameterType="com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDOExample"
|
||||||
|
resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<if test="distinct">
|
||||||
|
distinct
|
||||||
</if>
|
</if>
|
||||||
</foreach>
|
<include refid="Base_Column_List"/>
|
||||||
</where>
|
from s2_user
|
||||||
</sql>
|
<if test="_parameter != null">
|
||||||
<sql id="Base_Column_List">
|
<include refid="Example_Where_Clause"/>
|
||||||
id, name, password, display_name, email
|
</if>
|
||||||
</sql>
|
<if test="orderByClause != null">
|
||||||
<select id="selectByExample" parameterType="com.tencent.supersonic.auth.authentication.domain.dataobject.UserDOExample" resultMap="BaseResultMap">
|
order by ${orderByClause}
|
||||||
select
|
</if>
|
||||||
<if test="distinct">
|
<if test="limitStart != null and limitStart>=0">
|
||||||
distinct
|
limit #{limitStart} , #{limitEnd}
|
||||||
</if>
|
</if>
|
||||||
<include refid="Base_Column_List" />
|
</select>
|
||||||
from s2_user
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||||
<if test="_parameter != null">
|
select
|
||||||
<include refid="Example_Where_Clause" />
|
<include refid="Base_Column_List"/>
|
||||||
</if>
|
from s2_user
|
||||||
<if test="orderByClause != null">
|
where id = #{id,jdbcType=BIGINT}
|
||||||
order by ${orderByClause}
|
</select>
|
||||||
</if>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
<if test="limitStart != null and limitStart>=0">
|
delete
|
||||||
limit #{limitStart} , #{limitEnd}
|
from s2_user
|
||||||
</if>
|
where id = #{id,jdbcType=BIGINT}
|
||||||
</select>
|
</delete>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
<insert id="insert"
|
||||||
select
|
parameterType="com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO">
|
||||||
<include refid="Base_Column_List" />
|
insert into s2_user (id, name, password,
|
||||||
from s2_user
|
display_name, email)
|
||||||
where id = #{id,jdbcType=BIGINT}
|
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
|
||||||
</select>
|
#{displayName,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR})
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
</insert>
|
||||||
delete from s2_user
|
<insert id="insertSelective"
|
||||||
where id = #{id,jdbcType=BIGINT}
|
parameterType="com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO">
|
||||||
</delete>
|
insert into s2_user
|
||||||
<insert id="insert" parameterType="com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
insert into s2_user (id, name, password,
|
<if test="id != null">
|
||||||
display_name, email)
|
id,
|
||||||
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
|
</if>
|
||||||
#{displayName,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR})
|
<if test="name != null">
|
||||||
</insert>
|
name,
|
||||||
<insert id="insertSelective" parameterType="com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO">
|
</if>
|
||||||
insert into s2_user
|
<if test="password != null">
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
password,
|
||||||
<if test="id != null">
|
</if>
|
||||||
id,
|
<if test="displayName != null">
|
||||||
</if>
|
display_name,
|
||||||
<if test="name != null">
|
</if>
|
||||||
name,
|
<if test="email != null">
|
||||||
</if>
|
email,
|
||||||
<if test="password != null">
|
</if>
|
||||||
password,
|
</trim>
|
||||||
</if>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="displayName != null">
|
<if test="id != null">
|
||||||
display_name,
|
#{id,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
<if test="email != null">
|
<if test="name != null">
|
||||||
email,
|
#{name,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
<if test="password != null">
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
#{password,jdbcType=VARCHAR},
|
||||||
<if test="id != null">
|
</if>
|
||||||
#{id,jdbcType=BIGINT},
|
<if test="displayName != null">
|
||||||
</if>
|
#{displayName,jdbcType=VARCHAR},
|
||||||
<if test="name != null">
|
</if>
|
||||||
#{name,jdbcType=VARCHAR},
|
<if test="email != null">
|
||||||
</if>
|
#{email,jdbcType=VARCHAR},
|
||||||
<if test="password != null">
|
</if>
|
||||||
#{password,jdbcType=VARCHAR},
|
</trim>
|
||||||
</if>
|
</insert>
|
||||||
<if test="displayName != null">
|
<select id="countByExample"
|
||||||
#{displayName,jdbcType=VARCHAR},
|
parameterType="com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDOExample"
|
||||||
</if>
|
resultType="java.lang.Long">
|
||||||
<if test="email != null">
|
select count(*) from s2_user
|
||||||
#{email,jdbcType=VARCHAR},
|
<if test="_parameter != null">
|
||||||
</if>
|
<include refid="Example_Where_Clause"/>
|
||||||
</trim>
|
</if>
|
||||||
</insert>
|
</select>
|
||||||
<select id="countByExample" parameterType="com.tencent.supersonic.auth.authentication.domain.dataobject.UserDOExample" resultType="java.lang.Long">
|
<update id="updateByPrimaryKeySelective"
|
||||||
select count(*) from s2_user
|
parameterType="com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO">
|
||||||
<if test="_parameter != null">
|
update s2_user
|
||||||
<include refid="Example_Where_Clause" />
|
<set>
|
||||||
</if>
|
<if test="name != null">
|
||||||
</select>
|
name = #{name,jdbcType=VARCHAR},
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO">
|
</if>
|
||||||
update s2_user
|
<if test="password != null">
|
||||||
<set>
|
password = #{password,jdbcType=VARCHAR},
|
||||||
<if test="name != null">
|
</if>
|
||||||
name = #{name,jdbcType=VARCHAR},
|
<if test="displayName != null">
|
||||||
</if>
|
display_name = #{displayName,jdbcType=VARCHAR},
|
||||||
<if test="password != null">
|
</if>
|
||||||
password = #{password,jdbcType=VARCHAR},
|
<if test="email != null">
|
||||||
</if>
|
email = #{email,jdbcType=VARCHAR},
|
||||||
<if test="displayName != null">
|
</if>
|
||||||
display_name = #{displayName,jdbcType=VARCHAR},
|
</set>
|
||||||
</if>
|
where id = #{id,jdbcType=BIGINT}
|
||||||
<if test="email != null">
|
</update>
|
||||||
email = #{email,jdbcType=VARCHAR},
|
<update id="updateByPrimaryKey"
|
||||||
</if>
|
parameterType="com.tencent.supersonic.auth.authentication.persistence.dataobject.UserDO">
|
||||||
</set>
|
update s2_user
|
||||||
where id = #{id,jdbcType=BIGINT}
|
set name = #{name,jdbcType=VARCHAR},
|
||||||
</update>
|
password = #{password,jdbcType=VARCHAR},
|
||||||
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.auth.authentication.domain.dataobject.UserDO">
|
display_name = #{displayName,jdbcType=VARCHAR},
|
||||||
update s2_user
|
email = #{email,jdbcType=VARCHAR}
|
||||||
set name = #{name,jdbcType=VARCHAR},
|
where id = #{id,jdbcType=BIGINT}
|
||||||
password = #{password,jdbcType=VARCHAR},
|
</update>
|
||||||
display_name = #{displayName,jdbcType=VARCHAR},
|
|
||||||
email = #{email,jdbcType=VARCHAR}
|
|
||||||
where id = #{id,jdbcType=BIGINT}
|
|
||||||
</update>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>auth</artifactId>
|
<artifactId>auth</artifactId>
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
package com.tencent.supersonic.auth.authorization.application;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.tencent.supersonic.auth.api.authorization.pojo.AuthRes;
|
|
||||||
import com.tencent.supersonic.auth.api.authorization.pojo.AuthResGrp;
|
|
||||||
import com.tencent.supersonic.auth.api.authorization.pojo.DimensionFilter;
|
|
||||||
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
|
||||||
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
|
||||||
import com.tencent.supersonic.auth.authorization.domain.pojo.AuthGroup;
|
|
||||||
import com.tencent.supersonic.auth.authorization.domain.pojo.AuthRule;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class AuthApplicationService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JdbcTemplate jdbcTemplate;
|
|
||||||
|
|
||||||
private List<AuthGroup> load() {
|
|
||||||
List<String> rows = jdbcTemplate.queryForList("select config from s2_auth_groups", String.class);
|
|
||||||
Gson g = new Gson();
|
|
||||||
return rows.stream().map(row -> g.fromJson(row, AuthGroup.class)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AuthGroup> queryAuthGroups(String domainId, Integer groupId) {
|
|
||||||
return load().stream()
|
|
||||||
.filter(group -> (Objects.isNull(groupId) || groupId.equals(group.getGroupId()))
|
|
||||||
&& domainId.equals(group.getDomainId()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateAuthGroup(AuthGroup group) {
|
|
||||||
Gson g = new Gson();
|
|
||||||
if (group.getGroupId() == null) {
|
|
||||||
int nextGroupId = 1;
|
|
||||||
String sql = "select max(group_id) as group_id from s2_auth_groups";
|
|
||||||
Integer obj = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
||||||
if (obj != null) {
|
|
||||||
nextGroupId = obj + 1;
|
|
||||||
}
|
|
||||||
group.setGroupId(nextGroupId);
|
|
||||||
jdbcTemplate.update("insert into s2_auth_groups (group_id, config) values (?, ?);", nextGroupId,
|
|
||||||
g.toJson(group));
|
|
||||||
} else {
|
|
||||||
jdbcTemplate.update("update s2_auth_groups set config = ? where group_id = ?;", g.toJson(group),
|
|
||||||
group.getGroupId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthorizedResourceResp queryAuthorizedResources(QueryAuthResReq req, HttpServletRequest request) {
|
|
||||||
List<AuthGroup> groups = load().stream().
|
|
||||||
filter(group -> group.getAuthorizedUsers().contains(req.getUser()) && req.getDomainId()
|
|
||||||
.equals(group.getDomainId())).
|
|
||||||
collect(Collectors.toList());
|
|
||||||
AuthorizedResourceResp resource = new AuthorizedResourceResp();
|
|
||||||
Map<String, List<AuthGroup>> authGroupsByDomainId = groups.stream()
|
|
||||||
.collect(Collectors.groupingBy(AuthGroup::getDomainId));
|
|
||||||
Map<String, List<AuthRes>> reqAuthRes = req.getResources().stream()
|
|
||||||
.collect(Collectors.groupingBy(AuthRes::getDomainId));
|
|
||||||
|
|
||||||
for (String domainId : reqAuthRes.keySet()) {
|
|
||||||
List<AuthRes> reqResourcesList = reqAuthRes.get(domainId);
|
|
||||||
AuthResGrp rg = new AuthResGrp();
|
|
||||||
if (authGroupsByDomainId.containsKey(domainId)) {
|
|
||||||
List<AuthGroup> authGroups = authGroupsByDomainId.get(domainId);
|
|
||||||
for (AuthRes reqRes : reqResourcesList) {
|
|
||||||
for (AuthGroup authRuleGroup : authGroups) {
|
|
||||||
List<AuthRule> authRules = authRuleGroup.getAuthRules();
|
|
||||||
List<String> allAuthItems = new ArrayList<>();
|
|
||||||
authRules.stream().forEach(authRule -> allAuthItems.addAll(authRule.resourceNames()));
|
|
||||||
|
|
||||||
if (allAuthItems.contains(reqRes.getName())) {
|
|
||||||
rg.getGroup().add(reqRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Objects.nonNull(rg) && !CollectionUtils.isEmpty(rg.getGroup())) {
|
|
||||||
resource.getResources().add(rg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(req.getDomainId())) {
|
|
||||||
List<AuthGroup> authGroups = authGroupsByDomainId.get(req.getDomainId());
|
|
||||||
if (!CollectionUtils.isEmpty(authGroups)) {
|
|
||||||
for (AuthGroup group : authGroups) {
|
|
||||||
if (group.getDimensionFilters() != null
|
|
||||||
&& group.getDimensionFilters().stream().anyMatch(expr -> !Strings.isNullOrEmpty(expr))) {
|
|
||||||
DimensionFilter df = new DimensionFilter();
|
|
||||||
df.setDescription(group.getDimensionFilterDescription());
|
|
||||||
df.setExpressions(group.getDimensionFilters());
|
|
||||||
resource.getFilters().add(df);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeAuthGroup(AuthGroup group) {
|
|
||||||
jdbcTemplate.update("delete from s2_auth_groups where group_id = ?", group.getGroupId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +1,155 @@
|
|||||||
package com.tencent.supersonic.auth.authorization.application;
|
package com.tencent.supersonic.auth.authorization.application;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||||
|
import com.tencent.supersonic.auth.api.authorization.pojo.AuthGroup;
|
||||||
|
import com.tencent.supersonic.auth.api.authorization.pojo.AuthRes;
|
||||||
|
import com.tencent.supersonic.auth.api.authorization.pojo.AuthResGrp;
|
||||||
|
import com.tencent.supersonic.auth.api.authorization.pojo.AuthRule;
|
||||||
|
import com.tencent.supersonic.auth.api.authorization.pojo.DimensionFilter;
|
||||||
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
||||||
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
||||||
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
|
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AuthServiceImpl implements AuthService {
|
public class AuthServiceImpl implements AuthService {
|
||||||
|
|
||||||
private final AuthApplicationService authApplicationService;
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
public AuthServiceImpl(AuthApplicationService authApplicationService) {
|
private UserService userService;
|
||||||
this.authApplicationService = authApplicationService;
|
|
||||||
|
public AuthServiceImpl(JdbcTemplate jdbcTemplate,
|
||||||
|
UserService userService) {
|
||||||
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AuthGroup> load() {
|
||||||
|
List<String> rows = jdbcTemplate.queryForList("select config from s2_auth_groups", String.class);
|
||||||
|
Gson g = new Gson();
|
||||||
|
return rows.stream().map(row -> g.fromJson(row, AuthGroup.class)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthorizedResourceResp queryAuthorizedResources(HttpServletRequest request, QueryAuthResReq req) {
|
public List<AuthGroup> queryAuthGroups(String modelId, Integer groupId) {
|
||||||
return authApplicationService.queryAuthorizedResources(req, request);
|
return load().stream()
|
||||||
|
.filter(group -> (Objects.isNull(groupId) || groupId.equals(group.getGroupId()))
|
||||||
|
&& modelId.equals(group.getModelId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAuthGroup(AuthGroup group) {
|
||||||
|
Gson g = new Gson();
|
||||||
|
if (group.getGroupId() == null) {
|
||||||
|
int nextGroupId = 1;
|
||||||
|
String sql = "select max(group_id) as group_id from s2_auth_groups";
|
||||||
|
Integer obj = jdbcTemplate.queryForObject(sql, Integer.class);
|
||||||
|
if (obj != null) {
|
||||||
|
nextGroupId = obj + 1;
|
||||||
|
}
|
||||||
|
group.setGroupId(nextGroupId);
|
||||||
|
jdbcTemplate.update("insert into s2_auth_groups (group_id, config) values (?, ?);", nextGroupId,
|
||||||
|
g.toJson(group));
|
||||||
|
} else {
|
||||||
|
jdbcTemplate.update("update s2_auth_groups set config = ? where group_id = ?;", g.toJson(group),
|
||||||
|
group.getGroupId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAuthGroup(AuthGroup group) {
|
||||||
|
jdbcTemplate.update("delete from s2_auth_groups where group_id = ?", group.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthorizedResourceResp queryAuthorizedResources(QueryAuthResReq req, HttpServletRequest request) {
|
||||||
|
Set<String> userOrgIds = userService.getUserAllOrgId(req.getUser());
|
||||||
|
if (!CollectionUtils.isEmpty(userOrgIds)) {
|
||||||
|
req.setDepartmentIds(new ArrayList<>(userOrgIds));
|
||||||
|
}
|
||||||
|
List<AuthGroup> groups = getAuthGroups(req);
|
||||||
|
AuthorizedResourceResp resource = new AuthorizedResourceResp();
|
||||||
|
Map<String, List<AuthGroup>> authGroupsByModelId = groups.stream()
|
||||||
|
.collect(Collectors.groupingBy(AuthGroup::getModelId));
|
||||||
|
Map<String, List<AuthRes>> reqAuthRes = req.getResources().stream()
|
||||||
|
.collect(Collectors.groupingBy(AuthRes::getModelId));
|
||||||
|
|
||||||
|
for (String modelId : reqAuthRes.keySet()) {
|
||||||
|
List<AuthRes> reqResourcesList = reqAuthRes.get(modelId);
|
||||||
|
AuthResGrp rg = new AuthResGrp();
|
||||||
|
if (authGroupsByModelId.containsKey(modelId)) {
|
||||||
|
List<AuthGroup> authGroups = authGroupsByModelId.get(modelId);
|
||||||
|
for (AuthRes reqRes : reqResourcesList) {
|
||||||
|
for (AuthGroup authRuleGroup : authGroups) {
|
||||||
|
List<AuthRule> authRules = authRuleGroup.getAuthRules();
|
||||||
|
List<String> allAuthItems = new ArrayList<>();
|
||||||
|
authRules.forEach(authRule -> allAuthItems.addAll(authRule.resourceNames()));
|
||||||
|
|
||||||
|
if (allAuthItems.contains(reqRes.getName())) {
|
||||||
|
rg.getGroup().add(reqRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(rg.getGroup())) {
|
||||||
|
resource.getResources().add(rg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(req.getModelId())) {
|
||||||
|
List<AuthGroup> authGroups = authGroupsByModelId.get(req.getModelId());
|
||||||
|
if (!CollectionUtils.isEmpty(authGroups)) {
|
||||||
|
for (AuthGroup group : authGroups) {
|
||||||
|
if (group.getDimensionFilters() != null
|
||||||
|
&& group.getDimensionFilters().stream().anyMatch(expr -> !Strings.isNullOrEmpty(expr))) {
|
||||||
|
DimensionFilter df = new DimensionFilter();
|
||||||
|
df.setDescription(group.getDimensionFilterDescription());
|
||||||
|
df.setExpressions(group.getDimensionFilters());
|
||||||
|
resource.getFilters().add(df);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AuthGroup> getAuthGroups(QueryAuthResReq req) {
|
||||||
|
List<AuthGroup> groups = load().stream()
|
||||||
|
.filter(group -> {
|
||||||
|
if (!Objects.equals(group.getModelId(), req.getModelId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(group.getAuthorizedUsers()) && group.getAuthorizedUsers()
|
||||||
|
.contains(req.getUser())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (String departmentId : req.getDepartmentIds()) {
|
||||||
|
if (!CollectionUtils.isEmpty(group.getAuthorizedDepartmentIds())
|
||||||
|
&& group.getAuthorizedDepartmentIds().contains(departmentId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
log.info("user:{} department:{} authGroups:{}", req.getUser(), req.getDepartmentIds(), groups);
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.tencent.supersonic.auth.authorization.rest;
|
package com.tencent.supersonic.auth.authorization.rest;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authorization.pojo.AuthGroup;
|
||||||
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
||||||
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
||||||
import com.tencent.supersonic.auth.authorization.application.AuthApplicationService;
|
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
|
||||||
import com.tencent.supersonic.auth.authorization.domain.pojo.AuthGroup;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -19,16 +19,16 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
private final AuthApplicationService service;
|
private final AuthService authService;
|
||||||
|
|
||||||
public AuthController(AuthApplicationService service) {
|
public AuthController(AuthService authService) {
|
||||||
this.service = service;
|
this.authService = authService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/queryGroup")
|
@GetMapping("/queryGroup")
|
||||||
public List<AuthGroup> queryAuthGroup(@RequestParam("domainId") String domainId,
|
public List<AuthGroup> queryAuthGroup(@RequestParam("modelId") String modelId,
|
||||||
@RequestParam(value = "groupId", required = false) Integer groupId) {
|
@RequestParam(value = "groupId", required = false) Integer groupId) {
|
||||||
return service.queryAuthGroups(domainId, groupId);
|
return authService.queryAuthGroups(modelId, groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,12 +37,12 @@ public class AuthController {
|
|||||||
@PostMapping("/createGroup")
|
@PostMapping("/createGroup")
|
||||||
public void newAuthGroup(@RequestBody AuthGroup group) {
|
public void newAuthGroup(@RequestBody AuthGroup group) {
|
||||||
group.setGroupId(null);
|
group.setGroupId(null);
|
||||||
service.updateAuthGroup(group);
|
authService.updateAuthGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/removeGroup")
|
@PostMapping("/removeGroup")
|
||||||
public void removeAuthGroup(@RequestBody AuthGroup group) {
|
public void removeAuthGroup(@RequestBody AuthGroup group) {
|
||||||
service.removeAuthGroup(group);
|
authService.removeAuthGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +55,7 @@ public class AuthController {
|
|||||||
if (group.getGroupId() == null || group.getGroupId() == 0) {
|
if (group.getGroupId() == null || group.getGroupId() == 0) {
|
||||||
throw new RuntimeException("groupId is empty");
|
throw new RuntimeException("groupId is empty");
|
||||||
}
|
}
|
||||||
service.updateAuthGroup(group);
|
authService.updateAuthGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,6 +68,6 @@ public class AuthController {
|
|||||||
@PostMapping("/queryAuthorizedRes")
|
@PostMapping("/queryAuthorizedRes")
|
||||||
public AuthorizedResourceResp queryAuthorizedResources(@RequestBody QueryAuthResReq req,
|
public AuthorizedResourceResp queryAuthorizedResources(@RequestBody QueryAuthResReq req,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
return service.queryAuthorizedResources(req, request);
|
return authService.queryAuthorizedResources(req, request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>supersonic</artifactId>
|
<artifactId>supersonic</artifactId>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.tencent.supersonic.chat.api.service;
|
package com.tencent.supersonic.chat.api.component;
|
||||||
|
|
||||||
import com.tencent.supersonic.chat.api.request.QueryContextReq;
|
import com.tencent.supersonic.chat.api.pojo.QueryContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface defines the contract for a schema mapper that identifies references to schema
|
* This interface defines the contract for a schema mapper that identifies references to schema
|
||||||
@@ -11,5 +11,5 @@ import com.tencent.supersonic.chat.api.request.QueryContextReq;
|
|||||||
*/
|
*/
|
||||||
public interface SchemaMapper {
|
public interface SchemaMapper {
|
||||||
|
|
||||||
void map(QueryContextReq queryContext);
|
void map(QueryContext queryContext);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.component;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.ModelSchema;
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||||
|
import com.tencent.supersonic.semantic.api.model.request.PageDimensionReq;
|
||||||
|
import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||||
|
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||||
|
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||||
|
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||||
|
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||||
|
import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaResp;
|
||||||
|
import com.tencent.supersonic.semantic.api.query.request.QueryDslReq;
|
||||||
|
import com.tencent.supersonic.semantic.api.query.request.QueryMultiStructReq;
|
||||||
|
import com.tencent.supersonic.semantic.api.query.request.QueryStructReq;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines the contract for a semantic layer that provides a simplified and
|
||||||
|
* consistent view of data from multiple sources.
|
||||||
|
* The semantic layer abstracts away the complexity of the underlying data sources and provides
|
||||||
|
* a unified view of the data that is easier to understand and use.
|
||||||
|
* <p>
|
||||||
|
* The interface defines methods for getting metadata as well as querying data in the semantic layer.
|
||||||
|
* Implementations of this interface should provide concrete implementations that interact with the
|
||||||
|
* underlying data sources and return results in a consistent format. Or it can be implemented
|
||||||
|
* as proxy to a remote semantic service.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public interface SemanticLayer {
|
||||||
|
|
||||||
|
QueryResultWithSchemaResp queryByStruct(QueryStructReq queryStructReq, User user);
|
||||||
|
|
||||||
|
QueryResultWithSchemaResp queryByMultiStruct(QueryMultiStructReq queryMultiStructReq, User user);
|
||||||
|
|
||||||
|
QueryResultWithSchemaResp queryByDsl(QueryDslReq queryDslReq, User user);
|
||||||
|
|
||||||
|
List<ModelSchema> getModelSchema();
|
||||||
|
|
||||||
|
List<ModelSchema> getModelSchema(List<Long> ids);
|
||||||
|
|
||||||
|
ModelSchema getModelSchema(Long model, Boolean cacheEnable);
|
||||||
|
|
||||||
|
PageInfo<DimensionResp> getDimensionPage(PageDimensionReq pageDimensionCmd);
|
||||||
|
|
||||||
|
PageInfo<MetricResp> getMetricPage(PageMetricReq pageMetricCmd);
|
||||||
|
|
||||||
|
List<DomainResp> getDomainList(User user);
|
||||||
|
|
||||||
|
List<ModelResp> getModelList(AuthType authType, Long domainId, User user);
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.tencent.supersonic.chat.api.service;
|
package com.tencent.supersonic.chat.api.component;
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.chat.api.pojo.ChatContext;
|
import com.tencent.supersonic.chat.api.pojo.ChatContext;
|
||||||
import com.tencent.supersonic.chat.api.request.QueryContextReq;
|
import com.tencent.supersonic.chat.api.pojo.QueryContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface defines the contract for a semantic parser that can analyze natural language query
|
* This interface defines the contract for a semantic parser that can analyze natural language query
|
||||||
@@ -13,5 +13,5 @@ import com.tencent.supersonic.chat.api.request.QueryContextReq;
|
|||||||
*/
|
*/
|
||||||
public interface SemanticParser {
|
public interface SemanticParser {
|
||||||
|
|
||||||
boolean parse(QueryContextReq queryContext, ChatContext chatCtx);
|
void parse(QueryContext queryContext, ChatContext chatContext);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.component;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
|
||||||
|
import org.apache.calcite.sql.parser.SqlParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class defines the contract for a semantic query that executes specific type of
|
||||||
|
* query based on the results of semantic parsing.
|
||||||
|
*/
|
||||||
|
public interface SemanticQuery {
|
||||||
|
|
||||||
|
String getQueryMode();
|
||||||
|
|
||||||
|
QueryResult execute(User user) throws SqlParseException;
|
||||||
|
|
||||||
|
SemanticParseInfo getParseInfo();
|
||||||
|
|
||||||
|
void setParseInfo(SemanticParseInfo parseInfo);
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ModelSchema {
|
||||||
|
|
||||||
|
private SchemaElement model;
|
||||||
|
private Set<SchemaElement> metrics = new HashSet<>();
|
||||||
|
private Set<SchemaElement> dimensions = new HashSet<>();
|
||||||
|
private Set<SchemaElement> dimensionValues = new HashSet<>();
|
||||||
|
private SchemaElement entity = new SchemaElement();
|
||||||
|
|
||||||
|
public SchemaElement getElement(SchemaElementType elementType, long elementID) {
|
||||||
|
Optional<SchemaElement> element = Optional.empty();
|
||||||
|
|
||||||
|
switch (elementType) {
|
||||||
|
case ENTITY:
|
||||||
|
element = Optional.ofNullable(entity);
|
||||||
|
break;
|
||||||
|
case MODEL:
|
||||||
|
element = Optional.of(model);
|
||||||
|
break;
|
||||||
|
case METRIC:
|
||||||
|
element = metrics.stream().filter(e -> e.getId() == elementID).findFirst();
|
||||||
|
break;
|
||||||
|
case DIMENSION:
|
||||||
|
element = dimensions.stream().filter(e -> e.getId() == elementID).findFirst();
|
||||||
|
break;
|
||||||
|
case VALUE:
|
||||||
|
element = dimensionValues.stream().filter(e -> e.getId() == elementID).findFirst();
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if (element.isPresent()) {
|
||||||
|
return element.get();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.component.SemanticQuery;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class QueryContext {
|
||||||
|
|
||||||
|
private QueryReq request;
|
||||||
|
private List<SemanticQuery> candidateQueries = new ArrayList<>();
|
||||||
|
private SchemaMapInfo mapInfo = new SchemaMapInfo();
|
||||||
|
|
||||||
|
public QueryContext(QueryReq request) {
|
||||||
|
this.request = request;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
//@AllArgsConstructor
|
||||||
|
public class SchemaElement implements Serializable {
|
||||||
|
|
||||||
|
private Long model;
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String bizName;
|
||||||
|
private Long useCnt;
|
||||||
|
private SchemaElementType type;
|
||||||
|
private List<String> alias;
|
||||||
|
|
||||||
|
// public SchemaElement() {
|
||||||
|
// }
|
||||||
|
|
||||||
|
public SchemaElement(Long model, Long id, String name, String bizName,
|
||||||
|
Long useCnt, SchemaElementType type, List<String> alias) {
|
||||||
|
this.model = model;
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.bizName = bizName;
|
||||||
|
this.useCnt = useCnt;
|
||||||
|
this.type = type;
|
||||||
|
this.alias = alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SchemaElement schemaElement = (SchemaElement) o;
|
||||||
|
return Objects.equal(model, schemaElement.model) && Objects.equal(id,
|
||||||
|
schemaElement.id) && Objects.equal(name, schemaElement.name)
|
||||||
|
&& Objects.equal(bizName, schemaElement.bizName) && Objects.equal(
|
||||||
|
useCnt, schemaElement.useCnt) && Objects.equal(type, schemaElement.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(model, id, name, bizName, useCnt, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,23 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo;
|
package com.tencent.supersonic.chat.api.pojo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
@ToString
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
public class SchemaElementMatch {
|
public class SchemaElementMatch {
|
||||||
|
|
||||||
SchemaElementType elementType;
|
SchemaElement element;
|
||||||
|
|
||||||
int elementID;
|
|
||||||
|
|
||||||
double similarity;
|
double similarity;
|
||||||
|
|
||||||
String detectWord;
|
String detectWord;
|
||||||
|
|
||||||
String word;
|
String word;
|
||||||
|
|
||||||
Long frequency;
|
Long frequency;
|
||||||
|
boolean isInherited;
|
||||||
|
|
||||||
public SchemaElementMatch() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo;
|
package com.tencent.supersonic.chat.api.pojo;
|
||||||
|
|
||||||
public enum SchemaElementType {
|
public enum SchemaElementType {
|
||||||
DOMAIN,
|
MODEL,
|
||||||
METRIC,
|
METRIC,
|
||||||
DIMENSION,
|
DIMENSION,
|
||||||
VALUE,
|
VALUE,
|
||||||
|
|||||||
@@ -7,26 +7,21 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class SchemaMapInfo {
|
public class SchemaMapInfo {
|
||||||
|
|
||||||
private Map<Integer, List<SchemaElementMatch>> domainElementMatches = new HashMap<>();
|
private Map<Long, List<SchemaElementMatch>> modelElementMatches = new HashMap<>();
|
||||||
|
|
||||||
public Set<Integer> getMatchedDomains() {
|
public Set<Long> getMatchedModels() {
|
||||||
return domainElementMatches.keySet();
|
return modelElementMatches.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SchemaElementMatch> getMatchedElements(Integer domain) {
|
public List<SchemaElementMatch> getMatchedElements(Long model) {
|
||||||
return domainElementMatches.get(domain);
|
return modelElementMatches.get(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, List<SchemaElementMatch>> getDomainElementMatches() {
|
public Map<Long, List<SchemaElementMatch>> getModelElementMatches() {
|
||||||
return domainElementMatches;
|
return modelElementMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMatchedElements(Integer domain, List<SchemaElementMatch> elementMatches) {
|
public void setMatchedElements(Long model, List<SchemaElementMatch> elementMatches) {
|
||||||
domainElementMatches.put(domain, elementMatches);
|
modelElementMatches.put(model, elementMatches);
|
||||||
}
|
|
||||||
|
|
||||||
public void setDomainElementMatches(
|
|
||||||
Map<Integer, List<SchemaElementMatch>> domainElementMatches) {
|
|
||||||
this.domainElementMatches = domainElementMatches;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,66 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo;
|
package com.tencent.supersonic.chat.api.pojo;
|
||||||
|
|
||||||
|
|
||||||
import com.tencent.supersonic.common.enums.AggregateTypeEnum;
|
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||||
import com.tencent.supersonic.common.pojo.DateConf;
|
import com.tencent.supersonic.common.pojo.DateConf;
|
||||||
import com.tencent.supersonic.common.pojo.Order;
|
import com.tencent.supersonic.common.pojo.Order;
|
||||||
import com.tencent.supersonic.common.pojo.SchemaItem;
|
import com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SemanticParseInfo {
|
public class SemanticParseInfo {
|
||||||
|
|
||||||
String queryMode;
|
private String queryMode;
|
||||||
AggregateTypeEnum aggType = AggregateTypeEnum.NONE;
|
private SchemaElement model;
|
||||||
Long domainId = 0L;
|
private Set<SchemaElement> metrics = new TreeSet<>(new SchemaNameLengthComparator());
|
||||||
String domainName;
|
private Set<SchemaElement> dimensions = new LinkedHashSet();
|
||||||
Long entity = 0L;
|
private SchemaElement entity;
|
||||||
Set<SchemaItem> metrics = new LinkedHashSet();
|
private AggregateTypeEnum aggType = AggregateTypeEnum.NONE;
|
||||||
Set<SchemaItem> dimensions = new LinkedHashSet();
|
private Set<QueryFilter> dimensionFilters = new LinkedHashSet();
|
||||||
Set<Filter> dimensionFilters = new LinkedHashSet();
|
private Set<QueryFilter> metricFilters = new LinkedHashSet();
|
||||||
Set<Filter> metricFilters = new LinkedHashSet();
|
|
||||||
private Set<Order> orders = new LinkedHashSet();
|
private Set<Order> orders = new LinkedHashSet();
|
||||||
private DateConf dateInfo;
|
private DateConf dateInfo;
|
||||||
private Long limit;
|
private Long limit;
|
||||||
private Boolean nativeQuery = false;
|
private Boolean nativeQuery = false;
|
||||||
|
private double score;
|
||||||
|
private List<SchemaElementMatch> elementMatches = new ArrayList<>();
|
||||||
|
private Map<String, Object> properties = new HashMap<>();
|
||||||
|
|
||||||
|
public Long getModelId() {
|
||||||
|
return model != null ? model.getId() : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelName() {
|
||||||
|
return model != null ? model.getName() : "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SchemaNameLengthComparator implements Comparator<SchemaElement> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(SchemaElement o1, SchemaElement o2) {
|
||||||
|
int len1 = o1.getName().length();
|
||||||
|
int len2 = o2.getName().length();
|
||||||
|
if (len1 != len2) {
|
||||||
|
return len1 - len2;
|
||||||
|
} else {
|
||||||
|
return o1.getName().compareTo(o2.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<SchemaElement> getMetrics() {
|
||||||
|
Set<SchemaElement> metricSet = new TreeSet<>(new SchemaNameLengthComparator());
|
||||||
|
metricSet.addAll(metrics);
|
||||||
|
metrics = metricSet;
|
||||||
|
return metrics;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SemanticSchema implements Serializable {
|
||||||
|
|
||||||
|
private List<ModelSchema> modelSchemaList;
|
||||||
|
|
||||||
|
public SemanticSchema(List<ModelSchema> modelSchemaList) {
|
||||||
|
this.modelSchemaList = modelSchemaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(ModelSchema schema) {
|
||||||
|
modelSchemaList.add(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Long, String> getModelIdToName() {
|
||||||
|
return modelSchemaList.stream()
|
||||||
|
.collect(Collectors.toMap(a -> a.getModel().getId(), a -> a.getModel().getName(), (k1, k2) -> k1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SchemaElement> getDimensionValues() {
|
||||||
|
List<SchemaElement> dimensionValues = new ArrayList<>();
|
||||||
|
modelSchemaList.stream().forEach(d -> dimensionValues.addAll(d.getDimensionValues()));
|
||||||
|
return dimensionValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SchemaElement> getDimensions() {
|
||||||
|
List<SchemaElement> dimensions = new ArrayList<>();
|
||||||
|
modelSchemaList.stream().forEach(d -> dimensions.addAll(d.getDimensions()));
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SchemaElement> getMetrics() {
|
||||||
|
List<SchemaElement> metrics = new ArrayList<>();
|
||||||
|
modelSchemaList.stream().forEach(d -> metrics.addAll(d.getMetrics()));
|
||||||
|
return metrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SchemaElement> getModels() {
|
||||||
|
List<SchemaElement> models = new ArrayList<>();
|
||||||
|
modelSchemaList.stream().forEach(d -> models.add(d.getModel()));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SchemaElement> getEntities() {
|
||||||
|
List<SchemaElement> entities = new ArrayList<>();
|
||||||
|
modelSchemaList.stream().forEach(d -> entities.add(d.getEntity()));
|
||||||
|
return entities;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatAggConfigReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* invisible dimensions/metrics
|
||||||
|
*/
|
||||||
|
private ItemVisibility visibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* information about dictionary about the model
|
||||||
|
*/
|
||||||
|
private List<KnowledgeInfoReq> knowledgeInfos;
|
||||||
|
|
||||||
|
private KnowledgeAdvancedConfig globalKnowledgeConfig;
|
||||||
|
|
||||||
|
private ChatDefaultConfigReq chatDefaultConfig;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extended information command about model
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class ChatConfigBaseReq {
|
||||||
|
|
||||||
|
private Long modelId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the chatDetailConfig about the model
|
||||||
|
*/
|
||||||
|
private ChatDetailConfigReq chatDetailConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the chatAggConfig about the model
|
||||||
|
*/
|
||||||
|
private ChatAggConfigReq chatAggConfig;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the recommended questions about the model
|
||||||
|
*/
|
||||||
|
private List<RecommendedQuestionReq> recommendedQuestions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* available status
|
||||||
|
*/
|
||||||
|
private StatusEnum status;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatConfigEditReqReq extends ChatConfigBaseReq {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.tencent.supersonic.chat.domain.pojo.config;
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
import com.tencent.supersonic.common.enums.StatusEnum;
|
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@@ -10,6 +10,6 @@ import lombok.NoArgsConstructor;
|
|||||||
public class ChatConfigFilter {
|
public class ChatConfigFilter {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private Long domainId;
|
private Long modelId;
|
||||||
private StatusEnum status = StatusEnum.ONLINE;
|
private StatusEnum status = StatusEnum.ONLINE;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.supersonic.common.pojo.Constants;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatDefaultConfigReq {
|
||||||
|
|
||||||
|
private List<Long> dimensionIds = new ArrayList<>();
|
||||||
|
private List<Long> metricIds = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default time span unit
|
||||||
|
*/
|
||||||
|
private Integer unit = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default time type: day
|
||||||
|
* DAY, WEEK, MONTH, YEAR
|
||||||
|
*/
|
||||||
|
private String period = Constants.DAY;
|
||||||
|
|
||||||
|
private TimeMode timeMode = TimeMode.LAST;
|
||||||
|
|
||||||
|
public enum TimeMode {
|
||||||
|
/**
|
||||||
|
* date mode
|
||||||
|
* LAST - a certain time
|
||||||
|
* RECENT - a period time
|
||||||
|
*/
|
||||||
|
LAST, RECENT
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatDetailConfigReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* invisible dimensions/metrics
|
||||||
|
*/
|
||||||
|
private ItemVisibility visibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* information about dictionary about the model
|
||||||
|
*/
|
||||||
|
private List<KnowledgeInfoReq> knowledgeInfos;
|
||||||
|
|
||||||
|
private KnowledgeAdvancedConfig globalKnowledgeConfig;
|
||||||
|
|
||||||
|
private ChatDefaultConfigReq chatDefaultConfig;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.chat.domain.pojo.config;
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the entity info about the domain
|
* the entity info about the model
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -18,16 +18,12 @@ public class Entity {
|
|||||||
/**
|
/**
|
||||||
* uniquely identifies an entity
|
* uniquely identifies an entity
|
||||||
*/
|
*/
|
||||||
private List<Long> entityIds;
|
private Long entityId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* entity name list
|
* entity name list
|
||||||
*/
|
*/
|
||||||
private List<String> names;
|
private List<String> names;
|
||||||
|
|
||||||
/**
|
|
||||||
* query entity default information
|
|
||||||
*/
|
|
||||||
private EntityDetailData detailData;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ExecuteQueryReq {
|
||||||
|
|
||||||
|
private User user;
|
||||||
|
private Integer chatId;
|
||||||
|
private String queryText;
|
||||||
|
private SemanticParseInfo parseInfo;
|
||||||
|
private boolean saveAnswer = true;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.tencent.supersonic.chat.domain.pojo.config;
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
@@ -12,10 +13,10 @@ public class ItemVisibility {
|
|||||||
/**
|
/**
|
||||||
* invisible dimensions
|
* invisible dimensions
|
||||||
*/
|
*/
|
||||||
private List<Long> blackDimIdList;
|
private List<Long> blackDimIdList = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* invisible metrics
|
* invisible metrics
|
||||||
*/
|
*/
|
||||||
private List<Long> blackMetricIdList;
|
private List<Long> blackMetricIdList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* advanced knowledge config
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class KnowledgeAdvancedConfig {
|
||||||
|
|
||||||
|
private List<String> blackList = new ArrayList<>();
|
||||||
|
private List<String> whiteList = new ArrayList<>();
|
||||||
|
private List<String> ruleList = new ArrayList<>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* information about dictionary about the model
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class KnowledgeInfoReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* metricId、DimensionId、modelId
|
||||||
|
*/
|
||||||
|
private Long itemId;
|
||||||
|
|
||||||
|
private String bizName;
|
||||||
|
/**
|
||||||
|
* type: IntentionTypeEnum
|
||||||
|
* temporarily only supports dimension-related information
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private TypeEnums type = TypeEnums.DIMENSION;
|
||||||
|
|
||||||
|
private Boolean searchEnable = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* advanced knowledge config for single item
|
||||||
|
*/
|
||||||
|
private KnowledgeAdvancedConfig knowledgeAdvancedConfig;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.chat.domain.pojo.chat;
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -15,20 +15,20 @@ public class PageQueryInfoReq {
|
|||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrent() {
|
public void setPageSize(int pageSize) {
|
||||||
return current;
|
this.pageSize = pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName() {
|
public int getCurrent() {
|
||||||
return userName;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrent(int current) {
|
public void setCurrent(int current) {
|
||||||
this.current = current;
|
this.current = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPageSize(int pageSize) {
|
public String getUserName() {
|
||||||
this.pageSize = pageSize;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserName(String userName) {
|
public void setUserName(String userName) {
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PluginQueryReq {
|
||||||
|
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String parseMode;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String model;
|
||||||
|
|
||||||
|
private String pattern;
|
||||||
|
|
||||||
|
private String createdBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||||
|
import com.tencent.supersonic.common.pojo.DateConf;
|
||||||
|
import com.tencent.supersonic.common.pojo.Order;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QueryDataReq {
|
||||||
|
|
||||||
|
String queryMode;
|
||||||
|
SchemaElement model;
|
||||||
|
Set<SchemaElement> metrics = new HashSet<>();
|
||||||
|
Set<SchemaElement> dimensions = new HashSet<>();
|
||||||
|
Set<QueryFilter> dimensionFilters = new HashSet<>();
|
||||||
|
Set<QueryFilter> metricFilters = new HashSet<>();
|
||||||
|
private Set<Order> orders = new HashSet<>();
|
||||||
|
private DateConf dateInfo;
|
||||||
|
private Long limit;
|
||||||
|
private Boolean nativeQuery = false;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo;
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
import com.tencent.supersonic.semantic.api.query.enums.FilterOperatorEnum;
|
import com.tencent.supersonic.semantic.api.query.enums.FilterOperatorEnum;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -7,7 +7,7 @@ import lombok.ToString;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class Filter {
|
public class QueryFilter {
|
||||||
|
|
||||||
private String bizName;
|
private String bizName;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ public class Filter {
|
|||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Filter filter = (Filter) o;
|
QueryFilter filter = (QueryFilter) o;
|
||||||
return Objects.equals(bizName, filter.bizName) && Objects.equals(name, filter.name)
|
return Objects.equals(bizName, filter.bizName) && Objects.equals(name, filter.name)
|
||||||
&& operator == filter.operator && Objects.equals(value, filter.value) && Objects.equals(
|
&& operator == filter.operator && Objects.equals(value, filter.value) && Objects.equals(
|
||||||
elementID, filter.elementID);
|
elementID, filter.elementID);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QueryFilters {
|
||||||
|
|
||||||
|
private List<QueryFilter> filters = new ArrayList<>();
|
||||||
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QueryReq {
|
||||||
|
|
||||||
|
private String queryText;
|
||||||
|
private Integer chatId;
|
||||||
|
private Long modelId = 0L;
|
||||||
|
private User user;
|
||||||
|
private QueryFilters queryFilters;
|
||||||
|
private boolean saveAnswer = true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.request;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RecommendedQuestionReq {
|
||||||
|
|
||||||
|
private String question;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AggregateInfo {
|
||||||
|
|
||||||
|
private List<MetricInfo> metricInfos = new ArrayList<>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.KnowledgeAdvancedConfig;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.KnowledgeInfoReq;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatAggRichConfigResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* invisible dimensions/metrics
|
||||||
|
*/
|
||||||
|
private ItemVisibilityInfo visibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* information about dictionary about the model
|
||||||
|
*/
|
||||||
|
private List<KnowledgeInfoReq> knowledgeInfos;
|
||||||
|
|
||||||
|
private KnowledgeAdvancedConfig globalKnowledgeConfig;
|
||||||
|
|
||||||
|
private ChatDefaultRichConfigResp chatDefaultConfig;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.ChatAggConfigReq;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.ChatDetailConfigReq;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.RecommendedQuestionReq;
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatConfigResp {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long modelId;
|
||||||
|
|
||||||
|
private ChatDetailConfigReq chatDetailConfig;
|
||||||
|
|
||||||
|
private ChatAggConfigReq chatAggConfig;
|
||||||
|
|
||||||
|
private List<RecommendedQuestionReq> recommendedQuestions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* available status
|
||||||
|
*/
|
||||||
|
private StatusEnum statusEnum;
|
||||||
|
|
||||||
|
private String createdBy;
|
||||||
|
private String updatedBy;
|
||||||
|
private Date createdAt;
|
||||||
|
private Date updatedAt;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.RecommendedQuestionReq;
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatConfigRichResp {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long modelId;
|
||||||
|
|
||||||
|
private String modelName;
|
||||||
|
private String bizName;
|
||||||
|
|
||||||
|
private ChatAggRichConfigResp chatAggRichConfig;
|
||||||
|
|
||||||
|
private ChatDetailRichConfigResp chatDetailRichConfig;
|
||||||
|
|
||||||
|
private List<RecommendedQuestionReq> recommendedQuestions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* available status
|
||||||
|
*/
|
||||||
|
private StatusEnum statusEnum;
|
||||||
|
|
||||||
|
private String createdBy;
|
||||||
|
private String updatedBy;
|
||||||
|
private Date createdAt;
|
||||||
|
private Date updatedAt;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.ChatDefaultConfigReq;
|
||||||
|
import com.tencent.supersonic.common.pojo.Constants;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatDefaultRichConfigResp {
|
||||||
|
|
||||||
|
private List<SchemaElement> dimensions;
|
||||||
|
private List<SchemaElement> metrics;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default time span unit
|
||||||
|
*/
|
||||||
|
private Integer unit = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default time type: day
|
||||||
|
* DAY, WEEK, MONTH, YEAR
|
||||||
|
*/
|
||||||
|
private String period = Constants.DAY;
|
||||||
|
|
||||||
|
private ChatDefaultConfigReq.TimeMode timeMode;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.KnowledgeAdvancedConfig;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.KnowledgeInfoReq;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChatDetailRichConfigResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* invisible dimensions/metrics
|
||||||
|
*/
|
||||||
|
private ItemVisibilityInfo visibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* information about dictionary about the model
|
||||||
|
*/
|
||||||
|
private List<KnowledgeInfoReq> knowledgeInfos;
|
||||||
|
|
||||||
|
private KnowledgeAdvancedConfig globalKnowledgeConfig;
|
||||||
|
|
||||||
|
private ChatDefaultRichConfigResp chatDefaultConfig;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo;
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo;
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class EntityInfo {
|
public class EntityInfo {
|
||||||
|
|
||||||
private DomainInfo domainInfo = new DomainInfo();
|
private ModelInfo modelInfo = new ModelInfo();
|
||||||
private List<DataInfo> dimensions = new ArrayList<>();
|
private List<DataInfo> dimensions = new ArrayList<>();
|
||||||
private List<DataInfo> metrics = new ArrayList<>();
|
private List<DataInfo> metrics = new ArrayList<>();
|
||||||
private String entityId;
|
private String entityId;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EntityRichInfoResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* entity alias
|
||||||
|
*/
|
||||||
|
private List<String> names;
|
||||||
|
|
||||||
|
private SchemaElement dimItem;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tencent.supersonic.chat.domain.pojo.config;
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MetricInfo {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String dimension;
|
||||||
|
private String value;
|
||||||
|
private String date;
|
||||||
|
private Map<String, String> statistics;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo;
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class DomainInfo extends DataInfo implements Serializable {
|
public class ModelInfo extends DataInfo implements Serializable {
|
||||||
|
|
||||||
private List<String> words;
|
private List<String> words;
|
||||||
private String primaryEntityBizName;
|
private String primaryEntityBizName;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ParseResp {
|
||||||
|
|
||||||
|
private Integer chatId;
|
||||||
|
private String queryText;
|
||||||
|
private ParseState state;
|
||||||
|
private List<SemanticParseInfo> selectedParses;
|
||||||
|
private List<SemanticParseInfo> candidateParses;
|
||||||
|
|
||||||
|
public enum ParseState {
|
||||||
|
COMPLETED,
|
||||||
|
PENDING,
|
||||||
|
FAILED
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package com.tencent.supersonic.chat.domain.pojo.chat;
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
import com.tencent.supersonic.chat.api.response.QueryResultResp;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ChatQueryVO {
|
public class QueryResp {
|
||||||
|
|
||||||
private Long questionId;
|
private Long questionId;
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
@@ -13,5 +12,5 @@ public class ChatQueryVO {
|
|||||||
private Integer score;
|
private Integer score;
|
||||||
private String feedback;
|
private String feedback;
|
||||||
private String queryText;
|
private String queryText;
|
||||||
private QueryResultResp queryResponse;
|
private QueryResult queryResult;
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
package com.tencent.supersonic.chat.api.response;
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
import com.tencent.supersonic.chat.api.pojo.EntityInfo;
|
|
||||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||||
import com.tencent.supersonic.semantic.api.core.pojo.QueryAuthorization;
|
import com.tencent.supersonic.common.pojo.QueryAuthorization;
|
||||||
import com.tencent.supersonic.semantic.api.core.pojo.QueryColumn;
|
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class QueryResultResp {
|
public class QueryResult {
|
||||||
|
|
||||||
|
public EntityInfo entityInfo;
|
||||||
|
public AggregateInfo aggregateInfo;
|
||||||
private Long queryId;
|
private Long queryId;
|
||||||
private String queryMode;
|
private String queryMode;
|
||||||
private String querySql;
|
private String querySql;
|
||||||
private int queryState;
|
private QueryState queryState = QueryState.EMPTY;
|
||||||
private List<QueryColumn> queryColumns;
|
private List<QueryColumn> queryColumns;
|
||||||
private QueryAuthorization queryAuthorization;
|
private QueryAuthorization queryAuthorization;
|
||||||
public EntityInfo entityInfo;
|
|
||||||
private SemanticParseInfo chatContext;
|
private SemanticParseInfo chatContext;
|
||||||
private Object response;
|
private Object response;
|
||||||
private List<Map<String, Object>> queryResults;
|
private List<Map<String, Object>> queryResults;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
public enum QueryState {
|
||||||
|
SUCCESS,
|
||||||
|
SEARCH_EXCEPTION,
|
||||||
|
EMPTY,
|
||||||
|
INVALID;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.request.RecommendedQuestionReq;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RecommendQuestionResp {
|
||||||
|
|
||||||
|
private Long modelId;
|
||||||
|
private List<RecommendedQuestionReq> recommendedQuestions;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RecommendResp {
|
||||||
|
|
||||||
|
private List<SchemaElement> dimensions;
|
||||||
|
private List<SchemaElement> metrics;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user