Compare commits
118 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
862d637075 | ||
|
|
7942262eef | ||
|
|
783de18e50 | ||
|
|
3e673c14b7 | ||
|
|
1d5c57d516 | ||
|
|
eda81c36bc | ||
|
|
3d774f43bb | ||
|
|
e509431340 | ||
|
|
77ff6722ab | ||
|
|
ddbadcd1e8 | ||
|
|
03dff7620e | ||
|
|
6da66fac7c | ||
|
|
5abe56caad | ||
|
|
a30d9318da | ||
|
|
da9146f75f | ||
|
|
01ab1d6079 | ||
|
|
1d5e0e2bf1 | ||
|
|
dcbb2b4ac8 | ||
|
|
b1fefdeba7 | ||
|
|
694f847f1d | ||
|
|
9e3f479b3e | ||
|
|
40a3db911d | ||
|
|
50a1f794c2 | ||
|
|
089fab958d | ||
|
|
c56613bc63 | ||
|
|
206f410573 | ||
|
|
9992ca9183 | ||
|
|
8fa04b9973 | ||
|
|
dcf487d55c | ||
|
|
477fef11d3 | ||
|
|
ff5434a173 | ||
|
|
da5e0e5017 | ||
|
|
09d6ccca57 | ||
|
|
2fab0d6a80 | ||
|
|
4dec5b73f4 | ||
|
|
58976dc829 | ||
|
|
744e877309 | ||
|
|
f270a9bb12 | ||
|
|
e0e59cc82e | ||
|
|
a153809649 | ||
|
|
13d6f3ca8b | ||
|
|
8a3f40c394 | ||
|
|
b252eeb33b | ||
|
|
91e7b0eb33 | ||
|
|
7c8a1e7ebc | ||
|
|
0f72acc973 | ||
|
|
e66586c765 | ||
|
|
e949570c1a | ||
|
|
6cb2d76bfb | ||
|
|
2dfb089665 | ||
|
|
911410027d | ||
|
|
861762e005 | ||
|
|
8b106c4588 | ||
|
|
8767acf080 | ||
|
|
3fbc7e5b38 | ||
|
|
b7654611c7 | ||
|
|
64572e52ef | ||
|
|
bd2d08c9ff | ||
|
|
b8a1c8554e | ||
|
|
2e37d4db44 | ||
|
|
a5fcdea2fa | ||
|
|
dfb1e62074 | ||
|
|
d1918b14e2 | ||
|
|
7285947cb3 | ||
|
|
95ec165d49 | ||
|
|
e0289aa247 | ||
|
|
ccf4196f0e | ||
|
|
3048d203ff | ||
|
|
cec0e2d5c8 | ||
|
|
38b04972b6 | ||
|
|
974793cdff | ||
|
|
b05c2158de | ||
|
|
7405d3d711 | ||
|
|
23461e7337 | ||
|
|
d0fa28eebe | ||
|
|
08bdaabcf5 | ||
|
|
f602ccf2a4 | ||
|
|
942b25e9ce | ||
|
|
a01699bd12 | ||
|
|
5cd766762a | ||
|
|
85bbfd1233 | ||
|
|
a8d74a348a | ||
|
|
da5188d840 | ||
|
|
96079c8fa1 | ||
|
|
44ebfbf554 | ||
|
|
6d2e24f455 | ||
|
|
e281b5d47d | ||
|
|
c98c3f1209 | ||
|
|
842b19a378 | ||
|
|
fbfede7663 | ||
|
|
1dd6588d63 | ||
|
|
cb7cce2b98 | ||
|
|
1abcc4f92e | ||
|
|
0451b9319c | ||
|
|
c9e57ba84a | ||
|
|
74d1c06561 | ||
|
|
61f4c316d8 | ||
|
|
39783b3467 | ||
|
|
fad50328b6 | ||
|
|
61938a840f | ||
|
|
cafe72fcc2 | ||
|
|
0965f44866 | ||
|
|
2d9a5ab6b6 | ||
|
|
13ddbc05ee | ||
|
|
ba29b57a14 | ||
|
|
88686f84f4 | ||
|
|
adadffa0cd | ||
|
|
33229dd85a | ||
|
|
c64be60263 | ||
|
|
c89f3696ea | ||
|
|
18d8105344 | ||
|
|
fb38b86b82 | ||
|
|
aeb48e0144 | ||
|
|
713582bebf | ||
|
|
0cf04e8466 | ||
|
|
e923156735 | ||
|
|
7712c52f1b | ||
|
|
5300348552 |
64
.gitignore
vendored
64
.gitignore
vendored
@@ -1,5 +1,61 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
tmlog*.lck
|
||||
tmlog*.log
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
######################################################################
|
||||
# Build Tools
|
||||
|
||||
.gradle
|
||||
/build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
######################################################################
|
||||
# IDE
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/*
|
||||
nbbuild/
|
||||
zyplayer-doc-ui/dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
######################################################################
|
||||
# Others
|
||||
*.log
|
||||
*.xml.versionsBackup
|
||||
|
||||
!*/build/*.java
|
||||
!*/build/*.html
|
||||
!*/build/*.xml
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
# rebel
|
||||
rebel.xml
|
||||
|
||||
### gradle构建 ###
|
||||
*.gradle
|
||||
|
||||
### office ###
|
||||
# 忽略office文件打开临时文件 #
|
||||
[~$]*.*
|
||||
tmlog.lck
|
||||
|
||||
119
README.md
119
README.md
@@ -1,96 +1,67 @@
|
||||
# zyplayer-doc
|
||||
|
||||
#### 项目介绍
|
||||
定位为所有文档的管理项目,swagger文档、dubbo文档、数据库文档、wiki、ElasticSearch文档....等,提供一整套的解决方案,为开发者服务,欢迎有想法的一起来写,给个Star鼓励下呗!(您的一个Star是快速迭代的动力源泉!)
|
||||
## 项目介绍
|
||||
zyplayer-doc是一款在线文档工具,现有swagger 文档、dubbo文档、数据库文档、WIKI文档、ElasticSearch文档等,管理端具有人员管理、权限管理功能等功能。项目后端使用spring-boot、mybatis-plus等框架,前端使用zui、Vue、element-ui等框架。为开发者服务,欢迎有想法的一起来写,给个Star鼓励下呗!(您的一个Star是快速迭代的动力源泉!)
|
||||
欢迎加群讨论,QQ群号:466363173
|
||||
|
||||
体验地址:[http://doc.zyplayer.com](http://doc.zyplayer.com/zyplayer-doc-manage/) 需登录 账号:zyplayer 密码:123456 (未运行dubbo服务,不能体验dubbo文档调试)
|
||||
体验地址:[http://doc.zyplayer.com](http://doc.zyplayer.com/zyplayer-doc-manage/) 账号:zyplayer 密码:123456
|
||||
|
||||
各模块的详细使用文档地址,部署必看:
|
||||
[http://doc.zyplayer.com/zyplayer-doc-manage/open-wiki.html?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb](http://doc.zyplayer.com/zyplayer-doc-manage/open-wiki.html?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb)
|
||||
[详细部署文档](http://doc.zyplayer.com/zyplayer-doc-manage/doc-wiki#/page/share/view?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb)
|
||||
|
||||
## 功能介绍
|
||||
### 一、zyplayer-doc-manage 文档管理后台
|
||||
1. 具有项目模块导航,人员及权限管理功能,分组管理等功能。
|
||||
2. 集成了本项目内的各个子模块功能,是各模块的协调管理模块。
|
||||
|
||||
#### 软件架构
|
||||
##### 一、zyplayer-doc-core 一些核心、公用的类
|
||||
### 二、zyplayer-doc-db 数据库文档
|
||||
一款在线管理数据库的工具,你可以将所有的数据源统一管理到这里面,团队间的各成员就不必每人在自己电脑上装一个数据库管理软件,
|
||||
然后再添加数据源,修改账号密码也可以统一进行修改,新员工进入后对他关心的数据源进行授权即可查看。
|
||||
|
||||
##### 二、zyplayer-doc-db 数据库文档
|
||||
> 原[zyplayer-doc-db](https://gitee.com/zyplayer/zyplayer-doc-db),具有数据库文档的查看、管理、导出等功能
|
||||
1. 支持MySQL、SQLServer、Oracle、PostgreSQL、Hive、Impala数据源。
|
||||
2. 支持数据库表、字段文档查看修改,表文档导出、建表语句DDL导出、表数据导出。
|
||||
3. 支持SQL执行、表数据预览、不同数据库之间的数据互导,支持多数据源管理。
|
||||
4. 支持按人员、按数据源对用户授权,可给用户 库表注释查看、注释修改、SQL执行、函数修改等粒度的授权。
|
||||
5. 支持库函数和存储过程的增删改查,修改记录查询等。
|
||||
6. 目标是取代Navicat,做一个小而精的开源免费的在线数据库管理工具。
|
||||
|
||||
##### 三、zyplayer-doc-manage 可以单独部署的文档管理后台
|
||||
> 后端使用spring-boot、mybatis-plus、springfox-swagger等框架,前端使用[zui](http://zui.sexy/)、[Vue](https://cn.vuejs.org/)、[element-ui](http://element-cn.eleme.io)等框架
|
||||
### 三、zyplayer-doc-wiki wiki文档工具
|
||||
1. 在线管理公司、项目及任意形式的文档
|
||||
2. 文档支持按空间划分,按人员分组授权,支持空间收藏和空间内的文档开放访问。
|
||||
3. 文档支持编辑、查看、评论、上传附件、历史版本查看、页面权限控制、文档搜索等功能。
|
||||
4. 文档编辑支持html富文本方式编辑和markdown的方式编辑。
|
||||
5. 本工具使用的开源工具有:vue、element-ui、mavon-editor、wangeditor等。
|
||||
6. 参考学习了Atlassian Confluence文档工具进行开发,争取作为该软件的开源免费替代产品,同时作为内部文档管理工具最好的存在。
|
||||
|
||||
> 已集成三套优秀swagger文档前端:[zyplayer-doc-swagger](https://gitee.com/zyplayer/zyplayer-doc)、[swagger-bootstrap-ui](https://gitee.com/xiaoym/swagger-bootstrap-ui)、[springfox-swagger-ui](https://github.com/springfox/springfox/tree/master/springfox-swagger-ui)
|
||||
### 四、zyplayer-doc-swagger swagger的UI及整套解决方案
|
||||
1. 支持swagger的文档展示,接口调试,文档导出等,解析速度快,界面设计走心。
|
||||
2. 支持将所有的swagger文档进行统一管理,支持全局参数设置,请求参数缓存,下次自动填充等。
|
||||
3. 目标是解决swagger官方文档查看及接口调试不方便的问题。
|
||||
|
||||
> 已集成本项目内的各子模块,可直接使用
|
||||
### 五、zyplayer-doc-dubbo 将dubbo的文档在线化管理
|
||||
1. 支持zookeeper、nacos的注册中心文档获取,支持在线调试接口
|
||||
|
||||
##### 四、zyplayer-doc-swagger 原[swagger-mg-ui](https://gitee.com/zyplayer/swagger-mg-ui),swagger的UI及整套解决方案
|
||||
> 具有 后端存储、代理请求、模拟返回、所有文档管理 等一系列原创功能,不止UI
|
||||
### 六、zyplayer-doc-es ElasticSearch文档工具
|
||||
1. 支持ElasticSearch的文档查看和执行DSL查询的功能
|
||||
|
||||
##### 五、zyplayer-doc-dubbo 将dubbo的文档在线化管理
|
||||
> 支持zookeeper、nacos的注册中心文档获取,支持在线调试接口
|
||||
### 七、其他
|
||||
1. zyplayer-doc-ui 前面各模块的前端UI源码
|
||||
2. zyplayer-doc-core 一些核心、公用的类
|
||||
3. zyplayer-doc-data 数据库层面的交互
|
||||
4. zyplayer-doc-grpc grpc文档工具
|
||||
5. zyplayer-doc-other 一些测试
|
||||
|
||||
##### 六、zyplayer-doc-wiki wiki文档工具
|
||||
> 支持文档创建、展示,文件上传、下载,空间隔离,开放文档访问等
|
||||
## 运行方式
|
||||
|
||||
##### 七、zyplayer-doc-grpc grpc文档工具
|
||||
> 用比较变态的方式实现了grpc的文档和在线调试功能,通过http的方式来请求grpc的接口
|
||||
|
||||
> 默认未开启此功能,如需使用需要在zyplayer-doc-manage项目中开启@EnableDocGrpc注解
|
||||
|
||||
##### 八、zyplayer-doc-es ElasticSearch文档工具
|
||||
> 支持ElasticSearch的文档查看和执行DSL查询的功能
|
||||
|
||||
#### 运行方式
|
||||
|
||||
1. 创建数据库:zyplayer_doc_manage,执行脚本:[zyplayer_doc_manage.1.0.4.sql](https://gitee.com/zyplayer/zyplayer-doc/blob/master/zyplayer-doc-manage/src/main/resources/sql/zyplayer_doc_manage.1.0.4.sql)
|
||||
1. 创建数据库:zyplayer_doc_manage,执行脚本:[全量建表语句.sql](https://gitee.com/zyplayer/zyplayer-doc/blob/master/zyplayer-doc-manage/src/main/resources/sql/全量建表语句.sql)
|
||||
|
||||
2. 修改zyplayer-doc-manage项目的application.yml配置文件里面的数据库账号密码
|
||||
|
||||
3. 启动zyplayer-doc-manage项目,访问地址:http://127.0.0.1:8083/zyplayer-doc-manage/
|
||||
|
||||
#### 模块介绍
|
||||
|
||||
##### 一、zyplayer-doc-swagger
|
||||
1. 在 `zyplayer-doc-swagger`->`文档管理`->`文档地址管理` 页可以管理`任意地址`的文档,在集成的三套UI中都可以直接查看和调试这里配置的文档,不用对UI做任何调整,只要标准的UI集成进来也可以直接用
|
||||
|
||||
2. 文档展示配置,`自动填充请求参数`:可配置填充级别,`强制重写域名`:文档在本地想调试线上接口的好帮手,`自动保存请求参数`:不用每次输入
|
||||
|
||||
3. 可配置`全局参数`,放在header或param里的
|
||||
|
||||
4. 可对`调试数据`进行管理
|
||||
|
||||
5. `模拟返回`:前端自行调试接口的好帮手
|
||||
|
||||
6. 私人强迫症级定制化文档展示,清晰明了,参数支持批量编辑,每一条线的间距都考量了半天,支持`文件上传`的调试,需要指定dataType = `File`或`MultipartFile`,例:
|
||||
|
||||
@ApiImplicitParam(name = "file", value = "文件", dataType = "File", allowMultiple = true)
|
||||
|
||||
7. 后端代理请求,后端存储,不会存在任何跨域问题
|
||||
|
||||
##### 二、zyplayer-doc-db
|
||||
1. 支持Mysql、SQLserver的数据库表、字段文档查看修改,导出,展示关系图等功能
|
||||
|
||||
2. 支持多数据源,在`zyplayer-doc-manage` -> `application.yml` -> `zyplayer.doc.db.dbConfigList` 处配置多个数据库连接即可
|
||||
|
||||
##### 三、zyplayer-doc-dubbo
|
||||
1. `zyplayer-doc-manage` -> `application.yml` -> `zyplayer.dubbo.zookeeper.url` 配置zookeeper地址
|
||||
|
||||
2. `zyplayer-doc-manage` -> `application.yml` -> `zyplayer.dubbo.nacos.url` 配置nacos服务地址
|
||||
|
||||
3. 默认找zookeeper,未配置再找nacos的配置
|
||||
|
||||
4. 支持文档查找、文档编辑、在线调试接口
|
||||
|
||||
5. 自动获取参数列表需要指定的类存在,所以请在 pom.xml -> dependencies 最后加上服务所在的包,后端才能通过Class.forName("xx");来找到参数列表,减少录入成本
|
||||
|
||||
6. 数组或List参数,调试参数录入格式例:[1,2] ,后端通过JSON工具转成指定类型,有不支持的类型时欢迎反馈
|
||||
|
||||
##### 四、zyplayer-doc-manage
|
||||
1. 整合了上面两个功能到此项目,较少熟悉成本,`git clone`下来即可运行
|
||||
|
||||
2. 具有简单的`权限管理`、`人员管理`功能
|
||||
|
||||
3. 使用最新的一些技术框架,很简单,初学者拿来学习也是很不错的
|
||||
|
||||
更多详细的使用部署文档:http://doc.zyplayer.com/zyplayer-doc-manage/open-wiki.html?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb
|
||||
更多详细的使用部署文档:http://doc.zyplayer.com/zyplayer-doc-manage/doc-wiki#/page/share/view?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb
|
||||
|
||||
#### 界面展示
|
||||

|
||||

|
||||

|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<version>1.0.9</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>zyplayer-doc</name>
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
# update
|
||||
# 本文件用于已部署好的系统检测自己是否需要升级使用,怕有人担心安全一类的问题,所以不提供服务器接口来做
|
||||
lastVersion=1.0.4
|
||||
upgradeContent=1、swagger文档支持给文档地址重命名,下拉时方便查看;\
|
||||
2、swagger文档去掉“文档地址管理”页管理,统一改为“详细地址管理”;\
|
||||
3、数据库文档增加权限控制,分为:库表查看权,注释修改权,SQL执行权;\
|
||||
4、数据库文档增加SQL执行器,可直接执行SQL;\
|
||||
5、数据库文档表信息增加表的状态信息展示;\
|
||||
6、缓存及其他细节优化;
|
||||
upgradeUrl=https://gitee.com/zyplayer/zyplayer-doc/releases
|
||||
nextStep=1、ElasticSearch文档优化
|
||||
lastVersion=1.0.9
|
||||
|
||||
upgradeContent=数据库模块:;\
|
||||
1、增加hive和impala数据源支持,可查看表结构、执行SQL查询数据;\
|
||||
2、框架优化,数据查询和层级更合理;\
|
||||
3、数据查看优化,执行器支持复制为insert、update、json格式;\
|
||||
4、数据库表数据导出支持,支持导出为为insert、update、json格式,可使用单个文件导出或zip压缩文件导出;\
|
||||
5、增加表关系图(简版,找到更好的ER图组件再替换);\
|
||||
6、将表字段、表结构、表关系图、表数据查看页面合并到一个页面,更加便于使用;\
|
||||
7、sqlserver数据库查询加强,数据查询、库表信息、数据导出等全功能支持;\
|
||||
8、优化SQL编辑器引入方式,优化自动提示,优化sqlserver表、字段注释获取和更新方式,数据查询时改为需指定数据库,便于库表检索提示;\
|
||||
9、SQL编辑器自动提示库、表、列逻辑优化,更加好用;\
|
||||
10、sql执行增加动态参数功能,SQL中可使用${xx}或#{xx}动态参数;\
|
||||
11、数据预览列表头移上去展示列说明;\
|
||||
12、自动打包至各模块的文件夹内,不再拷贝打包后的文件;\
|
||||
13、优化关于页面和项目升级提示;\
|
||||
wiki模块:;\
|
||||
1、wiki模块使用vant移动端框架支持手机端文档查看适配 #I2BC14;\
|
||||
2、wiki查看页面优化;
|
||||
|
||||
upgradeUrl=https://gitee.com/zyplayer/zyplayer-doc/releases
|
||||
nextStep=
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
|
||||
模块的详细使用文档地址,部署必看:
|
||||
|
||||
http://doc.zyplayer.com/zyplayer-doc-manage/open-wiki.html?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb
|
||||
http://doc.zyplayer.com/zyplayer-doc-manage/doc-wiki#/page/share/view?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<version>1.0.9</version>
|
||||
<name>zyplayer-doc-core</name>
|
||||
|
||||
<url>http://maven.apache.org</url>
|
||||
@@ -39,8 +39,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-http</artifactId>
|
||||
<version>4.1.8</version>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.6.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
@@ -52,5 +52,10 @@
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>${pagehelper.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>3.0.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1,214 +1,227 @@
|
||||
package com.zyplayer.doc.core.json;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 文档返回数据格式
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月21日
|
||||
*/
|
||||
public class DocResponseJson<T> implements ResponseJson<T> {
|
||||
private static SerializeConfig mapping = new SerializeConfig();
|
||||
static {
|
||||
mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
@ApiModelProperty(value = "状态码")
|
||||
private Integer errCode;
|
||||
@ApiModelProperty(value = "返回值说明")
|
||||
private String errMsg;
|
||||
@ApiModelProperty(value = "返回数据")
|
||||
private Object data;
|
||||
@ApiModelProperty(value = "总数")
|
||||
private Long total;
|
||||
@ApiModelProperty(value = "当前页数")
|
||||
private Integer pageNum;
|
||||
@ApiModelProperty(value = "每页条数")
|
||||
private Integer pageSize;
|
||||
@ApiModelProperty(value = "总页数")
|
||||
private Integer totalPage;
|
||||
|
||||
public DocResponseJson() {
|
||||
this.errCode = 200;
|
||||
}
|
||||
|
||||
public DocResponseJson(Object data) {
|
||||
this.setData(data);
|
||||
this.errCode = 200;
|
||||
}
|
||||
|
||||
public DocResponseJson(int errCode, String errMsg) {
|
||||
super();
|
||||
this.errCode = errCode;
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public DocResponseJson(int errCode, String errMsg, Object data) {
|
||||
super();
|
||||
this.setData(data);
|
||||
this.errCode = errCode;
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public DocResponseJson(Integer errCode) {
|
||||
super();
|
||||
this.errCode = errCode;
|
||||
}
|
||||
|
||||
public Integer getErrCode() {
|
||||
return errCode;
|
||||
}
|
||||
|
||||
public void setErrCode(Integer errCode) {
|
||||
this.errCode = errCode;
|
||||
}
|
||||
|
||||
public String getErrMsg() {
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
public void setErrMsg(String errMsg) {
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public Long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public Integer getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(Integer totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
if (null != data) {
|
||||
if (data instanceof PageInfo) {
|
||||
PageInfo<?> pageInfo = (PageInfo<?>) data;
|
||||
this.data = pageInfo.getList();
|
||||
this.total = pageInfo.getTotal();
|
||||
this.pageNum = pageInfo.getPageNum();
|
||||
this.pageSize = pageInfo.getPageSize();
|
||||
this.totalPage = pageInfo.getPages();
|
||||
} else {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提示语
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> warn(String errMsg) {
|
||||
return new DocResponseJson<T>(300, errMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> error(String errMsg) {
|
||||
return new DocResponseJson<T>(500, errMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> failure(int errCode, String errMsg) {
|
||||
return new DocResponseJson<T>(errCode, errMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功的返回方法
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> ok() {
|
||||
return new DocResponseJson<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功的返回方法
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> ok(Object data) {
|
||||
if (data == null) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
DocResponseJson<T> responseJson = new DocResponseJson<>();
|
||||
responseJson.setData(data);
|
||||
return responseJson;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return JSON.toJSONString(this, mapping);
|
||||
}
|
||||
|
||||
public void send(HttpServletResponse response) {
|
||||
try {
|
||||
response.setStatus(200);
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Cache-Control", "no-cache, must-revalidate");
|
||||
response.getWriter().write(toJson());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DefaultResponseJson [errCode=" + errCode + ", errMsg=" + errMsg + ", data=" + data + "]";
|
||||
}
|
||||
|
||||
}
|
||||
package com.zyplayer.doc.core.json;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 文档返回数据格式
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月21日
|
||||
*/
|
||||
public class DocResponseJson<T> implements ResponseJson<T> {
|
||||
private static SerializeConfig mapping = new SerializeConfig();
|
||||
static {
|
||||
mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
@ApiModelProperty(value = "状态码")
|
||||
private Integer errCode;
|
||||
@ApiModelProperty(value = "返回值说明")
|
||||
private String errMsg;
|
||||
@ApiModelProperty(value = "返回数据")
|
||||
private Object data;
|
||||
@ApiModelProperty(value = "总数")
|
||||
private Long total;
|
||||
@ApiModelProperty(value = "当前页数")
|
||||
private Integer pageNum;
|
||||
@ApiModelProperty(value = "每页条数")
|
||||
private Integer pageSize;
|
||||
@ApiModelProperty(value = "总页数")
|
||||
private Integer totalPage;
|
||||
|
||||
public DocResponseJson() {
|
||||
this.errCode = 200;
|
||||
}
|
||||
|
||||
public DocResponseJson(Object data) {
|
||||
this.setData(data);
|
||||
this.errCode = 200;
|
||||
}
|
||||
|
||||
public DocResponseJson(int errCode, String errMsg) {
|
||||
super();
|
||||
this.errCode = errCode;
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public DocResponseJson(int errCode, String errMsg, Object data) {
|
||||
super();
|
||||
this.setData(data);
|
||||
this.errCode = errCode;
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public DocResponseJson(Integer errCode) {
|
||||
super();
|
||||
this.errCode = errCode;
|
||||
}
|
||||
|
||||
public Integer getErrCode() {
|
||||
return errCode;
|
||||
}
|
||||
|
||||
public void setErrCode(Integer errCode) {
|
||||
this.errCode = errCode;
|
||||
}
|
||||
|
||||
public String getErrMsg() {
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
public void setErrMsg(String errMsg) {
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public Long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public Integer getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(Integer totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
if (null != data) {
|
||||
if (data instanceof PageInfo) {
|
||||
PageInfo<?> pageInfo = (PageInfo<?>) data;
|
||||
this.data = pageInfo.getList();
|
||||
this.total = pageInfo.getTotal();
|
||||
this.pageNum = pageInfo.getPageNum();
|
||||
this.pageSize = pageInfo.getPageSize();
|
||||
this.totalPage = pageInfo.getPages();
|
||||
} else if (data instanceof IPage) {
|
||||
IPage<?> iPage = (IPage<?>) data;
|
||||
this.data = iPage.getRecords();
|
||||
this.total = iPage.getTotal();
|
||||
this.pageNum = (int) iPage.getCurrent();
|
||||
this.pageSize = (int) iPage.getSize();
|
||||
this.totalPage = (int) iPage.getPages();
|
||||
} else {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提示语
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> warn(String errMsg) {
|
||||
return new DocResponseJson<T>(300, errMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> error(String errMsg) {
|
||||
return new DocResponseJson<T>(500, errMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> failure(int errCode, String errMsg) {
|
||||
return new DocResponseJson<T>(errCode, errMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功的返回方法
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> ok() {
|
||||
return new DocResponseJson<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功的返回方法
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月7日
|
||||
* @return
|
||||
*/
|
||||
public static <T> DocResponseJson<T> ok(Object data) {
|
||||
if (data == null) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
DocResponseJson<T> responseJson = new DocResponseJson<>();
|
||||
responseJson.setData(data);
|
||||
return responseJson;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return JSON.toJSONString(this, mapping);
|
||||
}
|
||||
|
||||
public void send(HttpServletResponse response) {
|
||||
try {
|
||||
response.setStatus(200);
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Cache-Control", "no-cache, must-revalidate");
|
||||
response.getWriter().write(toJson());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOk() {
|
||||
return Objects.equals(this.errCode, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DefaultResponseJson [errCode=" + errCode + ", errMsg=" + errMsg + ", data=" + data + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.zyplayer.doc.core.util;
|
||||
|
||||
/**
|
||||
* zyplayer-doc版本号
|
||||
* @since 2021-06-06
|
||||
*/
|
||||
public class ZyplayerDocVersion {
|
||||
public static final String version = "1.0.9";
|
||||
}
|
||||
@@ -5,5 +5,5 @@
|
||||
|
||||
模块的详细使用文档地址,部署必看:
|
||||
|
||||
http://doc.zyplayer.com/zyplayer-doc-manage/open-wiki.html?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb
|
||||
http://doc.zyplayer.com/zyplayer-doc-manage/doc-wiki#/page/share/view?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-data</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<version>1.0.9</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -23,7 +23,7 @@
|
||||
<velocity.engine.core.version>2.0</velocity.engine.core.version>
|
||||
<dozer.core.version>6.1.0</dozer.core.version>
|
||||
<alibaba.druid.version>1.1.9</alibaba.druid.version>
|
||||
<zyplayer.doc.version>1.0.4</zyplayer.doc.version>
|
||||
<zyplayer.doc.version>1.0.9</zyplayer.doc.version>
|
||||
<elasticsearch.version>7.2.0</elasticsearch.version>
|
||||
</properties>
|
||||
|
||||
@@ -67,7 +67,42 @@
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>12.1.0.1-atlassian-hosted</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-jdbc</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j-1.2-api</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j-web</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.dozermapper</groupId>
|
||||
<artifactId>dozer-core</artifactId>
|
||||
|
||||
@@ -44,7 +44,7 @@ public class AuthAspect {
|
||||
HttpServletRequest request = ThreadLocalUtil.getHttpServletRequest();
|
||||
StringBuffer requestURL = request.getRequestURL();
|
||||
String requestURLStr = URLEncoder.encode(requestURL.toString(), "utf-8");
|
||||
return new ModelAndView("redirect:#/user/login?redirect=" + requestURLStr);
|
||||
return new ModelAndView("redirect:./#/user/login?redirect=" + requestURLStr);
|
||||
} else if (returnType.isAssignableFrom(Map.class)) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
@Component
|
||||
public class DocLoginOriginInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Value("${zyplayer.doc.manage.originDomainRegex:''}")
|
||||
@Value("${zyplayer.doc.manage.originDomainRegex:}")
|
||||
private String originDomainRegex;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -54,17 +55,19 @@ public class MybatisPlusConfig {
|
||||
private String username;
|
||||
@Value("${zyplayer.doc.manage.datasource.password}")
|
||||
private String password;
|
||||
@Resource
|
||||
private PaginationInterceptor paginationInterceptor;
|
||||
|
||||
@Bean(name = "manageDatasource")
|
||||
public DataSource manageDatasource() {
|
||||
return DruidDataSourceUtil.createDataSource(driverClassName, url, username, password);
|
||||
public DataSource manageDatasource() throws Exception {
|
||||
return DruidDataSourceUtil.createDataSource(driverClassName, url, username, password, false);
|
||||
}
|
||||
|
||||
@Bean(name = "manageSqlSessionFactory")
|
||||
public MybatisSqlSessionFactoryBean manageSqlSessionFactory() throws Exception {
|
||||
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
||||
sqlSessionFactoryBean.setDataSource(manageDatasource());
|
||||
sqlSessionFactoryBean.setPlugins(new Interceptor[]{SQL_LOG_INTERCEPTOR, MYSQL_PAGE_HELPER});
|
||||
sqlSessionFactoryBean.setPlugins(new Interceptor[]{SQL_LOG_INTERCEPTOR, MYSQL_PAGE_HELPER, paginationInterceptor});
|
||||
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mapper/manage/*Mapper.xml"));
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.zyplayer.doc.data.config.security;
|
||||
|
||||
import com.zyplayer.doc.data.utils.CachePrefix;
|
||||
import com.zyplayer.doc.data.utils.CacheUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户工具类
|
||||
* @author 暮光:城中城
|
||||
@@ -54,6 +57,21 @@ public class DocUserUtil {
|
||||
public static void setCurrentUser(String accessToken, DocUserDetails docUser) {
|
||||
DOC_USER_DETAILS.set(docUser);
|
||||
CacheUtil.put(accessToken, docUser);
|
||||
CacheUtil.put(CachePrefix.LOGIN_USER_ID_TOKEN + docUser.getUserId(), accessToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前用户权限
|
||||
*/
|
||||
public static void setUserAuth(Long userId, Set<String> userAuthSet) {
|
||||
String userToken = CacheUtil.get(CachePrefix.LOGIN_USER_ID_TOKEN + userId);
|
||||
if (userToken != null) {
|
||||
DocUserDetails docUser = CacheUtil.get(userToken);
|
||||
if (docUser != null) {
|
||||
docUser.setAuthorities(userAuthSet);
|
||||
CacheUtil.put(userToken, docUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,6 +69,11 @@ public class DbDatasource implements Serializable {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据源分组
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -155,4 +160,12 @@ public class DbDatasource implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ public class DbFavorite implements Serializable {
|
||||
* 是否有效 0=无效 1=有效
|
||||
*/
|
||||
private Integer yn;
|
||||
|
||||
/**
|
||||
* 执行参数JSON
|
||||
*/
|
||||
private String paramJson;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@@ -129,4 +134,12 @@ public class DbFavorite implements Serializable {
|
||||
public void setDatasourceId(Long datasourceId) {
|
||||
this.datasourceId = datasourceId;
|
||||
}
|
||||
|
||||
public String getParamJson() {
|
||||
return paramJson;
|
||||
}
|
||||
|
||||
public void setParamJson(String paramJson) {
|
||||
this.paramJson = paramJson;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
@@ -53,6 +53,11 @@ public class DbHistory implements Serializable {
|
||||
*/
|
||||
private Integer yn;
|
||||
|
||||
/**
|
||||
* 执行参数JSON
|
||||
*/
|
||||
private String paramJson;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -115,4 +120,12 @@ public class DbHistory implements Serializable {
|
||||
public void setDatasourceId(Long datasourceId) {
|
||||
this.datasourceId = datasourceId;
|
||||
}
|
||||
|
||||
public String getParamJson() {
|
||||
return paramJson;
|
||||
}
|
||||
|
||||
public void setParamJson(String paramJson) {
|
||||
this.paramJson = paramJson;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据库函数修改日志
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-04-26
|
||||
*/
|
||||
public class DbProcLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源ID
|
||||
*/
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 所属数据库
|
||||
*/
|
||||
private String procDb;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String procName;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String procType;
|
||||
|
||||
/**
|
||||
* 函数创建SQL
|
||||
*/
|
||||
private String procBody;
|
||||
|
||||
/**
|
||||
* 保存状态 1=成功 2=失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getDatasourceId() {
|
||||
return datasourceId;
|
||||
}
|
||||
|
||||
public void setDatasourceId(Long datasourceId) {
|
||||
this.datasourceId = datasourceId;
|
||||
}
|
||||
public String getProcDb() {
|
||||
return procDb;
|
||||
}
|
||||
|
||||
public void setProcDb(String procDb) {
|
||||
this.procDb = procDb;
|
||||
}
|
||||
public String getProcName() {
|
||||
return procName;
|
||||
}
|
||||
|
||||
public void setProcName(String procName) {
|
||||
this.procName = procName;
|
||||
}
|
||||
public String getProcType() {
|
||||
return procType;
|
||||
}
|
||||
|
||||
public void setProcType(String procType) {
|
||||
this.procType = procType;
|
||||
}
|
||||
public String getProcBody() {
|
||||
return procBody;
|
||||
}
|
||||
|
||||
public void setProcBody(String procBody) {
|
||||
this.procBody = procBody;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DbProcLog{" +
|
||||
"id=" + id +
|
||||
", datasourceId=" + datasourceId +
|
||||
", procDb=" + procDb +
|
||||
", procName=" + procName +
|
||||
", procType=" + procType +
|
||||
", procBody=" + procBody +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
"}";
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 表关系
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-07
|
||||
*/
|
||||
public class DbTableRelation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源ID
|
||||
*/
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 源库名
|
||||
*/
|
||||
private String startDbName;
|
||||
|
||||
/**
|
||||
* 源表名
|
||||
*/
|
||||
private String startTableName;
|
||||
|
||||
/**
|
||||
* 源字段名
|
||||
*/
|
||||
private String startColumnName;
|
||||
|
||||
/**
|
||||
* 目标库名
|
||||
*/
|
||||
private String endDbName;
|
||||
|
||||
/**
|
||||
* 目标表名
|
||||
*/
|
||||
private String endTableName;
|
||||
|
||||
/**
|
||||
* 目标字段名
|
||||
*/
|
||||
private String endColumnName;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getDatasourceId() {
|
||||
return datasourceId;
|
||||
}
|
||||
|
||||
public void setDatasourceId(Long datasourceId) {
|
||||
this.datasourceId = datasourceId;
|
||||
}
|
||||
public String getStartDbName() {
|
||||
return startDbName;
|
||||
}
|
||||
|
||||
public void setStartDbName(String startDbName) {
|
||||
this.startDbName = startDbName;
|
||||
}
|
||||
public String getStartTableName() {
|
||||
return startTableName;
|
||||
}
|
||||
|
||||
public void setStartTableName(String startTableName) {
|
||||
this.startTableName = startTableName;
|
||||
}
|
||||
public String getStartColumnName() {
|
||||
return startColumnName;
|
||||
}
|
||||
|
||||
public void setStartColumnName(String startColumnName) {
|
||||
this.startColumnName = startColumnName;
|
||||
}
|
||||
public String getEndDbName() {
|
||||
return endDbName;
|
||||
}
|
||||
|
||||
public void setEndDbName(String endDbName) {
|
||||
this.endDbName = endDbName;
|
||||
}
|
||||
public String getEndTableName() {
|
||||
return endTableName;
|
||||
}
|
||||
|
||||
public void setEndTableName(String endTableName) {
|
||||
this.endTableName = endTableName;
|
||||
}
|
||||
public String getEndColumnName() {
|
||||
return endColumnName;
|
||||
}
|
||||
|
||||
public void setEndColumnName(String endColumnName) {
|
||||
this.endColumnName = endColumnName;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DbTableRelation{" +
|
||||
"id=" + id +
|
||||
", datasourceId=" + datasourceId +
|
||||
", startDbName=" + startDbName +
|
||||
", startTableName=" + startTableName +
|
||||
", startColumnName=" + startColumnName +
|
||||
", endDbName=" + endDbName +
|
||||
", endTableName=" + endTableName +
|
||||
", endColumnName=" + endColumnName +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
public class UserGroup implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分组名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标记 0=正常 1=已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserGroup{" +
|
||||
"id=" + id +
|
||||
", name=" + name +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组在各项目内的授权关系
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public class UserGroupAuth implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 群ID
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 授权数据的ID
|
||||
*/
|
||||
private Long dataId;
|
||||
|
||||
/**
|
||||
* 授权类型,依据各项目自己定义
|
||||
*/
|
||||
private Integer authType;
|
||||
|
||||
/**
|
||||
* 项目类型 1=WIKI模块 2=数据库模块
|
||||
*/
|
||||
private Integer projectType;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标记 0=正常 1=已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
public Long getDataId() {
|
||||
return dataId;
|
||||
}
|
||||
|
||||
public void setDataId(Long dataId) {
|
||||
this.dataId = dataId;
|
||||
}
|
||||
public Integer getProjectType() {
|
||||
return projectType;
|
||||
}
|
||||
|
||||
public void setProjectType(Integer projectType) {
|
||||
this.projectType = projectType;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserGroupAuth{" +
|
||||
"id=" + id +
|
||||
", groupId=" + groupId +
|
||||
", dataId=" + dataId +
|
||||
", projectType=" + projectType +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
|
||||
public Integer getAuthType() {
|
||||
return authType;
|
||||
}
|
||||
|
||||
public void setAuthType(Integer authType) {
|
||||
this.authType = authType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户和用户组关系表
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
public class UserGroupRelation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 群ID
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标记 0=正常 1=已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserGroupRelation{" +
|
||||
"id=" + id +
|
||||
", groupId=" + groupId +
|
||||
", userId=" + userId +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户消息表
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-06-23
|
||||
*/
|
||||
public class UserMessage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 系统类型 1=manage 2=wiki 3=db
|
||||
*/
|
||||
private Integer sysType;
|
||||
|
||||
/**
|
||||
* 消息类型 1=普通文本消息 2=wiki文档创建 3=wiki文档删除 4=wiki文档编辑 5=wiki文档权限修改 6=wiki文档评论 7=wiki文档删除评论
|
||||
*/
|
||||
private Integer msgType;
|
||||
|
||||
/**
|
||||
* 消息关联的数据ID
|
||||
*/
|
||||
private Long dataId;
|
||||
|
||||
/**
|
||||
* 消息关联的数据说明
|
||||
*/
|
||||
private String dataDesc;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String msgContent;
|
||||
|
||||
/**
|
||||
* 消息状态 0=未读 1=已读 2=已删除
|
||||
*/
|
||||
private Integer msgStatus;
|
||||
|
||||
/**
|
||||
* 操作人用户ID
|
||||
*/
|
||||
private Long operatorUserId;
|
||||
|
||||
/**
|
||||
* 操作人用户名
|
||||
*/
|
||||
private String operatorUserName;
|
||||
|
||||
/**
|
||||
* 影响用户ID
|
||||
*/
|
||||
private Long affectUserId;
|
||||
|
||||
/**
|
||||
* 影响人用户名
|
||||
*/
|
||||
private String affectUserName;
|
||||
|
||||
/**
|
||||
* 接收人用户ID
|
||||
*/
|
||||
private Long acceptUserId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date creationTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Integer getSysType() {
|
||||
return sysType;
|
||||
}
|
||||
|
||||
public void setSysType(Integer sysType) {
|
||||
this.sysType = sysType;
|
||||
}
|
||||
public Integer getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(Integer msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
public Long getDataId() {
|
||||
return dataId;
|
||||
}
|
||||
|
||||
public void setDataId(Long dataId) {
|
||||
this.dataId = dataId;
|
||||
}
|
||||
public String getDataDesc() {
|
||||
return dataDesc;
|
||||
}
|
||||
|
||||
public void setDataDesc(String dataDesc) {
|
||||
this.dataDesc = dataDesc;
|
||||
}
|
||||
public Integer getMsgStatus() {
|
||||
return msgStatus;
|
||||
}
|
||||
|
||||
public void setMsgStatus(Integer msgStatus) {
|
||||
this.msgStatus = msgStatus;
|
||||
}
|
||||
public Long getOperatorUserId() {
|
||||
return operatorUserId;
|
||||
}
|
||||
|
||||
public void setOperatorUserId(Long operatorUserId) {
|
||||
this.operatorUserId = operatorUserId;
|
||||
}
|
||||
public String getOperatorUserName() {
|
||||
return operatorUserName;
|
||||
}
|
||||
|
||||
public void setOperatorUserName(String operatorUserName) {
|
||||
this.operatorUserName = operatorUserName;
|
||||
}
|
||||
public Long getAcceptUserId() {
|
||||
return acceptUserId;
|
||||
}
|
||||
|
||||
public void setAcceptUserId(Long acceptUserId) {
|
||||
this.acceptUserId = acceptUserId;
|
||||
}
|
||||
public Date getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserMessage{" +
|
||||
"id=" + id +
|
||||
", sysType=" + sysType +
|
||||
", msgType=" + msgType +
|
||||
", dataId=" + dataId +
|
||||
", dataDesc=" + dataDesc +
|
||||
", msgStatus=" + msgStatus +
|
||||
", operatorUserId=" + operatorUserId +
|
||||
", operatorUserName=" + operatorUserName +
|
||||
", acceptUserId=" + acceptUserId +
|
||||
", creationTime=" + creationTime +
|
||||
"}";
|
||||
}
|
||||
|
||||
public String getMsgContent() {
|
||||
return msgContent;
|
||||
}
|
||||
|
||||
public void setMsgContent(String msgContent) {
|
||||
this.msgContent = msgContent;
|
||||
}
|
||||
|
||||
public Long getAffectUserId() {
|
||||
return affectUserId;
|
||||
}
|
||||
|
||||
public void setAffectUserId(Long affectUserId) {
|
||||
this.affectUserId = affectUserId;
|
||||
}
|
||||
|
||||
public String getAffectUserName() {
|
||||
return affectUserName;
|
||||
}
|
||||
|
||||
public void setAffectUserName(String affectUserName) {
|
||||
this.affectUserName = affectUserName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户设置表
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public class UserSetting implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 设置的名字
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 设置的值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标记 0=正常 1=已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserSetting{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", name=" + name +
|
||||
", value=" + value +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,11 @@ public class WikiPage implements Serializable {
|
||||
* 顺序
|
||||
*/
|
||||
private Integer seqNo;
|
||||
|
||||
/**
|
||||
* 编辑框类型 1=HTML 2=Markdown
|
||||
*/
|
||||
private Integer editorType;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@@ -233,4 +238,12 @@ public class WikiPage implements Serializable {
|
||||
", seqNo=" + seqNo +
|
||||
"}";
|
||||
}
|
||||
|
||||
public Integer getEditorType() {
|
||||
return editorType;
|
||||
}
|
||||
|
||||
public void setEditorType(Integer editorType) {
|
||||
this.editorType = editorType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ public class WikiPageFile implements Serializable {
|
||||
*/
|
||||
private Integer downloadNum;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -194,4 +199,12 @@ public class WikiPageFile implements Serializable {
|
||||
public void setDownloadNum(Integer downloadNum) {
|
||||
this.downloadNum = downloadNum;
|
||||
}
|
||||
|
||||
public Long getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(Long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-09-05
|
||||
*/
|
||||
public class WikiPageHistory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 页面ID
|
||||
*/
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标记 0=正常 1=已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* git提交记录ID
|
||||
*/
|
||||
private String gitCommitId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getPageId() {
|
||||
return pageId;
|
||||
}
|
||||
|
||||
public void setPageId(Long pageId) {
|
||||
this.pageId = pageId;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
public String getGitCommitId() {
|
||||
return gitCommitId;
|
||||
}
|
||||
|
||||
public void setGitCommitId(String gitCommitId) {
|
||||
this.gitCommitId = gitCommitId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WikiPageHistory{" +
|
||||
"id=" + id +
|
||||
", pageId=" + pageId +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
", gitCommitId=" + gitCommitId +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户空间收藏记录表
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public class WikiSpaceFavorite implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 空间ID
|
||||
*/
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标记 0=正常 1=已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getSpaceId() {
|
||||
return spaceId;
|
||||
}
|
||||
|
||||
public void setSpaceId(Long spaceId) {
|
||||
this.spaceId = spaceId;
|
||||
}
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WikiSpaceFavorite{" +
|
||||
"id=" + id +
|
||||
", spaceId=" + spaceId +
|
||||
", userId=" + userId +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbProcLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据库函数修改日志 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-04-26
|
||||
*/
|
||||
public interface DbProcLogMapper extends BaseMapper<DbProcLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbTableRelation;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 表关系 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-07
|
||||
*/
|
||||
public interface DbTableRelationMapper extends BaseMapper<DbTableRelation> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroupAuth;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组在各项目内的授权关系 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public interface UserGroupAuthMapper extends BaseMapper<UserGroupAuth> {
|
||||
|
||||
@Select("select a.id from user_group_auth a join user_group_relation b on a.group_id=b.group_id and b.user_id=#{userId} " +
|
||||
"where a.project_type=#{projectType} and a.auth_type=#{authType} and a.data_id=#{spaceId} and b.del_flag=0")
|
||||
Long haveAuth(Long spaceId, Integer projectType, Integer authType, Long userId);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroup;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
public interface UserGroupMapper extends BaseMapper<UserGroup> {
|
||||
|
||||
@Select("select b.id, b.user_no, b.email, b.phone, b.sex, b.user_name, b.avatar from user_group_relation a join user_info b on b.id=a.user_id where a.group_id=#{groupId} and a.del_flag=0 and b.del_flag=0")
|
||||
List<UserInfo> groupUserList(@Param("groupId") Long groupId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroupRelation;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户和用户组关系表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
public interface UserGroupRelationMapper extends BaseMapper<UserGroupRelation> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户消息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-06-23
|
||||
*/
|
||||
public interface UserMessageMapper extends BaseMapper<UserMessage> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserSetting;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户设置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public interface UserSettingMapper extends BaseMapper<UserSetting> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageHistory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-09-05
|
||||
*/
|
||||
public interface WikiPageHistoryMapper extends BaseMapper<WikiPageHistory> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpaceFavorite;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户空间收藏记录表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public interface WikiSpaceFavoriteMapper extends BaseMapper<WikiSpaceFavorite> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zyplayer.doc.data.repository.manage.param;
|
||||
|
||||
/**
|
||||
* 表关系请求参数
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-07
|
||||
*/
|
||||
public class TableRelationParam {
|
||||
private Long sourceId;
|
||||
private String dbName;
|
||||
private String tableName;
|
||||
private String columnName;
|
||||
// 关系JSON,大概是:[{dbName: 'xxx', tableName: 'xxx', columnName: 'xxx'}]
|
||||
private String relation;
|
||||
|
||||
public Long getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public void setSourceId(Long sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
public String getDbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
public void setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getRelation() {
|
||||
return relation;
|
||||
}
|
||||
|
||||
public void setRelation(String relation) {
|
||||
this.relation = relation;
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zyplayer.doc.data.repository.manage.vo;
|
||||
import java.util.Date;
|
||||
|
||||
public class SpaceNewsVo {
|
||||
private String space;
|
||||
private Long spaceId;
|
||||
private Long pageId;
|
||||
private Integer zanNum;
|
||||
@@ -103,4 +104,12 @@ public class SpaceNewsVo {
|
||||
public void setSpaceId(Long spaceId) {
|
||||
this.spaceId = spaceId;
|
||||
}
|
||||
|
||||
public String getSpace() {
|
||||
return space;
|
||||
}
|
||||
|
||||
public void setSpace(String space) {
|
||||
this.space = space;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.zyplayer.doc.data.repository.manage.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表关系结构
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-07
|
||||
*/
|
||||
public class TableRelationVo {
|
||||
private String dbName;
|
||||
private String tableName;
|
||||
// name和columnName是一个,name给前端使用的
|
||||
private String name;
|
||||
private String columnName;
|
||||
private Integer nodeType;
|
||||
private List<TableRelationVo> children;
|
||||
|
||||
public String getDbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
public void setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
public List<TableRelationVo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TableRelationVo> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public Integer getNodeType() {
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(Integer nodeType) {
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
}
|
||||
@@ -5,4 +5,8 @@ public class DocAuthConst {
|
||||
public static final String WIKI = "WIKI_";
|
||||
|
||||
public static final String DB_DATASOURCE_MANAGE = "DB_DATASOURCE_MANAGE";
|
||||
public static final String ES_DATASOURCE_MANAGE = "ES_DATASOURCE_MANAGE";
|
||||
public static final String USER_MANAGE = "USER_MANAGE";
|
||||
public static final String AUTH_MANAGE = "AUTH_MANAGE";
|
||||
public static final String AUTH_ASSIGN = "AUTH_ASSIGN";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.zyplayer.doc.data.repository.support.consts;
|
||||
|
||||
public enum UserMsgSysType {
|
||||
// 系统类型 1=manage 2=wiki 3=db
|
||||
MANAGE(1), WIKI(2), DB(2),
|
||||
;
|
||||
|
||||
UserMsgSysType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private int type;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.zyplayer.doc.data.repository.support.consts;
|
||||
|
||||
public enum UserMsgType {
|
||||
// 消息类型 1=普通文本消息 2=wiki文档创建 3=wiki文档删除 4=wiki文档编辑 5=wiki文档权限修改
|
||||
// 6=wiki文档评论 7=wiki文档删除评论 8=wiki文档上传附件 9=wiki文档修改了父级 10=wiki文档点赞 11=wiki文档附件删除
|
||||
SIMPLE(1), WIKI_PAGE_CREATE(2), WIKI_PAGE_DELETE(3), WIKI_PAGE_UPDATE(4), WIKI_PAGE_AUTH(5),
|
||||
WIKI_PAGE_COMMENT(6), WIKI_PAGE_COMMENT_DEL(7), WIKI_PAGE_UPLOAD(8), WIKI_PAGE_PARENT(9), WIKI_PAGE_ZAN(10), WIKI_PAGE_FILE_DEL(11),
|
||||
WIKI_PAGE_ZAN_CANCEL(12),
|
||||
// !!增加类型的时候需要在zyplayer-doc-ui/wiki-ui/src/components/layouts/GlobalLayout.vue showUserMessage()方法添加类型支持
|
||||
;
|
||||
|
||||
UserMsgType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private int type;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.zyplayer.doc.data.repository.support.consts;
|
||||
|
||||
public class UserSettingConst {
|
||||
public static final String WIKI_ONLY_SHOW_FAVORITE = "wiki_only_show_favorite";
|
||||
}
|
||||
@@ -13,15 +13,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CodeGenerator {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
final String moduleName = "manage";
|
||||
// final String[] tableName = { "zyplayer_storage", "auth_info", "user_auth", "user_info", "db_datasource" };
|
||||
// final String[] tableName = { "wiki_space", "wiki_page", "wiki_page_content", "wiki_page_file", "wiki_page_comment", "wiki_page_zan" };
|
||||
// final String[] tableName = { "db_datasource", "es_datasource", "db_favorite" };
|
||||
final String[] tableName = { "db_transfer_task" };
|
||||
|
||||
final String[] tableName = {"db_table_relation"};
|
||||
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
// 全局配置
|
||||
@@ -35,7 +35,7 @@ public class CodeGenerator {
|
||||
gc.setServiceName("%sService");
|
||||
gc.setControllerName("Generator%sController");
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl("jdbc:mysql://127.0.0.1:3306/zyplayer_doc_manage?useUnicode=true&useSSL=false&characterEncoding=utf8");
|
||||
@@ -44,7 +44,7 @@ public class CodeGenerator {
|
||||
dsc.setUsername("root");
|
||||
dsc.setPassword("root");
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
|
||||
// 包配置
|
||||
final PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName(null);
|
||||
@@ -55,7 +55,7 @@ public class CodeGenerator {
|
||||
pc.setService("service.manage");
|
||||
pc.setServiceImpl("service.manage.impl");
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
|
||||
// 自定义配置
|
||||
InjectionConfig cfg = new InjectionConfig() {
|
||||
@Override
|
||||
@@ -73,7 +73,7 @@ public class CodeGenerator {
|
||||
cfg.setFileOutConfigList(focList);
|
||||
mpg.setCfg(cfg);
|
||||
mpg.setTemplate(new TemplateConfig().setXml(null));
|
||||
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
@@ -90,5 +90,5 @@ public class CodeGenerator {
|
||||
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
|
||||
mpg.execute();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class ElasticSearchUtil {
|
||||
private static Logger logger = LoggerFactory.getLogger(ElasticSearchUtil.class);
|
||||
|
||||
@Value(value = "${zyplayer.doc.manage.elasticsearch.hostPort:''}")
|
||||
@Value(value = "${zyplayer.doc.manage.elasticsearch.hostPort:}")
|
||||
private String hostAndPort;
|
||||
@Value(value = "${zyplayer.doc.manage.elasticsearch.scheme:''}")
|
||||
@Value(value = "${zyplayer.doc.manage.elasticsearch.scheme:}")
|
||||
private String esScheme;
|
||||
@Value("${zyplayer.doc.manage.elasticsearch.open:''}")
|
||||
@Value("${zyplayer.doc.manage.elasticsearch.open:}")
|
||||
private String elasticsearchOpen;
|
||||
|
||||
private static final Object createLock = new Object();
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* es抽象类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-07-07
|
||||
*/
|
||||
@@ -101,6 +102,7 @@ public abstract class EsAbstractService<T> {
|
||||
|
||||
/**
|
||||
* 多条件 模糊查询,查询前100条
|
||||
*
|
||||
* @param condition 查询条件
|
||||
*/
|
||||
public List<T> getDataByCondition(List<EsQueryColumn> condition) {
|
||||
@@ -109,9 +111,10 @@ public abstract class EsAbstractService<T> {
|
||||
|
||||
/**
|
||||
* 多条件 模糊查询
|
||||
* @param condition 查询条件
|
||||
*
|
||||
* @param condition 查询条件
|
||||
* @param startIndex 开始行
|
||||
* @param pageSize 每页数量
|
||||
* @param pageSize 每页数量
|
||||
*/
|
||||
public EsPage<T> getDataByCondition(List<EsQueryColumn> condition, String[] fields, Integer startIndex, Integer pageSize) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
@@ -147,11 +150,13 @@ public abstract class EsAbstractService<T> {
|
||||
});
|
||||
return this.getDataByQuery(boolQueryBuilder, fields, startIndex, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条件 模糊查询
|
||||
*
|
||||
* @param queryBuilders 查询条件
|
||||
* @param startIndex 开始行
|
||||
* @param pageSize 每页数量
|
||||
* @param startIndex 开始行
|
||||
* @param pageSize 每页数量
|
||||
*/
|
||||
public EsPage<T> getDataByQuery(QueryBuilder queryBuilders, String[] fields, Integer startIndex, Integer pageSize) {
|
||||
// 设置高亮标签
|
||||
@@ -208,5 +213,5 @@ public abstract class EsAbstractService<T> {
|
||||
esPage.setData(tableList);
|
||||
return esPage;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface DbHistoryService extends IService<DbHistory> {
|
||||
|
||||
void saveHistory(String content, Long datasourceId);
|
||||
void saveHistory(String content, String paramJson, Long datasourceId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbProcLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据库函数修改日志 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-04-26
|
||||
*/
|
||||
public interface DbProcLogService extends IService<DbProcLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbTableRelation;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zyplayer.doc.data.repository.manage.param.TableRelationParam;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.TableRelationVo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 表关系 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-07
|
||||
*/
|
||||
public interface DbTableRelationService extends IService<DbTableRelation> {
|
||||
|
||||
void update(TableRelationParam param);
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.zyplayer.doc.data.service.manage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserAuth;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户权限表 服务类
|
||||
@@ -12,5 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2019-05-31
|
||||
*/
|
||||
public interface UserAuthService extends IService<UserAuth> {
|
||||
|
||||
|
||||
Set<String> getUserAuthSet(Long id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroupAuth;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组在各项目内的授权关系 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public interface UserGroupAuthService extends IService<UserGroupAuth> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroupRelation;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户和用户组关系表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
public interface UserGroupRelationService extends IService<UserGroupRelation> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroup;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
public interface UserGroupService extends IService<UserGroup> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户消息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-06-23
|
||||
*/
|
||||
public interface UserMessageService extends IService<UserMessage> {
|
||||
|
||||
void addWikiMessage(UserMessage userMessage);
|
||||
|
||||
UserMessage createUserMessage(DocUserDetails currentUser, Long pageId, String dataDesc, UserMsgSysType sysType, UserMsgType msgType);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserSetting;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户设置表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public interface UserSettingService extends IService<UserSetting> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageHistory;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-09-05
|
||||
*/
|
||||
public interface WikiPageHistoryService extends IService<WikiPageHistory> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpaceFavorite;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户空间收藏记录表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public interface WikiSpaceFavoriteService extends IService<WikiSpaceFavorite> {
|
||||
|
||||
}
|
||||
@@ -26,11 +26,12 @@ public class DbHistoryServiceImpl extends ServiceImpl<DbHistoryMapper, DbHistory
|
||||
DbHistoryMapper dbHistoryMapper;
|
||||
|
||||
@Override
|
||||
public void saveHistory(String content, Long datasourceId) {
|
||||
public void saveHistory(String content, String paramJson, Long datasourceId) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
DbHistory dbHistory = new DbHistory();
|
||||
dbHistory.setDatasourceId(datasourceId);
|
||||
dbHistory.setContent(content);
|
||||
dbHistory.setParamJson(paramJson);
|
||||
dbHistory.setCreateTime(new Date());
|
||||
dbHistory.setCreateUserId(currentUser.getUserId());
|
||||
dbHistory.setCreateUserName(currentUser.getUsername());
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbProcLog;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.DbProcLogMapper;
|
||||
import com.zyplayer.doc.data.service.manage.DbProcLogService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据库函数修改日志 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-04-26
|
||||
*/
|
||||
@Service
|
||||
public class DbProcLogServiceImpl extends ServiceImpl<DbProcLogMapper, DbProcLog> implements DbProcLogService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.sun.jersey.server.impl.wadl.WadlResource;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbTableRelation;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.DbTableRelationMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.param.TableRelationParam;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.TableRelationVo;
|
||||
import com.zyplayer.doc.data.service.manage.DbTableRelationService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 表关系 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-07
|
||||
*/
|
||||
@Service
|
||||
public class DbTableRelationServiceImpl extends ServiceImpl<DbTableRelationMapper, DbTableRelation> implements DbTableRelationService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(TableRelationParam param) {
|
||||
UpdateWrapper<DbTableRelation> removeWrapper = new UpdateWrapper<>();
|
||||
removeWrapper.eq("datasource_id", param.getSourceId());
|
||||
removeWrapper.and(wrapper -> wrapper.or(or -> or.eq("start_db_name", param.getDbName())
|
||||
.eq("start_table_name", param.getTableName())
|
||||
.eq("start_column_name", param.getColumnName())
|
||||
).or(or -> or.eq("end_db_name", param.getDbName())
|
||||
.eq("end_table_name", param.getTableName())
|
||||
.eq("end_column_name", param.getColumnName())
|
||||
));
|
||||
this.remove(removeWrapper);
|
||||
if(StringUtils.isEmpty(param.getRelation())) {
|
||||
return;
|
||||
}
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
List<TableRelationParam> tableRelationList = JSON.parseArray(param.getRelation(), TableRelationParam.class);
|
||||
for (TableRelationParam relation : tableRelationList) {
|
||||
if (StringUtils.isBlank(relation.getDbName())
|
||||
|| StringUtils.isBlank(relation.getTableName())
|
||||
|| StringUtils.isBlank(relation.getColumnName())) {
|
||||
continue;
|
||||
}
|
||||
DbTableRelation tableRelation = new DbTableRelation();
|
||||
tableRelation.setDatasourceId(param.getSourceId());
|
||||
tableRelation.setStartDbName(param.getDbName());
|
||||
tableRelation.setStartTableName(param.getTableName());
|
||||
tableRelation.setStartColumnName(param.getColumnName());
|
||||
tableRelation.setEndDbName(relation.getDbName());
|
||||
tableRelation.setEndTableName(relation.getTableName());
|
||||
tableRelation.setEndColumnName(relation.getColumnName());
|
||||
tableRelation.setCreateTime(new Date());
|
||||
tableRelation.setCreateUserId(currentUser.getUserId());
|
||||
tableRelation.setCreateUserName(currentUser.getUsername());
|
||||
this.save(tableRelation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.AuthInfo;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserAuth;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.UserAuthMapper;
|
||||
import com.zyplayer.doc.data.service.manage.AuthInfoService;
|
||||
import com.zyplayer.doc.data.service.manage.UserAuthService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户权限表 服务实现类
|
||||
@@ -16,5 +23,25 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class UserAuthServiceImpl extends ServiceImpl<UserAuthMapper, UserAuth> implements UserAuthService {
|
||||
|
||||
|
||||
@Resource
|
||||
AuthInfoService authInfoService;
|
||||
|
||||
@Override
|
||||
public Set<String> getUserAuthSet(Long id) {
|
||||
QueryWrapper<UserAuth> authWrapper = new QueryWrapper<>();
|
||||
authWrapper.eq("user_id", id).eq("del_flag", "0");
|
||||
List<UserAuth> userAuthList = this.list(authWrapper);
|
||||
Set<String> userAuthSet = Collections.emptySet();
|
||||
if (userAuthList != null && userAuthList.size() > 0) {
|
||||
List<Long> authIdList = userAuthList.stream().map(UserAuth::getAuthId).collect(Collectors.toList());
|
||||
Collection<AuthInfo> authInfoList = authInfoService.listByIds(authIdList);
|
||||
Map<Long, String> authNameMap = authInfoList.stream().collect(Collectors.toMap(AuthInfo::getId, AuthInfo::getAuthName));
|
||||
userAuthSet = userAuthList.stream().map(val -> {
|
||||
String authName = Optional.ofNullable(authNameMap.get(val.getAuthId())).orElse("");
|
||||
return authName + Optional.ofNullable(val.getAuthCustomSuffix()).orElse("");
|
||||
}).collect(Collectors.toSet());
|
||||
}
|
||||
return userAuthSet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroupAuth;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.UserGroupAuthMapper;
|
||||
import com.zyplayer.doc.data.service.manage.UserGroupAuthService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组在各项目内的授权关系 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
@Service
|
||||
public class UserGroupAuthServiceImpl extends ServiceImpl<UserGroupAuthMapper, UserGroupAuth> implements UserGroupAuthService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroupRelation;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.UserGroupRelationMapper;
|
||||
import com.zyplayer.doc.data.service.manage.UserGroupRelationService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户和用户组关系表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
@Service
|
||||
public class UserGroupRelationServiceImpl extends ServiceImpl<UserGroupRelationMapper, UserGroupRelation> implements UserGroupRelationService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserGroup;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.UserGroupMapper;
|
||||
import com.zyplayer.doc.data.service.manage.UserGroupService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-08
|
||||
*/
|
||||
@Service
|
||||
public class UserGroupServiceImpl extends ServiceImpl<UserGroupMapper, UserGroup> implements UserGroupService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.UserMessageMapper;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.manage.UserMessageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户消息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-06-23
|
||||
*/
|
||||
@Service
|
||||
public class UserMessageServiceImpl extends ServiceImpl<UserMessageMapper, UserMessage> implements UserMessageService {
|
||||
|
||||
@Override
|
||||
public UserMessage createUserMessage(DocUserDetails currentUser, Long dataId, String dataDesc, UserMsgSysType sysType, UserMsgType msgType) {
|
||||
UserMessage userMessage = new UserMessage();
|
||||
userMessage.setDataId(dataId);
|
||||
userMessage.setDataDesc(dataDesc);
|
||||
userMessage.setSysType(sysType.getType());
|
||||
userMessage.setMsgType(msgType.getType());
|
||||
userMessage.setOperatorUserId(currentUser.getUserId());
|
||||
userMessage.setOperatorUserName(currentUser.getUsername());
|
||||
return userMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWikiMessage(UserMessage userMessage) {
|
||||
// 初始值,操作人的消息默认为已读
|
||||
userMessage.setMsgStatus(1);
|
||||
userMessage.setCreationTime(new Date());
|
||||
// 操作人
|
||||
userMessage.setAcceptUserId(userMessage.getOperatorUserId());
|
||||
this.setWikiMsgContentForOperator(userMessage);
|
||||
this.save(userMessage);
|
||||
// 影响人
|
||||
if (userMessage.getAffectUserId() != null && !Objects.equals(userMessage.getAffectUserId(), userMessage.getOperatorUserId())) {
|
||||
userMessage.setId(null);
|
||||
// 收影响人的消息为未读
|
||||
userMessage.setMsgStatus(0);
|
||||
userMessage.setAcceptUserId(userMessage.getAffectUserId());
|
||||
this.setWikiMsgContentForAffect(userMessage);
|
||||
this.save(userMessage);
|
||||
}
|
||||
// 后期可以添加文档的关注人等
|
||||
}
|
||||
|
||||
/**
|
||||
* 给操作人发通知的内容
|
||||
*
|
||||
* @param userMessage
|
||||
*/
|
||||
private void setWikiMsgContentForOperator(UserMessage userMessage) {
|
||||
if (Objects.equals(UserMsgType.WIKI_PAGE_UPLOAD.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您在‘%s’文档内上传了一个附件", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_AUTH.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您修改了‘%s’文档内‘%s’的权限", userMessage.getDataDesc(), userMessage.getAffectUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_COMMENT.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您评论了‘%s’", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_COMMENT_DEL.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您删除了‘%s’文档的评论", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_PARENT.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您修改了‘%s’文档的父级", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_DELETE.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您删除了‘%s’", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_CREATE.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您创建了‘%s’", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_UPDATE.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您修改了‘%s’", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_ZAN.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您赞同了‘%s’", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_FILE_DEL.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您删除了‘%s’文档的一个附件", userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_ZAN_CANCEL.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您取消了对‘%s’文档的赞同", userMessage.getDataDesc()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 给影响人发通知的内容
|
||||
*
|
||||
* @param userMessage
|
||||
*/
|
||||
private void setWikiMsgContentForAffect(UserMessage userMessage) {
|
||||
if (Objects.equals(UserMsgType.WIKI_PAGE_UPLOAD.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("‘%s’为您的文档‘%s’上传了附件", userMessage.getOperatorUserName(), userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_AUTH.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您在‘%s’文档内的权限被‘%s’修改了", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_COMMENT.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您的‘%s’文档收到了来自‘%s’的评论", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_COMMENT_DEL.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("‘%s’删除了您的文档‘%s’的一条评论", userMessage.getOperatorUserName(), userMessage.getDataDesc()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_PARENT.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您的‘%s’文档被‘%s’修改了父级", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_DELETE.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您的‘%s’文档被‘%s’删除了", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_UPDATE.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您的‘%s’文档被‘%s’修改了", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_ZAN.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您的‘%s’文档收到了‘%s’的赞同", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_FILE_DEL.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("您的‘%s’文档被‘%s’删除了一个附件", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
|
||||
} else if (Objects.equals(UserMsgType.WIKI_PAGE_ZAN_CANCEL.getType(), userMessage.getMsgType())) {
|
||||
userMessage.setMsgContent(String.format("‘%s’取消了对文档‘%s’的赞同", userMessage.getOperatorUserName(), userMessage.getDataDesc()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserSetting;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.UserSettingMapper;
|
||||
import com.zyplayer.doc.data.service.manage.UserSettingService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户设置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
@Service
|
||||
public class UserSettingServiceImpl extends ServiceImpl<UserSettingMapper, UserSetting> implements UserSettingService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageHistory;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageHistoryMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageHistoryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020-09-05
|
||||
*/
|
||||
@Service
|
||||
public class WikiPageHistoryServiceImpl extends ServiceImpl<WikiPageHistoryMapper, WikiPageHistory> implements WikiPageHistoryService {
|
||||
|
||||
}
|
||||
@@ -2,8 +2,14 @@ package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.manage.UserMessageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -25,6 +31,8 @@ public class WikiPageServiceImpl extends ServiceImpl<WikiPageMapper, WikiPage> i
|
||||
|
||||
@Resource
|
||||
WikiPageMapper wikiPageMapper;
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
|
||||
@Override
|
||||
public void changeParent(WikiPage wikiPage, Integer beforeSeq, Integer afterSeq) {
|
||||
@@ -43,10 +51,28 @@ public class WikiPageServiceImpl extends ServiceImpl<WikiPageMapper, WikiPage> i
|
||||
wikiPage.setSeqNo(lastSeq + 1);
|
||||
}
|
||||
this.updateById(wikiPage);
|
||||
// 给相关人发送消息
|
||||
WikiPage wikiPageSel = this.getById(wikiPage.getId());
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_PARENT);
|
||||
userMessage.setAffectUserId(wikiPageSel.getCreateUserId());
|
||||
userMessage.setAffectUserName(wikiPageSel.getCreateUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePage(WikiPage wikiPage) {
|
||||
// 给相关人发送消息
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPage.getId(), wikiPage.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_DELETE);
|
||||
userMessage.setAffectUserId(wikiPage.getCreateUserId());
|
||||
userMessage.setAffectUserName(wikiPage.getCreateUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
// 递归删除
|
||||
this.deletePageAndSon(wikiPage);
|
||||
}
|
||||
|
||||
private void deletePageAndSon(WikiPage wikiPage) {
|
||||
wikiPage.setDelFlag(1);
|
||||
this.updateById(wikiPage);
|
||||
|
||||
@@ -60,7 +86,7 @@ public class WikiPageServiceImpl extends ServiceImpl<WikiPageMapper, WikiPage> i
|
||||
// 递归删除子页面
|
||||
for (WikiPage page : wikiPageList) {
|
||||
wikiPage.setId(page.getId());
|
||||
this.deletePage(wikiPage);
|
||||
this.deletePageAndSon(wikiPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class WikiPageZanServiceImpl extends ServiceImpl<WikiPageZanMapper, WikiP
|
||||
wikiPageZan.setCreateUserName(currentUser.getUsername());
|
||||
this.save(wikiPageZan);
|
||||
}
|
||||
int numAdd = wikiPageZan.getYn() == 1 ? 1 : -1;
|
||||
int numAdd = Objects.equals(wikiPageZan.getYn(), 1) ? 1 : -1;
|
||||
wikiPageMapper.updateZanNum(wikiPageZan.getPageId(), numAdd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpaceFavorite;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiSpaceFavoriteMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceFavoriteService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户空间收藏记录表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
@Service
|
||||
public class WikiSpaceFavoriteServiceImpl extends ServiceImpl<WikiSpaceFavoriteMapper, WikiSpaceFavorite> implements WikiSpaceFavoriteService {
|
||||
|
||||
}
|
||||
@@ -3,4 +3,5 @@ package com.zyplayer.doc.data.utils;
|
||||
public class CachePrefix {
|
||||
public static final String WIKI_LOCK_PAGE = "WIKI_LOCK_PAGE_";
|
||||
public static final String DB_EDITOR_DATA_CACHE = "DB_EDITOR_DATA_CACHE_";
|
||||
public static final String LOGIN_USER_ID_TOKEN = "LOGIN_USER_ID_TOKEN_";
|
||||
}
|
||||
|
||||
@@ -4,47 +4,44 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class DruidDataSourceUtil {
|
||||
|
||||
private static AtomicLong nameId = new AtomicLong(0);
|
||||
|
||||
public static DruidDataSource createDataSource(String driverClassName, String url, String username, String password){
|
||||
try {
|
||||
// 数据源配置
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setDriverClassName(driverClassName);
|
||||
dataSource.setUrl(url);
|
||||
dataSource.setUsername(username);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setInitialSize(2);
|
||||
dataSource.setMinIdle(2);
|
||||
dataSource.setMaxActive(50);
|
||||
dataSource.setTestWhileIdle(true);
|
||||
dataSource.setTestOnBorrow(false);
|
||||
dataSource.setTestOnReturn(false);
|
||||
dataSource.setValidationQuery("select 1");
|
||||
dataSource.setMaxWait(3000);
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(60000);
|
||||
dataSource.setMinEvictableIdleTimeMillis(3600000);
|
||||
// 重试3次,失败退出,源码里是errorCount > connectionErrorRetryAttempts,所以写成2就是3次、、、
|
||||
// CreateConnectionThread 源码在这个类里面
|
||||
dataSource.setConnectionErrorRetryAttempts(2);
|
||||
dataSource.setBreakAfterAcquireFailure(true);
|
||||
dataSource.setName("zyplayer-doc-db-" + nameId.incrementAndGet());
|
||||
if (url.contains("oracle")) {
|
||||
dataSource.setValidationQuery("select 1 from dual");
|
||||
}
|
||||
DruidPooledConnection connection = dataSource.getConnection(3000);
|
||||
if (connection == null) {
|
||||
throw new ConfirmException("尝试获取该数据源连接失败:" + url);
|
||||
}
|
||||
connection.recycle();
|
||||
return dataSource;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
public static DruidDataSource createDataSource(String driverClassName, String url, String username, String password, boolean breakAfterAcquireFailure) throws Exception {
|
||||
// 数据源配置
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setDriverClassName(driverClassName);
|
||||
dataSource.setUrl(url);
|
||||
dataSource.setUsername(username);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setInitialSize(2);
|
||||
dataSource.setMinIdle(2);
|
||||
dataSource.setMaxActive(50);
|
||||
dataSource.setTestWhileIdle(true);
|
||||
dataSource.setTestOnBorrow(false);
|
||||
dataSource.setTestOnReturn(false);
|
||||
dataSource.setValidationQuery("select 1");
|
||||
dataSource.setMaxWait(3000);
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(60000);
|
||||
dataSource.setMinEvictableIdleTimeMillis(3600000);
|
||||
// 重试3次,失败退出,源码里是errorCount > connectionErrorRetryAttempts,所以写成2就是3次、、、
|
||||
// CreateConnectionThread 源码在这个类里面
|
||||
dataSource.setConnectionErrorRetryAttempts(2);
|
||||
dataSource.setBreakAfterAcquireFailure(breakAfterAcquireFailure);// false:连接出错后不退出,等待下个定时周期重试,true:失败不再重试
|
||||
dataSource.setTimeBetweenConnectErrorMillis(180000);// 连接出错后重试时间间隔3分钟
|
||||
dataSource.setName("zyplayer-doc-db-" + nameId.incrementAndGet());
|
||||
if (Objects.equals("oracle.jdbc.driver.OracleDriver", driverClassName)) {
|
||||
dataSource.setValidationQuery("select 1 from dual");
|
||||
}
|
||||
return null;
|
||||
DruidPooledConnection connection = dataSource.getConnection(3000);
|
||||
if (connection == null) {
|
||||
throw new ConfirmException("尝试获取该数据源连接失败:" + url);
|
||||
}
|
||||
connection.recycle();
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.DbProcLogMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.DbTableRelationMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.UserGroupAuthMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.UserGroupMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.UserGroupRelationMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.UserMessageMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.UserSettingMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.WikiPageHistoryMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.WikiSpaceFavoriteMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,53 +1,6 @@
|
||||
# zyplayer-doc-db
|
||||
|
||||
#### 项目介绍
|
||||
数据库文档工具,网页方式管理,只需两步即可对表注释、字段注释进行查看、修改、导出等操作,支持字段或注释的模糊查询,只有一个单独的页面,方便集成到已有的管理系统里面,本工具不对数据源进行管理,因为后台管理系统肯定是已有的数据源,没必要再来创建,只需要注入数据源即可管理
|
||||
数据库文档、管理工具,对表注释、字段注释进行查看、修改、导出等操作,支持字段或注释的模糊查询
|
||||
|
||||
按照指定的格式可展示表的关系图,展示样式见下图
|
||||
本关系图不是通过外键生成,所以需要在字段注释最后按规则添加外键关系才能生成图表,支持的格式有:
|
||||
1. T:表,例:XXX(字段注释),T:user_info
|
||||
2. T:表.关联ID,例:XXX(字段注释),T:user_info.id
|
||||
3. T:库.表.关联ID,例:XXX(字段注释),T:order_db.user_info.id
|
||||
|
||||
关系图为实验功能,有更好的建议或展示方式欢迎提交建议!
|
||||
|
||||
当前支持SqlServer、mysql的管理,后期加上oracle和其他数据库的支持
|
||||
|
||||
#### 使用方式
|
||||
1. 添加注解:@EnableDocDb
|
||||
2. 注入Bean
|
||||
|
||||
```
|
||||
// 注入已有的数据源
|
||||
@Resource DataSource orderDatasource;
|
||||
@Resource DataSource userDatasource;
|
||||
|
||||
//....
|
||||
|
||||
@Bean
|
||||
public DatabaseRegistrationBean databaseRegistrationBean() {
|
||||
DatabaseRegistrationBean bean = new DatabaseRegistrationBean();
|
||||
List<DataSource> dataSourceList = new LinkedList<>();
|
||||
// 设置需要展示的数据源
|
||||
dataSourceList.add(orderDatasource);
|
||||
dataSourceList.add(userDatasource);
|
||||
bean.setDataSourceList(dataSourceList);
|
||||
return bean;
|
||||
}
|
||||
```
|
||||
|
||||
3. 打开网页访问域名地址+doc-db.html即可,例:http://192.168.0.100:8080/doc-db.html
|
||||
|
||||
#### 界面展示
|
||||
基本界面:
|
||||

|
||||
模糊查询:
|
||||

|
||||
表注释修改:
|
||||

|
||||
文档导出:
|
||||

|
||||
导出文档查看:
|
||||

|
||||
表关联关系图:
|
||||

|
||||
支持MySQL、SQLServer、Oracle数据源,支持数据库表、字段文档查看修改,表文档导出,SQL执行、表数据预览、不同数据库之间的数据互导,支持多数据源管理。支持按人员、按数据源对用户授权,可给用户 库表注释查看、注释修改、SQL执行 粒度的授权。目标是取代Navicat,做一个开源免费的在线数据库管理工具。
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-db</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<version>1.0.9</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>zyplayer-doc-db</name>
|
||||
<description>数据库文档工具</description>
|
||||
@@ -67,13 +67,18 @@
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.47</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<zyplayer.doc.version>1.0.4</zyplayer.doc.version>
|
||||
<zyplayer.doc.version>1.0.9</zyplayer.doc.version>
|
||||
<!-- 打包跳过单元测试 -->
|
||||
<skipTests>true</skipTests>
|
||||
<elasticsearch.version>7.2.0</elasticsearch.version>
|
||||
@@ -104,6 +109,10 @@
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources/dist</directory>
|
||||
<targetPath>META-INF/resources/</targetPath>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<targetPath>META-INF/resources/</targetPath>
|
||||
@@ -126,103 +135,5 @@
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.2</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<skipTests>${skipTests}</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.2</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package com.zyplayer.doc.db.controller;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
@@ -22,31 +16,28 @@ import com.zyplayer.doc.data.utils.CacheUtil;
|
||||
import com.zyplayer.doc.db.controller.vo.DatabaseExportVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo.TableInfoVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableDdlVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableStatusVo;
|
||||
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean.DatabaseProduct;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||
import com.zyplayer.doc.db.framework.db.dto.*;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.mysql.MysqlMapper;
|
||||
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import com.zyplayer.doc.db.framework.utils.PoiUtil;
|
||||
import com.zyplayer.doc.db.service.DatabaseServiceFactory;
|
||||
import com.zyplayer.doc.db.service.DbBaseService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
@@ -65,6 +56,8 @@ public class DatabaseDocController {
|
||||
DbDatasourceService dbDatasourceService;
|
||||
@Resource
|
||||
UserAuthService userAuthService;
|
||||
@Resource
|
||||
DatabaseServiceFactory databaseServiceFactory;
|
||||
|
||||
@PostMapping(value = "/getDataSourceList")
|
||||
public ResponseJson getDataSourceList() {
|
||||
@@ -84,258 +77,148 @@ public class DatabaseDocController {
|
||||
List<Long> userAuthDbIds = userAuthList.stream().map(val -> NumberUtils.toLong(val.getAuthCustomSuffix().replace(DocAuthConst.DB, ""))).collect(Collectors.toList());
|
||||
wrapper.in("id", userAuthDbIds);
|
||||
}
|
||||
wrapper.select("id", "name", "group_name");
|
||||
List<DbDatasource> datasourceList = dbDatasourceService.list(wrapper);
|
||||
List<DatabaseFactoryBean> dataSourceList = datasourceList.stream().map(val -> {
|
||||
DatabaseFactoryBean bean = new DatabaseFactoryBean();
|
||||
bean.setCnName(val.getName());
|
||||
bean.setId(val.getId());
|
||||
return bean;
|
||||
}).collect(Collectors.toList());
|
||||
return DocDbResponseJson.ok(dataSourceList);
|
||||
return DocDbResponseJson.ok(datasourceList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编辑器所需的所有信息,用于自动补全
|
||||
* 此接口会返回所有库表结构,介意的话请自己手动屏蔽调此接口
|
||||
*
|
||||
* @param sourceId
|
||||
* @return
|
||||
* 获取数据源基本信息
|
||||
* @param sourceId 数据源ID
|
||||
* @return 基本信息
|
||||
*/
|
||||
@PostMapping(value = "/getEditorData")
|
||||
public ResponseJson getEditorData(Long sourceId) {
|
||||
// 没权限,返回空
|
||||
if (!DocUserUtil.haveAuth(DocAuthConst.DB_DATASOURCE_MANAGE)
|
||||
&& !DocUserUtil.haveCustomAuth(DbAuthType.VIEW.getName(), DocAuthConst.DB + sourceId)) {
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
String cacheKey = CachePrefix.DB_EDITOR_DATA_CACHE + sourceId;
|
||||
Object resultObj = CacheUtil.get(cacheKey);
|
||||
if (resultObj != null) {
|
||||
return DocDbResponseJson.ok(resultObj);
|
||||
}
|
||||
BaseMapper baseMapper = this.getBaseMapper(sourceId);
|
||||
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getFactoryById(sourceId);
|
||||
List<DatabaseInfoDto> dbNameDtoList = baseMapper.getDatabaseList();
|
||||
Map<String, List<TableInfoDto>> dbTableMap = new HashMap<>();
|
||||
Map<String, List<TableColumnDescDto>> tableColumnsMap = new HashMap<>();
|
||||
|
||||
Map<String, List<TableInfoDto>> tableMapList = new HashMap<>();
|
||||
// MYSQL可以一次性查询所有库表
|
||||
if (databaseFactoryBean.getDatabaseProduct() == DatabaseProduct.MYSQL) {
|
||||
List<TableInfoDto> dbTableList = baseMapper.getTableList(null);
|
||||
tableMapList = dbTableList.stream().collect(Collectors.groupingBy(TableInfoDto::getDbName));
|
||||
}
|
||||
for (DatabaseInfoDto infoDto : dbNameDtoList) {
|
||||
List<TableInfoDto> tableInfoDtoList = tableMapList.get(infoDto.getDbName());
|
||||
// SQLSERVER必须要库才能查
|
||||
if (databaseFactoryBean.getDatabaseProduct() == DatabaseProduct.SQLSERVER) {
|
||||
tableInfoDtoList = baseMapper.getTableList(infoDto.getDbName());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(tableInfoDtoList)) {
|
||||
continue;
|
||||
}
|
||||
dbTableMap.put(infoDto.getDbName(), tableInfoDtoList);
|
||||
// 小于10个库,查所有库,否则只查询当前链接的库,防止库表太多,数据量太大
|
||||
// 如果觉得没必要就自己改吧!
|
||||
Map<String, List<TableColumnDescDto>> columnDescDtoMap = new HashMap<>();
|
||||
if (dbNameDtoList.size() <= 10 || Objects.equals(databaseFactoryBean.getDbName(), infoDto.getDbName())) {
|
||||
List<TableColumnDescDto> columnDescDto = baseMapper.getTableColumnList(infoDto.getDbName(), null);
|
||||
columnDescDtoMap = columnDescDto.stream().collect(Collectors.groupingBy(TableColumnDescDto::getTableName));
|
||||
}
|
||||
for (TableInfoDto tableInfoDto : tableInfoDtoList) {
|
||||
List<TableColumnDescDto> descDtoList = columnDescDtoMap.get(tableInfoDto.getTableName());
|
||||
if (CollectionUtils.isNotEmpty(descDtoList)) {
|
||||
tableColumnsMap.put(tableInfoDto.getTableName(), descDtoList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@PostMapping(value = "/getSourceBaseInfo")
|
||||
public ResponseJson getSourceBaseInfo(Long sourceId) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
Map<String, Object> dbResultMap = new HashMap<>();
|
||||
dbResultMap.put("db", dbNameDtoList);
|
||||
dbResultMap.put("table", dbTableMap);
|
||||
dbResultMap.put("column", tableColumnsMap);
|
||||
// 缓存10分钟,如果10分钟内库里面增删改了表或字段,则提示不出来
|
||||
CacheUtil.put(cacheKey, dbResultMap, 6000);
|
||||
dbResultMap.put("product", dbBaseService.getDatabaseProduct().name().toLowerCase());
|
||||
return DocDbResponseJson.ok(dbResultMap);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableDdl")
|
||||
public ResponseJson getTableDdl(Long sourceId, String dbName, String tableName) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
TableDdlVo tableDdlVo = dbBaseService.getTableDdl(sourceId, dbName, tableName);
|
||||
return DocDbResponseJson.ok(tableDdlVo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getDatabaseList")
|
||||
public ResponseJson getDatabaseList(Long sourceId) {
|
||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||
List<DatabaseInfoDto> dbNameDtoList = baseMapper.getDatabaseList();
|
||||
return DocDbResponseJson.ok(dbNameDtoList);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
List<DatabaseInfoDto> databaseList = dbBaseService.getDatabaseList(sourceId);
|
||||
return DocDbResponseJson.ok(databaseList);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableStatus")
|
||||
public ResponseJson getTableStatus(Long sourceId, String dbName, String tableName) {
|
||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||
TableStatusVo tableStatusVo = baseMapper.getTableStatus(dbName, tableName);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
TableStatusVo tableStatusVo = dbBaseService.getTableStatus(sourceId, dbName, tableName);
|
||||
return DocDbResponseJson.ok(tableStatusVo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableList")
|
||||
public ResponseJson getTableList(Long sourceId, String dbName) {
|
||||
BaseMapper baseMapper = this.getBaseMapper(sourceId);
|
||||
List<TableInfoDto> dbTableList = baseMapper.getTableList(dbName);
|
||||
return DocDbResponseJson.ok(dbTableList);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
List<TableInfoDto> tableList = dbBaseService.getTableList(sourceId, dbName);
|
||||
return DocDbResponseJson.ok(tableList);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableColumnList")
|
||||
public ResponseJson getTableColumnList(Long sourceId, String dbName, String tableName) {
|
||||
this.judgeAuth(sourceId, DbAuthType.VIEW.getName(), "没有查看该库表信息的权限");
|
||||
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getFactoryById(sourceId);
|
||||
if (databaseFactoryBean == null) {
|
||||
return DocDbResponseJson.warn("未找到对应的数据库连接");
|
||||
}
|
||||
TableColumnVo tableColumnVo = this.getTableColumnVo(databaseFactoryBean, dbName, tableName);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
TableColumnVo tableColumnVo = dbBaseService.getTableColumnList(sourceId, dbName, tableName);
|
||||
return DocDbResponseJson.ok(tableColumnVo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableColumnDescList")
|
||||
public ResponseJson getTableColumnDescList(Long sourceId, String tableName) {
|
||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||
List<TableColumnDescDto> columnDescDto = baseMapper.getTableColumnDescList(tableName);
|
||||
return DocDbResponseJson.ok(columnDescDto);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableAndColumnBySearch")
|
||||
public ResponseJson getTableAndColumnBySearch(Long sourceId, String dbName, String searchText) {
|
||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||
if (StringUtils.isBlank(searchText)) {
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
searchText = "%" + searchText + "%";
|
||||
List<QueryTableColumnDescDto> columnDescDto = baseMapper.getTableAndColumnBySearch(dbName, searchText);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
List<QueryTableColumnDescDto> columnDescDto = dbBaseService.getTableAndColumnBySearch(sourceId, dbName, searchText);
|
||||
return DocDbResponseJson.ok(columnDescDto);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableDescList")
|
||||
public ResponseJson getTableDescList(Long sourceId, String dbName, String tableName) {
|
||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||
List<TableDescDto> columnDescDto = baseMapper.getTableDescList(dbName, tableName);
|
||||
return DocDbResponseJson.ok(columnDescDto);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
List<TableDescDto> tableDescList = dbBaseService.getTableDescList(sourceId, dbName, tableName);
|
||||
return DocDbResponseJson.ok(tableDescList);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/updateTableDesc")
|
||||
public ResponseJson updateTableDesc(Long sourceId, String dbName, String tableName, String newDesc) {
|
||||
this.judgeAuth(sourceId, DbAuthType.DESC_EDIT.getName(), "没有修改该表注释的权限");
|
||||
BaseMapper baseMapper = this.getBaseMapper(sourceId);
|
||||
baseMapper.updateTableDesc(dbName, tableName, newDesc);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
dbBaseService.updateTableDesc(sourceId, dbName, tableName, newDesc);
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/updateTableColumnDesc")
|
||||
public ResponseJson updateTableColumnDesc(Long sourceId, String dbName, String tableName, String columnName, String newDesc) {
|
||||
this.judgeAuth(sourceId, DbAuthType.DESC_EDIT.getName(), "没有修改该表字段注释的权限");
|
||||
BaseMapper baseMapper = this.getBaseMapper(sourceId);
|
||||
ColumnInfoDto columnInfo = null;
|
||||
// mysql要同时修改类型默认值等,所以先查出来
|
||||
MysqlMapper mysqlMapper = databaseRegistrationBean.getBaseMapper(sourceId, MysqlMapper.class);
|
||||
if (mysqlMapper != null) {
|
||||
columnInfo = mysqlMapper.getColumnInfo(dbName, tableName, columnName);
|
||||
String isNullable = Optional.ofNullable(columnInfo.getIsNullable()).orElse("");
|
||||
columnInfo.setIsNullable("yes".equalsIgnoreCase(isNullable) ? "null" : "not null");
|
||||
String columnDefault = columnInfo.getColumnDefault();
|
||||
if (StringUtils.isNotBlank(columnDefault)) {
|
||||
columnInfo.setColumnDefault("DEFAULT " + columnDefault);
|
||||
} else {
|
||||
columnInfo.setColumnDefault("");
|
||||
}
|
||||
String extra = columnInfo.getExtra();
|
||||
columnInfo.setExtra(StringUtils.isBlank(extra) ? "" : extra);
|
||||
}
|
||||
baseMapper.updateTableColumnDesc(dbName, tableName, columnName, newDesc, columnInfo);
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
dbBaseService.updateTableColumnDesc(sourceId, dbName, tableName, columnName, newDesc);
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/exportDatabase")
|
||||
public ResponseJson exportDatabase(HttpServletResponse response, Long sourceId, String dbName, String tableNames, Integer exportType) {
|
||||
this.judgeAuth(sourceId, DbAuthType.VIEW.getName(), "没有查看该库表信息的权限");
|
||||
@PostMapping(value = "/exportDatabase")
|
||||
public ResponseJson exportDatabase(HttpServletResponse response, Long sourceId, String dbName, String tableNames, Integer exportType, Integer exportFormat) {
|
||||
if (StringUtils.isBlank(tableNames)) {
|
||||
return DocDbResponseJson.warn("请选择需要导出的表");
|
||||
}
|
||||
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getFactoryById(sourceId);
|
||||
if (databaseFactoryBean == null) {
|
||||
return DocDbResponseJson.warn("未找到对应的数据库连接");
|
||||
}
|
||||
List<TableInfoVo> tableList = new LinkedList<>();
|
||||
Map<String, List<TableColumnDescDto>> columnList = new HashMap<>();
|
||||
String[] tableNameArr = tableNames.split(",");
|
||||
for (String tableName : tableNameArr) {
|
||||
if (StringUtils.isBlank(tableName)) {
|
||||
continue;
|
||||
}
|
||||
TableColumnVo tableColumnVo = this.getTableColumnVo(databaseFactoryBean, dbName, tableName);
|
||||
columnList.put(tableName, tableColumnVo.getColumnList());
|
||||
tableList.add(tableColumnVo.getTableInfo());
|
||||
}
|
||||
DatabaseExportVo exportVo = new DatabaseExportVo();
|
||||
exportVo.setColumnList(columnList);
|
||||
exportVo.setTableList(tableList);
|
||||
String content = JSON.toJSONString(exportVo);
|
||||
content = "var docDbDatabase = " + content;
|
||||
List<String> tableNameList = Stream.of(tableNames.split(",")).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||
if (Objects.equals(exportType, 1)) {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=database.js");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
// 将文件输入流写入response的输出流中
|
||||
try {
|
||||
IoUtil.write(response.getOutputStream(), "utf-8", true, content);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String fileName = URLEncoder.encode("数据库表导出", "UTF-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet(0, "表信息").head(TableInfoVo.class).build();
|
||||
excelWriter.write(tableList, writeSheet);
|
||||
int index = 1;
|
||||
for (Map.Entry<String, List<TableColumnDescDto>> entry : columnList.entrySet()) {
|
||||
writeSheet = EasyExcel.writerSheet(index++, entry.getKey()).head(TableColumnDescDto.class).build();
|
||||
excelWriter.write(entry.getValue(), writeSheet);
|
||||
}
|
||||
excelWriter.finish();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this.exportForTableDoc(response, sourceId, dbName, tableNameList, exportFormat);
|
||||
} else if (Objects.equals(exportType, 2)) {
|
||||
return this.exportForTableDdl(response, sourceId, dbName, tableNameList, exportFormat);
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
private TableColumnVo getTableColumnVo(DatabaseFactoryBean databaseFactoryBean, String dbName, String tableName) {
|
||||
SqlSessionTemplate sessionTemplate = databaseFactoryBean.getSqlSessionTemplate();
|
||||
BaseMapper baseMapper = sessionTemplate.getMapper(BaseMapper.class);
|
||||
List<TableColumnDescDto> columnDescDto = baseMapper.getTableColumnList(dbName, tableName);
|
||||
// SQLSERVER要单独查字段注释
|
||||
if (databaseFactoryBean.getDatabaseProduct() == DatabaseProduct.SQLSERVER) {
|
||||
List<TableColumnDescDto> columnDescList = baseMapper.getTableColumnDescList(tableName);
|
||||
Map<String, TableColumnDescDto> columnMap = columnDescDto.stream().collect(Collectors.toMap(TableColumnDescDto::getName, val -> val));
|
||||
// 字段注释
|
||||
for (TableColumnDescDto descDto : columnDescList) {
|
||||
TableColumnDescDto tempDesc = columnMap.get(descDto.getName());
|
||||
if (tempDesc != null) {
|
||||
tempDesc.setDescription(descDto.getDescription());
|
||||
}
|
||||
private DocDbResponseJson exportForTableDdl(HttpServletResponse response, Long sourceId, String dbName, List<String> tableNameList, Integer exportFormat) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
Map<String, String> ddlSqlMap = new HashMap<>();
|
||||
for (String tableName : tableNameList) {
|
||||
TableDdlVo tableDdlVo = dbBaseService.getTableDdl(sourceId, dbName, tableName);
|
||||
ddlSqlMap.put(tableName, tableDdlVo.getTableDDLByType());
|
||||
}
|
||||
try {
|
||||
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getOrCreateFactoryById(sourceId);
|
||||
DatabaseProductEnum databaseProduct = databaseFactoryBean.getDatabaseProduct();
|
||||
PoiUtil.exportByDdl(ddlSqlMap, dbName, databaseProduct.name(), response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocDbResponseJson.error("导出失败:" + e.getMessage());
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
private DocDbResponseJson exportForTableDoc(HttpServletResponse response, Long sourceId, String dbName, List<String> tableNameList, Integer exportFormat) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
// 数据组装
|
||||
List<TableInfoVo> tableList = new LinkedList<>();
|
||||
Map<String, List<TableColumnDescDto>> columnList = new HashMap<>();
|
||||
for (String tableName : tableNameList) {
|
||||
TableColumnVo tableColumnVo = dbBaseService.getTableColumnList(sourceId, dbName, tableName);
|
||||
columnList.put(tableName, tableColumnVo.getColumnList());
|
||||
tableList.add(tableColumnVo.getTableInfo());
|
||||
}
|
||||
try {
|
||||
DatabaseExportVo exportVo = new DatabaseExportVo(columnList, tableList);
|
||||
if (Objects.equals(exportFormat, 1)) {
|
||||
PoiUtil.exportByText(exportVo, response);
|
||||
} else if (Objects.equals(exportFormat, 2)) {
|
||||
PoiUtil.exportByXlsx(exportVo, response);
|
||||
} else if (Objects.equals(exportFormat, 3)) {
|
||||
PoiUtil.exportByDocx(dbName, exportVo, response);
|
||||
}
|
||||
return DocDbResponseJson.error("导出失败:请先选择导出类型");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocDbResponseJson.error("导出失败:" + e.getMessage());
|
||||
}
|
||||
TableColumnVo tableColumnVo = new TableColumnVo();
|
||||
tableColumnVo.setColumnList(columnDescDto);
|
||||
// 表注释
|
||||
TableInfoVo tableInfoVo = new TableInfoVo();
|
||||
List<TableDescDto> tableDescList = baseMapper.getTableDescList(dbName, tableName);
|
||||
String description = null;
|
||||
if (tableDescList.size() > 0) {
|
||||
TableDescDto descDto = tableDescList.get(0);
|
||||
description = descDto.getDescription();
|
||||
}
|
||||
description = Optional.ofNullable(description).orElse("");
|
||||
tableInfoVo.setDescription(description);
|
||||
tableInfoVo.setTableName(tableName);
|
||||
tableColumnVo.setTableInfo(tableInfoVo);
|
||||
return tableColumnVo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,35 +232,5 @@ public class DatabaseDocController {
|
||||
throw new ConfirmException(noAuthInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取BaseMapper
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
*/
|
||||
private BaseMapper getBaseMapper(Long sourceId) {
|
||||
BaseMapper baseMapper = databaseRegistrationBean.getBaseMapperById(sourceId);
|
||||
if (baseMapper == null) {
|
||||
throw new ConfirmException("未找到对应的数据库连接");
|
||||
}
|
||||
return baseMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断查看权和获取BaseMapper
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
*/
|
||||
private BaseMapper getViewAuthBaseMapper(Long sourceId) {
|
||||
this.judgeAuth(sourceId, DbAuthType.VIEW.getName(), "没有查看该库表信息的权限");
|
||||
return this.getBaseMapper(sourceId);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//File zipFile = ZipUtil.zip("d:/aaa");
|
||||
File zipFile = new File("d:/111.zip");
|
||||
ZipUtil.zip(zipFile, true, new File("d:/111.txt"),
|
||||
new File("d:/222.txt"), new File("d:/aaa"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.stream.Stream;
|
||||
* @since 2019年8月18日
|
||||
*/
|
||||
@RestController
|
||||
@AuthMan("DB_DATASOURCE_MANAGE")
|
||||
@AuthMan(DocAuthConst.DB_DATASOURCE_MANAGE)
|
||||
@RequestMapping("/zyplayer-doc-db/auth")
|
||||
public class DbDataSourceAuthController {
|
||||
private static Logger logger = LoggerFactory.getLogger(DbDataSourceAuthController.class);
|
||||
@@ -91,6 +91,11 @@ public class DbDataSourceAuthController {
|
||||
UserAuth userAuth = this.createUserAuth(sourceId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getProcEditAuth(), 1)) {
|
||||
Long authId = authInfoMap.get(DbAuthType.PROC_EDIT.getName());
|
||||
UserAuth userAuth = this.createUserAuth(sourceId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (userAuthList.size() <= 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -121,7 +126,6 @@ public class DbDataSourceAuthController {
|
||||
userAuthGroup.forEach((key, value) -> {
|
||||
Set<String> authNameSet = value.stream().map(auth -> authInfoMap.get(auth.getAuthId())).collect(Collectors.toSet());
|
||||
UserDbAuthVo authVo = new UserDbAuthVo();
|
||||
authVo.setExecuteAuth(0);
|
||||
if (this.haveAuth(authNameSet, DbAuthType.UPDATE) == 1) {
|
||||
authVo.setExecuteAuth(3);
|
||||
} else if (this.haveAuth(authNameSet, DbAuthType.SELECT) == 1) {
|
||||
@@ -130,6 +134,7 @@ public class DbDataSourceAuthController {
|
||||
authVo.setExecuteAuth(1);
|
||||
}
|
||||
authVo.setDescEditAuth(this.haveAuth(authNameSet, DbAuthType.DESC_EDIT));
|
||||
authVo.setProcEditAuth(this.haveAuth(authNameSet, DbAuthType.PROC_EDIT));
|
||||
authVo.setUserId(key);
|
||||
authVo.setUserName(userInfoMap.get(key));
|
||||
authVoList.add(authVo);
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
package com.zyplayer.doc.db.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.util.TypeUtils;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.core.util.StringUtil;
|
||||
import com.zyplayer.doc.core.util.ZyplayerDocVersion;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||
import com.zyplayer.doc.db.controller.param.DataViewParam;
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo;
|
||||
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||
import com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteParam;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteResult;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteType;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.SqlExecutor;
|
||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||
import com.zyplayer.doc.db.framework.utils.JSONUtil;
|
||||
import com.zyplayer.doc.db.service.DatabaseServiceFactory;
|
||||
import com.zyplayer.doc.db.service.DbBaseService;
|
||||
import com.zyplayer.doc.db.service.download.BaseDownloadService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 表数据查看控制器
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年5月16日
|
||||
*/
|
||||
@AuthMan
|
||||
@RestController
|
||||
@RequestMapping("/zyplayer-doc-db/data-view")
|
||||
public class DbDataViewController {
|
||||
private static Logger logger = LoggerFactory.getLogger(DbDataViewController.class);
|
||||
|
||||
@Resource
|
||||
SqlExecutor sqlExecutor;
|
||||
@Resource
|
||||
DatabaseServiceFactory databaseServiceFactory;
|
||||
@Resource
|
||||
BaseDownloadService baseDownloadService;
|
||||
// 最大允许导出的行数,设置的过大有可能会导致内存溢出,默认10W条
|
||||
@Value("${zyplayer.doc.db.download-max-row:100000}")
|
||||
Integer downloadMaxRow;
|
||||
|
||||
@PostMapping(value = "/query")
|
||||
public ResponseJson query(DataViewParam param) {
|
||||
// 数据查询
|
||||
ExecuteType executeType = this.getExecuteType(param.getSourceId());
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(param.getSourceId());
|
||||
String queryPageSql = dbBaseService.getQueryPageSql(param);
|
||||
ExecuteResult executeResult = this.query(param.getSourceId(), param.getExecuteId(), executeType, queryPageSql);
|
||||
// 数据组装
|
||||
List<String> resultList = new LinkedList<>();
|
||||
resultList.add(JSON.toJSONString(executeResult, JSONUtil.serializeConfig, SerializerFeature.WriteMapNullValue));
|
||||
DocDbResponseJson responseJson = DocDbResponseJson.ok(resultList);
|
||||
// 计算总条数,第一页才查询总条数
|
||||
if (CollectionUtils.isNotEmpty(executeResult.getResult()) && Objects.equals(param.getPageNum(), 1)) {
|
||||
responseJson.setTotal((long) executeResult.getResult().size());
|
||||
if (executeResult.getResult().size() >= param.getPageSize()) {
|
||||
responseJson.setTotal(this.getDataCount(param, executeType));
|
||||
}
|
||||
}
|
||||
return responseJson;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单表数据下载
|
||||
*
|
||||
* @param response
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/download")
|
||||
public ResponseJson download(HttpServletResponse response, DataViewParam param) {
|
||||
param.setExecuteId(RandomUtil.simpleUUID());
|
||||
ExecuteType executeType = this.getExecuteType(param.getSourceId());
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(param.getSourceId());
|
||||
if (this.getDataCount(param, executeType) > downloadMaxRow) {
|
||||
return DocDbResponseJson.error(String.format("导出失败,表:%s 数据行数超过最大导出配置 %s,请联系管理员修改", param.getTableName(), downloadMaxRow));
|
||||
}
|
||||
// 获取列信息等
|
||||
TableColumnVo tableColumnVo = dbBaseService.getTableColumnList(param.getSourceId(), param.getDbName(), param.getTableName());
|
||||
Set<String> conditionSet = StringUtils.isBlank(param.getConditionColumn()) ? Collections.emptySet() : Stream.of(param.getConditionColumn().split(",")).collect(Collectors.toSet());
|
||||
Set<String> retainColumnSet = StringUtils.isBlank(param.getRetainColumn()) ? Collections.emptySet() : Stream.of(param.getRetainColumn().split(",")).collect(Collectors.toSet());
|
||||
List<TableColumnDescDto> columnList = tableColumnVo.getColumnList().stream().filter(item -> retainColumnSet.isEmpty() || retainColumnSet.contains(item.getName())).collect(Collectors.toList());
|
||||
// 数据查询
|
||||
String queryAllSql = dbBaseService.getQueryAllSql(param);
|
||||
ExecuteParam executeParam = new ExecuteParam();
|
||||
executeParam.setDatasourceId(param.getSourceId());
|
||||
executeParam.setExecuteId(param.getExecuteId());
|
||||
executeParam.setExecuteType(executeType);
|
||||
executeParam.setSql(queryAllSql);
|
||||
try {
|
||||
dbBaseService.downloadSingleTableData(response, param, executeParam, columnList, conditionSet);
|
||||
} catch (Exception e) {
|
||||
return DocDbResponseJson.error("导出失败:" + e.getMessage());
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 多表下载
|
||||
*
|
||||
* @param response
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/downloadMultiple")
|
||||
public ResponseJson downloadMultiple(HttpServletResponse response, DataViewParam param) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(param.getSourceId());
|
||||
if (StringUtils.isBlank(param.getTableNames())) {
|
||||
return DocDbResponseJson.warn("请选择导出的表");
|
||||
}
|
||||
param.setExecuteId(IdUtil.simpleUUID());
|
||||
String tempDir = System.getProperty("java.io.tmpdir");
|
||||
boolean multipleFile = Objects.equals(param.getDownloadFileType(), 2);
|
||||
boolean isJson = Objects.equals(param.getDownloadType(), "json");
|
||||
StringBuilder resultSb = new StringBuilder("/*\n" +
|
||||
" zyplayer-doc 表数据导出\n" +
|
||||
"\n" +
|
||||
" 数据库 : " + param.getDbName() + "\n" +
|
||||
" 数据库类型 : " + dbBaseService.getDatabaseProduct().name() + "\n" +
|
||||
" 导出时间 : " + DateTime.now().toString() + "\n" +
|
||||
" 软件版本 : " + ZyplayerDocVersion.version + "\n" +
|
||||
"*/\n\n");
|
||||
String[] tableNameArr = param.getTableNames().split(",");
|
||||
String tempDirName = tempDir + "zyplayer-doc-" + IdUtil.fastSimpleUUID();
|
||||
try {
|
||||
// 先校验总条数是否超过限制
|
||||
for (String tableName : tableNameArr) {
|
||||
param.setTableName(tableName);
|
||||
ExecuteType executeType = this.getExecuteType(param.getSourceId());
|
||||
if (this.getDataCount(param, executeType) > downloadMaxRow) {
|
||||
return DocDbResponseJson.error(String.format("导出失败,表:%s 数据行数超过最大导出配置 %s,请联系管理员修改", tableName, downloadMaxRow));
|
||||
}
|
||||
}
|
||||
// 创建临时文件夹
|
||||
FileUtil.mkdir(tempDirName);
|
||||
// 再分表查数据
|
||||
String suffix = isJson ? ".json" : ".sql";
|
||||
for (String tableName : tableNameArr) {
|
||||
param.setTableName(tableName);
|
||||
ExecuteType executeType = this.getExecuteType(param.getSourceId());
|
||||
// 获取列信息等
|
||||
TableColumnVo tableColumnVo = dbBaseService.getTableColumnList(param.getSourceId(), param.getDbName(), tableName);
|
||||
List<TableColumnDescDto> columnList = tableColumnVo.getColumnList();
|
||||
// 找主键作为更新条件
|
||||
Set<String> conditionSet = columnList.stream().filter(item -> Objects.equals(item.getPrimaryKey(), "1")).map(TableColumnDescDto::getName).collect(Collectors.toSet());
|
||||
// 数据查询
|
||||
String queryAllSql = dbBaseService.getQueryAllSql(param);
|
||||
ExecuteParam executeParam = new ExecuteParam();
|
||||
executeParam.setDatasourceId(param.getSourceId());
|
||||
executeParam.setExecuteId(param.getExecuteId());
|
||||
executeParam.setExecuteType(executeType);
|
||||
executeParam.setSql(queryAllSql);
|
||||
String downloadTableData = dbBaseService.getDownloadTableData(param, executeParam, columnList, conditionSet);
|
||||
// 写入临时文件
|
||||
if (multipleFile) {
|
||||
File tempFile = FileUtil.file(tempDirName + "/" + tableName + suffix);
|
||||
String tableDataSb = isJson ? downloadTableData : String.format("-- 导出数据表:`%s`.`%s` --\n", param.getDbName(), tableName) + downloadTableData;
|
||||
FileUtil.writeUtf8String(tableDataSb, tempFile);
|
||||
} else {
|
||||
resultSb.append(String.format("-- 导出数据表:`%s`.`%s` --\n", param.getDbName(), tableName));
|
||||
resultSb.append(downloadTableData).append("\n");
|
||||
}
|
||||
}
|
||||
if (multipleFile) {
|
||||
baseDownloadService.sendResponse(response, param.getDbName(), tempDirName);
|
||||
} else {
|
||||
baseDownloadService.sendResponse(response, param.getDbName(), suffix, resultSb.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocDbResponseJson.error("导出失败:" + e.getMessage());
|
||||
} finally {
|
||||
FileUtil.del(tempDirName);
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
private Long getDataCount(DataViewParam param, ExecuteType executeType) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(param.getSourceId());
|
||||
String queryCountSql = dbBaseService.getQueryCountSql(param);
|
||||
ExecuteResult countResult = this.query(param.getSourceId(), param.getExecuteId(), executeType, queryCountSql);
|
||||
if (CollectionUtils.isNotEmpty(countResult.getResult()) && MapUtils.isNotEmpty(countResult.getResult().get(0))) {
|
||||
Map<String, Object> countMap = countResult.getResult().get(0);
|
||||
Optional<Object> countAny = countMap.values().stream().findAny();
|
||||
return TypeUtils.castToLong(countAny.orElse(0));
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行数据查询
|
||||
*
|
||||
* @param sourceId
|
||||
* @param executeId
|
||||
* @param executeType
|
||||
* @param executeSql
|
||||
* @return
|
||||
*/
|
||||
private ExecuteResult query(Long sourceId, String executeId, ExecuteType executeType, String executeSql) {
|
||||
try {
|
||||
ExecuteParam executeParam = new ExecuteParam();
|
||||
executeParam.setDatasourceId(sourceId);
|
||||
executeParam.setExecuteId(executeId);
|
||||
executeParam.setExecuteType(executeType);
|
||||
executeParam.setSql(executeSql);
|
||||
executeParam.setMaxRows(1000);
|
||||
return sqlExecutor.execute(executeParam);
|
||||
} catch (Exception e) {
|
||||
logger.error("执行出错", e);
|
||||
return ExecuteResult.error(StringUtil.getException(e), executeSql);
|
||||
}
|
||||
}
|
||||
|
||||
private ExecuteType getExecuteType(Long sourceId) {
|
||||
boolean manageAuth = DocUserUtil.haveAuth(DocAuthConst.DB_DATASOURCE_MANAGE);
|
||||
boolean select = DocUserUtil.haveCustomAuth(DbAuthType.SELECT.getName(), DocAuthConst.DB + sourceId);
|
||||
boolean update = DocUserUtil.haveCustomAuth(DbAuthType.UPDATE.getName(), DocAuthConst.DB + sourceId);
|
||||
if (!manageAuth && !select && !update) {
|
||||
throw new ConfirmException("没有该数据源的执行权限");
|
||||
}
|
||||
return (manageAuth || update) ? ExecuteType.ALL : ExecuteType.SELECT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
package com.zyplayer.doc.db.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserInfo;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
|
||||
import com.zyplayer.doc.db.framework.configuration.DatasourceUtil;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据源控制器
|
||||
@@ -26,7 +34,7 @@ import java.util.*;
|
||||
* @since 2019年6月29日
|
||||
*/
|
||||
@RestController
|
||||
@AuthMan("DB_DATASOURCE_MANAGE")
|
||||
@AuthMan(DocAuthConst.DB_DATASOURCE_MANAGE)
|
||||
@RequestMapping("/zyplayer-doc-db/datasource")
|
||||
public class DbDatasourceController {
|
||||
|
||||
@@ -36,14 +44,54 @@ public class DbDatasourceController {
|
||||
DbDatasourceService dbDatasourceService;
|
||||
|
||||
@PostMapping(value = "/list")
|
||||
public ResponseJson list() {
|
||||
public ResponseJson list(Integer pageNum, Integer pageSize, String name, String groupName) {
|
||||
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("yn", 1);
|
||||
List<DbDatasource> datasourceList = dbDatasourceService.list(wrapper);
|
||||
for (DbDatasource dbDatasource : datasourceList) {
|
||||
wrapper.eq(StringUtils.isNotBlank(groupName), "group_name", groupName);
|
||||
wrapper.like(StringUtils.isNotBlank(name), "name", "%" + name + "%");
|
||||
IPage<DbDatasource> page = new Page<>(pageNum, pageSize, pageNum == 1);
|
||||
dbDatasourceService.page(page, wrapper);
|
||||
for (DbDatasource dbDatasource : page.getRecords()) {
|
||||
dbDatasource.setSourcePassword("***");
|
||||
}
|
||||
return DocDbResponseJson.ok(datasourceList);
|
||||
return DocDbResponseJson.ok(page);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/groups")
|
||||
public ResponseJson groups() {
|
||||
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("yn", 1);
|
||||
wrapper.isNotNull("group_name");
|
||||
wrapper.select("group_name");
|
||||
wrapper.groupBy("group_name");
|
||||
List<DbDatasource> datasourceList = dbDatasourceService.list(wrapper);
|
||||
if (CollectionUtils.isEmpty(datasourceList)) {
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
Set<String> groupNameSet = datasourceList.stream().map(DbDatasource::getGroupName).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
||||
return DocDbResponseJson.ok(groupNameSet);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/test")
|
||||
public ResponseJson test(DbDatasource dbDatasource) {
|
||||
// 验证新的数据源
|
||||
try {
|
||||
// 获取原始密码
|
||||
if (Objects.equals("***", dbDatasource.getSourcePassword()) && dbDatasource.getId() != null) {
|
||||
DbDatasource dbDatasourceSel = dbDatasourceService.getById(dbDatasource.getId());
|
||||
if (dbDatasourceSel != null) {
|
||||
dbDatasource.setSourcePassword(dbDatasourceSel.getSourcePassword());
|
||||
}
|
||||
}
|
||||
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource, true);
|
||||
databaseFactoryBean.getDataSource().close();
|
||||
} catch (ConfirmException e) {
|
||||
return DocDbResponseJson.warn(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocDbResponseJson.warn(ExceptionUtils.getFullStackTrace(e));
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
@@ -69,6 +117,8 @@ public class DbDatasourceController {
|
||||
Long sourceId = Optional.ofNullable(dbDatasource.getId()).orElse(0L);
|
||||
if (sourceId > 0) {
|
||||
dbDatasourceService.updateById(dbDatasource);
|
||||
// 关闭旧数据源
|
||||
databaseRegistrationBean.closeDatasource(dbDatasource.getId());
|
||||
} else {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
dbDatasource.setCreateTime(new Date());
|
||||
@@ -77,32 +127,6 @@ public class DbDatasourceController {
|
||||
dbDatasource.setYn(1);
|
||||
dbDatasourceService.save(dbDatasource);
|
||||
}
|
||||
DbDatasource dbDatasourceSel = dbDatasourceService.getById(dbDatasource.getId());
|
||||
List<DatabaseFactoryBean> newFactoryBeanList = new LinkedList<>();
|
||||
List<DatabaseFactoryBean> databaseFactoryBeanList = databaseRegistrationBean.getDatabaseFactoryBeanList();
|
||||
for (DatabaseFactoryBean factoryBean : databaseFactoryBeanList) {
|
||||
if (Objects.equals(factoryBean.getId(), sourceId)) {
|
||||
try {
|
||||
// 关闭旧的数据源
|
||||
factoryBean.getDataSource().close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
newFactoryBeanList.add(factoryBean);
|
||||
}
|
||||
}
|
||||
if (Optional.ofNullable(dbDatasourceSel.getYn()).orElse(0) == 1) {
|
||||
// 创建新的数据源
|
||||
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasourceSel);
|
||||
if (databaseFactoryBean != null) {
|
||||
newFactoryBeanList.add(databaseFactoryBean);
|
||||
}
|
||||
databaseRegistrationBean.setDatabaseFactoryBeanList(newFactoryBeanList);
|
||||
if (databaseFactoryBean == null) {
|
||||
return DocDbResponseJson.warn("创建数据源失败,请检查配置是否正确");
|
||||
}
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
package com.zyplayer.doc.db.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbProcLog;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||
import com.zyplayer.doc.data.service.manage.DbProcLogService;
|
||||
import com.zyplayer.doc.db.controller.param.ProcedureListParam;
|
||||
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||
import com.zyplayer.doc.db.framework.db.dto.ProcedureDto;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteResult;
|
||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||
import com.zyplayer.doc.db.service.DatabaseServiceFactory;
|
||||
import com.zyplayer.doc.db.service.DbBaseService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 存储过程管理控制器
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年4月24日
|
||||
*/
|
||||
@AuthMan
|
||||
@RestController
|
||||
@RequestMapping("/zyplayer-doc-db/procedure")
|
||||
public class DbProcedureController {
|
||||
private static Logger logger = LoggerFactory.getLogger(DbProcedureController.class);
|
||||
|
||||
@Resource
|
||||
DatabaseServiceFactory databaseServiceFactory;
|
||||
@Resource
|
||||
DbProcLogService dbProcLogService;
|
||||
|
||||
/**
|
||||
* 存储过程列表
|
||||
*
|
||||
* @param procedureParam 参数
|
||||
* @return 列表
|
||||
*/
|
||||
@PostMapping(value = "/list")
|
||||
public ResponseJson list(ProcedureListParam procedureParam) {
|
||||
try {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(procedureParam.getSourceId());
|
||||
procedureParam.setOffset((procedureParam.getPageNum() - 1) * procedureParam.getPageSize());
|
||||
List<ProcedureDto> procedureDtoList = dbBaseService.getProcedureList(procedureParam);
|
||||
DocDbResponseJson responseJson = DocDbResponseJson.ok(procedureDtoList);
|
||||
if (procedureParam.getPageNum() == 1) {
|
||||
responseJson.setTotal(dbBaseService.getProcedureCount(procedureParam));
|
||||
}
|
||||
return responseJson;
|
||||
} catch (Exception e) {
|
||||
// 一般是数据库的帐号没权限查存储过程
|
||||
return DocDbResponseJson.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取函数详情
|
||||
*
|
||||
* @param sourceId 数据源ID
|
||||
* @param dbName 数据库名
|
||||
* @param typeName 类型名
|
||||
* @param procName 函数名
|
||||
* @return 详情
|
||||
*/
|
||||
@PostMapping(value = "/detail")
|
||||
public ResponseJson detail(Long sourceId, String dbName, String typeName, String procName) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
try {
|
||||
ProcedureDto procedureDto = dbBaseService.getProcedureDetail(sourceId, dbName, typeName, procName);
|
||||
return DocDbResponseJson.ok(procedureDto);
|
||||
} catch (Exception e) {
|
||||
// 一般是数据库的帐号没权限查存储过程
|
||||
return DocDbResponseJson.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除函数
|
||||
*
|
||||
* @param sourceId 数据源ID
|
||||
* @param dbName 数据库名
|
||||
* @param typeName 类型名
|
||||
* @param procName 函数名
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping(value = "/delete")
|
||||
public ResponseJson delete(Long sourceId, String dbName, String typeName, String procName) {
|
||||
this.judgeAuth(sourceId, DbAuthType.PROC_EDIT.getName(), "没有修改该库函数的权限");
|
||||
DbProcLog dbProcLog = this.createDbProcLog(sourceId, dbName, typeName, procName, "删除函数操作");
|
||||
try {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
dbBaseService.deleteProcedure(sourceId, dbName, typeName, procName);
|
||||
return DocDbResponseJson.ok();
|
||||
} catch (Exception e) {
|
||||
dbProcLog.setStatus(2);
|
||||
// 一般是数据库的帐号没权限查存储过程
|
||||
return DocDbResponseJson.error(e.getMessage());
|
||||
} finally {
|
||||
dbProcLogService.save(dbProcLog);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存函数
|
||||
*
|
||||
* @param sourceId 数据源ID
|
||||
* @param dbName 数据库名
|
||||
* @param typeName 类型名
|
||||
* @param procName 函数名
|
||||
* @param procSql 存储过程创建SQL
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping(value = "/save")
|
||||
public ResponseJson save(Long sourceId, String dbName, String typeName, String procName, String procSql) {
|
||||
this.judgeAuth(sourceId, DbAuthType.PROC_EDIT.getName(), "没有修改该库函数的权限");
|
||||
DbProcLog dbProcLog = this.createDbProcLog(sourceId, dbName, typeName, procName, procSql);
|
||||
try {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
ExecuteResult executeResult = dbBaseService.saveProcedure(sourceId, dbName, typeName, procName, procSql);
|
||||
if (StringUtils.isNotBlank(executeResult.getErrMsg())) {
|
||||
dbProcLog.setStatus(2);
|
||||
}
|
||||
return DocDbResponseJson.ok(executeResult);
|
||||
} catch (Exception e) {
|
||||
dbProcLog.setStatus(2);
|
||||
// 一般是数据库的帐号没权限查存储过程
|
||||
return DocDbResponseJson.error(e.getMessage());
|
||||
} finally {
|
||||
dbProcLogService.save(dbProcLog);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储过程修改日志列表
|
||||
*
|
||||
* @param sourceId 数据源ID
|
||||
* @param dbName 数据库名
|
||||
* @param typeName 类型名
|
||||
* @param procName 函数名
|
||||
* @return 列表
|
||||
*/
|
||||
@PostMapping(value = "/log/list")
|
||||
public ResponseJson logList(Integer pageNum, Integer pageSize, Long sourceId, String dbName, String typeName, String procName) {
|
||||
QueryWrapper<DbProcLog> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("datasource_id", sourceId);
|
||||
wrapper.eq("proc_db", dbName);
|
||||
wrapper.eq("proc_name", procName);
|
||||
wrapper.eq("proc_type", typeName);
|
||||
wrapper.orderByDesc("id");
|
||||
wrapper.select("id", "proc_body", "create_user_name", "create_time", "status");
|
||||
IPage<DbProcLog> page = new Page<>(pageNum, pageSize, pageNum == 1);
|
||||
dbProcLogService.page(page, wrapper);
|
||||
return DocDbResponseJson.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储过程修改日志详情
|
||||
*
|
||||
* @param logId 日志ID
|
||||
* @return 详情
|
||||
*/
|
||||
@PostMapping(value = "/log/detail")
|
||||
public ResponseJson logDetail(Long logId) {
|
||||
DbProcLog dbProcLog = dbProcLogService.getById(logId);
|
||||
return DocDbResponseJson.ok(dbProcLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限判断
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
*/
|
||||
private void judgeAuth(Long sourceId, String authName, String noAuthInfo) {
|
||||
if (!DocUserUtil.haveAuth(DocAuthConst.DB_DATASOURCE_MANAGE)
|
||||
&& !DocUserUtil.haveCustomAuth(authName, DocAuthConst.DB + sourceId)) {
|
||||
throw new ConfirmException(noAuthInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建日志对象
|
||||
* @param sourceId
|
||||
* @param dbName
|
||||
* @param typeName
|
||||
* @param procName
|
||||
* @param procSql
|
||||
* @return
|
||||
*/
|
||||
public DbProcLog createDbProcLog(Long sourceId, String dbName, String typeName, String procName, String procSql) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
DbProcLog dbProcLog = new DbProcLog();
|
||||
dbProcLog.setDatasourceId(sourceId);
|
||||
dbProcLog.setCreateTime(new Date());
|
||||
dbProcLog.setCreateUserId(currentUser.getUserId());
|
||||
dbProcLog.setCreateUserName(currentUser.getUsername());
|
||||
dbProcLog.setProcDb(dbName);
|
||||
dbProcLog.setProcName(procName);
|
||||
dbProcLog.setProcType(typeName);
|
||||
dbProcLog.setProcBody(procSql);
|
||||
dbProcLog.setStatus(1);
|
||||
return dbProcLog;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.zyplayer.doc.db.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
@@ -20,14 +19,20 @@ import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteParam;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteResult;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteType;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.SqlExecutor;
|
||||
import com.zyplayer.doc.db.framework.db.transfer.SqlParseUtil;
|
||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||
import com.zyplayer.doc.db.framework.utils.JSONUtil;
|
||||
import com.zyplayer.doc.db.framework.utils.SqlLogUtil;
|
||||
import com.zyplayer.doc.db.service.DatabaseServiceFactory;
|
||||
import com.zyplayer.doc.db.service.DbBaseService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -40,6 +45,7 @@ import java.util.*;
|
||||
@RestController
|
||||
@RequestMapping("/zyplayer-doc-db/executor")
|
||||
public class DbSqlExecutorController {
|
||||
private static Logger logger = LoggerFactory.getLogger(DbSqlExecutorController.class);
|
||||
|
||||
@Resource
|
||||
SqlExecutor sqlExecutor;
|
||||
@@ -47,9 +53,11 @@ public class DbSqlExecutorController {
|
||||
DbHistoryService dbHistoryService;
|
||||
@Resource
|
||||
DbFavoriteService dbFavoriteService;
|
||||
@Resource
|
||||
DatabaseServiceFactory databaseServiceFactory;
|
||||
|
||||
@PostMapping(value = "/execute")
|
||||
public ResponseJson execute(Long sourceId, String executeId, String sql, String params) {
|
||||
public ResponseJson execute(Long sourceId, String executeId, String dbName, String sql, String params) {
|
||||
if (StringUtils.isBlank(sql)) {
|
||||
return DocDbResponseJson.warn("执行的SQL不能为空");
|
||||
}
|
||||
@@ -59,34 +67,43 @@ public class DbSqlExecutorController {
|
||||
if (!manageAuth && !select && !update) {
|
||||
return DocDbResponseJson.warn("没有该数据源的执行权限");
|
||||
}
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
String useDbSql = dbBaseService.getUseDbSql(dbName);
|
||||
// 保留历史记录
|
||||
dbHistoryService.saveHistory(sql.trim(), sourceId);
|
||||
dbHistoryService.saveHistory(sql.trim(), params, sourceId);
|
||||
// 参数处理
|
||||
Map<String, Object> paramMap = JSON.parseObject(params);
|
||||
List<String> resultList = new LinkedList<>();
|
||||
// 支持;分割的多个sql执行
|
||||
String[] sqlArr = sql.split(";");
|
||||
// 执行条数太多,反应慢,展示结果栏太多,也不应该在这一次执行很多条语句,应该使用导入
|
||||
if (sqlArr.length > 20) {
|
||||
return DocDbResponseJson.warn("单次执行最多支持20条语句同时执行,当前语句条数:" + sqlArr.length);
|
||||
}
|
||||
for (String sqlItem : sqlArr) {
|
||||
if (StringUtils.isBlank(sqlItem)) {
|
||||
continue;
|
||||
}
|
||||
sqlItem = sqlItem.trim();
|
||||
ExecuteResult executeResult;
|
||||
ExecuteParam executeParam = new ExecuteParam();
|
||||
try {
|
||||
ExecuteType executeType = (!manageAuth && select) ? ExecuteType.SELECT : ExecuteType.ALL;
|
||||
ExecuteParam executeParam = new ExecuteParam();
|
||||
ExecuteType executeType = (manageAuth || update) ? ExecuteType.ALL : ExecuteType.SELECT;
|
||||
executeParam = SqlParseUtil.getSingleExecuteParam(sqlItem, paramMap);
|
||||
executeParam.setDatasourceId(sourceId);
|
||||
executeParam.setExecuteId(executeId);
|
||||
executeParam.setExecuteType(executeType);
|
||||
executeParam.setSql(sqlItem);
|
||||
executeParam.setPrefixSql(useDbSql);
|
||||
executeParam.setMaxRows(1000);
|
||||
ExecuteResult executeResult = sqlExecutor.execute(executeParam);
|
||||
SerializeConfig mapping = new SerializeConfig();
|
||||
mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
|
||||
mapping.put(Timestamp.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
|
||||
String resultJsonStr = JSON.toJSONString(executeResult, mapping, SerializerFeature.WriteMapNullValue);
|
||||
resultList.add(resultJsonStr);
|
||||
executeResult = sqlExecutor.execute(executeParam);
|
||||
} catch (Exception e) {
|
||||
ExecuteResult executeResult = ExecuteResult.error(StringUtil.getException(e), sqlItem);
|
||||
resultList.add(JSON.toJSONString(executeResult));
|
||||
logger.error("执行出错", e);
|
||||
executeResult = ExecuteResult.error(e.getMessage(), sqlItem);
|
||||
}
|
||||
// 执行的sql处理
|
||||
String executeSqlLog = SqlLogUtil.parseLogSql(executeParam.getSql(), executeParam.getParameterMappings(), executeParam.getParamList());
|
||||
executeResult.setSql(executeSqlLog);
|
||||
resultList.add(JSON.toJSONString(executeResult, JSONUtil.serializeConfig, SerializerFeature.WriteMapNullValue));
|
||||
}
|
||||
return DocDbResponseJson.ok(resultList);
|
||||
}
|
||||
@@ -139,5 +156,6 @@ public class DbSqlExecutorController {
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.zyplayer.doc.db.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbTableRelation;
|
||||
import com.zyplayer.doc.data.repository.manage.param.TableRelationParam;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.TableRelationVo;
|
||||
import com.zyplayer.doc.data.service.manage.DbTableRelationService;
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo;
|
||||
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||
import com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto;
|
||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||
import com.zyplayer.doc.db.service.DatabaseServiceFactory;
|
||||
import com.zyplayer.doc.db.service.DbBaseService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 表关系控制器
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年6月6日
|
||||
*/
|
||||
@AuthMan
|
||||
@RestController
|
||||
@RequestMapping("/zyplayer-doc-db/table-relation")
|
||||
public class DbTableRelationController {
|
||||
private static Logger logger = LoggerFactory.getLogger(DbTableRelationController.class);
|
||||
|
||||
@Resource
|
||||
DatabaseServiceFactory databaseServiceFactory;
|
||||
@Resource
|
||||
DbTableRelationService dbTableRelationService;
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
public ResponseJson update(TableRelationParam param) {
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(param.getSourceId());
|
||||
dbBaseService.judgeAuth(param.getSourceId(), DbAuthType.UPDATE.getName(), "没有该库的执行权限");
|
||||
dbTableRelationService.update(param);
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getRelation")
|
||||
public ResponseJson getRelation(TableRelationParam param) {
|
||||
TableRelationVo relationVo = new TableRelationVo();
|
||||
relationVo.setDbName(param.getDbName());
|
||||
relationVo.setName(param.getTableName());
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(param.getSourceId());
|
||||
TableColumnVo tableColumn = dbBaseService.getTableColumnList(param.getSourceId(), param.getDbName(), param.getTableName());
|
||||
if (CollectionUtils.isNotEmpty(tableColumn.getColumnList())) {
|
||||
Set<String> drillPath = new HashSet<>();
|
||||
List<TableRelationVo> childrenRelationList = new LinkedList<>();
|
||||
for (TableColumnDescDto columnDto : tableColumn.getColumnList()) {
|
||||
drillPath.add(param.getDbName() + "." + param.getTableName() + "." + columnDto.getName());
|
||||
TableRelationVo relationVoChildren = new TableRelationVo();
|
||||
relationVoChildren.setNodeType(1);
|
||||
relationVoChildren.setDbName(param.getDbName());
|
||||
relationVoChildren.setTableName(param.getTableName());
|
||||
relationVoChildren.setName(columnDto.getName());
|
||||
relationVoChildren.setColumnName(columnDto.getName());
|
||||
relationVoChildren.setChildren(this.getRelation(param.getSourceId(), param.getDbName(), param.getTableName(), columnDto.getName(), drillPath,1));
|
||||
childrenRelationList.add(relationVoChildren);
|
||||
}
|
||||
relationVo.setChildren(childrenRelationList);
|
||||
}
|
||||
return DocDbResponseJson.ok(relationVo);
|
||||
}
|
||||
|
||||
public List<TableRelationVo> getRelation(Long sourceId, String dbName, String tableName, String columnName, Set<String> drillPath, int recursion) {
|
||||
// 最大支持5层关系链展示
|
||||
if (recursion >= 5) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
QueryWrapper<DbTableRelation> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("datasource_id", sourceId);
|
||||
queryWrapper.and(wrapper -> wrapper.or(or -> or.eq("start_db_name", dbName)
|
||||
.eq("start_table_name", tableName)
|
||||
.eq("start_column_name", columnName)
|
||||
).or(or -> or.eq("end_db_name", dbName)
|
||||
.eq("end_table_name", tableName)
|
||||
.eq("end_column_name", columnName)
|
||||
));
|
||||
List<TableRelationVo> resultRelationList = new LinkedList<>();
|
||||
List<DbTableRelation> relationList = dbTableRelationService.list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(relationList)) {
|
||||
return resultRelationList;
|
||||
}
|
||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||
for (DbTableRelation tableRelation : relationList) {
|
||||
String endDbName = tableRelation.getStartDbName();
|
||||
String endTableName = tableRelation.getStartTableName();
|
||||
String endColumnName = tableRelation.getStartColumnName();
|
||||
if (Objects.equals(tableRelation.getStartDbName(), dbName)
|
||||
&& Objects.equals(tableRelation.getStartTableName(), tableName)
|
||||
&& Objects.equals(tableRelation.getStartColumnName(), columnName)) {
|
||||
endDbName = tableRelation.getEndDbName();
|
||||
endTableName = tableRelation.getEndTableName();
|
||||
endColumnName = tableRelation.getEndColumnName();
|
||||
}
|
||||
if (drillPath.contains(endDbName + "." + endTableName + "." + endColumnName)) {
|
||||
continue;
|
||||
}
|
||||
TableRelationVo relationVo = new TableRelationVo();
|
||||
relationVo.setDbName(endDbName);
|
||||
relationVo.setTableName(endTableName);
|
||||
relationVo.setName("表:" + endTableName + "\n列:" + endColumnName);
|
||||
relationVo.setColumnName(endColumnName);
|
||||
TableColumnVo tableColumn = dbBaseService.getTableColumnList(sourceId, endDbName, endTableName);
|
||||
if (CollectionUtils.isNotEmpty(tableColumn.getColumnList())) {
|
||||
List<TableRelationVo> childrenRelationList = new LinkedList<>();
|
||||
for (TableColumnDescDto columnDto : tableColumn.getColumnList()) {
|
||||
boolean contains = drillPath.contains(endDbName + "." + endTableName + "." + columnDto.getName());
|
||||
drillPath.add(endDbName + "." + endTableName + "." + columnDto.getName());
|
||||
TableRelationVo relationVoChildren = new TableRelationVo();
|
||||
relationVoChildren.setNodeType(1);
|
||||
relationVoChildren.setDbName(endDbName);
|
||||
relationVoChildren.setTableName(endTableName);
|
||||
relationVoChildren.setName(columnDto.getName());
|
||||
relationVoChildren.setColumnName(columnDto.getName());
|
||||
if (!contains) {
|
||||
relationVoChildren.setChildren(this.getRelation(sourceId, endDbName, endTableName, columnDto.getName(), drillPath, recursion + 1));
|
||||
}
|
||||
childrenRelationList.add(relationVoChildren);
|
||||
}
|
||||
relationVo.setChildren(childrenRelationList);
|
||||
}
|
||||
resultRelationList.add(relationVo);
|
||||
}
|
||||
return resultRelationList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -92,5 +96,4 @@ public class DbTransferDataController {
|
||||
List<String> selectNames = SqlParseUtil.getSelectNames(sql);
|
||||
return DocDbResponseJson.ok(selectNames);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.zyplayer.doc.db.controller.param;
|
||||
|
||||
public class DataDownloadParam {
|
||||
private Long sourceId;
|
||||
private String dbName;
|
||||
private String tableName;
|
||||
private String downloadType;
|
||||
private String conditionColumn;
|
||||
|
||||
public Long getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public void setSourceId(Long sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
public String getDbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
public void setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getDownloadType() {
|
||||
return downloadType;
|
||||
}
|
||||
|
||||
public void setDownloadType(String downloadType) {
|
||||
this.downloadType = downloadType;
|
||||
}
|
||||
|
||||
public String getConditionColumn() {
|
||||
return conditionColumn;
|
||||
}
|
||||
|
||||
public void setConditionColumn(String conditionColumn) {
|
||||
this.conditionColumn = conditionColumn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.zyplayer.doc.db.controller.param;
|
||||
|
||||
public class DataViewParam {
|
||||
private Long sourceId;
|
||||
private String executeId;
|
||||
private Integer pageSize;
|
||||
private Integer pageNum;
|
||||
private String dbName;
|
||||
private String tableName;
|
||||
// 下载多张数据表
|
||||
private String tableNames;
|
||||
private String orderColumn;
|
||||
private String orderType;
|
||||
private String condition;
|
||||
private String downloadType;
|
||||
private String retainColumn;
|
||||
private String conditionColumn;
|
||||
private Integer dropTableFlag;
|
||||
private Integer createTableFlag;
|
||||
private Integer downloadFileType;
|
||||
|
||||
public Integer getOffset() {
|
||||
return ((this.pageNum - 1) * this.pageSize);
|
||||
}
|
||||
|
||||
public Long getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public void setSourceId(Long sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
public String getExecuteId() {
|
||||
return executeId;
|
||||
}
|
||||
|
||||
public void setExecuteId(String executeId) {
|
||||
this.executeId = executeId;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public String getDbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
public void setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getOrderColumn() {
|
||||
return orderColumn;
|
||||
}
|
||||
|
||||
public void setOrderColumn(String orderColumn) {
|
||||
this.orderColumn = orderColumn;
|
||||
}
|
||||
|
||||
public String getOrderType() {
|
||||
return orderType;
|
||||
}
|
||||
|
||||
public void setOrderType(String orderType) {
|
||||
this.orderType = orderType;
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getDownloadType() {
|
||||
return downloadType;
|
||||
}
|
||||
|
||||
public void setDownloadType(String downloadType) {
|
||||
this.downloadType = downloadType;
|
||||
}
|
||||
|
||||
public String getConditionColumn() {
|
||||
return conditionColumn;
|
||||
}
|
||||
|
||||
public void setConditionColumn(String conditionColumn) {
|
||||
this.conditionColumn = conditionColumn;
|
||||
}
|
||||
|
||||
public Integer getDropTableFlag() {
|
||||
return dropTableFlag;
|
||||
}
|
||||
|
||||
public void setDropTableFlag(Integer dropTableFlag) {
|
||||
this.dropTableFlag = dropTableFlag;
|
||||
}
|
||||
|
||||
public Integer getCreateTableFlag() {
|
||||
return createTableFlag;
|
||||
}
|
||||
|
||||
public void setCreateTableFlag(Integer createTableFlag) {
|
||||
this.createTableFlag = createTableFlag;
|
||||
}
|
||||
|
||||
public String getRetainColumn() {
|
||||
return retainColumn;
|
||||
}
|
||||
|
||||
public void setRetainColumn(String retainColumn) {
|
||||
this.retainColumn = retainColumn;
|
||||
}
|
||||
|
||||
public String getTableNames() {
|
||||
return tableNames;
|
||||
}
|
||||
|
||||
public void setTableNames(String tableNames) {
|
||||
this.tableNames = tableNames;
|
||||
}
|
||||
|
||||
public Integer getDownloadFileType() {
|
||||
return downloadFileType;
|
||||
}
|
||||
|
||||
public void setDownloadFileType(Integer downloadFileType) {
|
||||
this.downloadFileType = downloadFileType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.zyplayer.doc.db.controller.param;
|
||||
|
||||
public class ProcedureListParam {
|
||||
private Long sourceId;
|
||||
private String dbName;
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
private Integer offset;
|
||||
private String name;
|
||||
private String type;
|
||||
|
||||
public Long getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public void setSourceId(Long sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
public String getDbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
public void setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(Integer offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,12 @@ public class DatabaseExportVo {
|
||||
private Map<String, List<TableColumnDescDto>> columnList;
|
||||
|
||||
private List<TableInfoVo> tableList;
|
||||
|
||||
|
||||
public DatabaseExportVo(Map<String, List<TableColumnDescDto>> columnList, List<TableInfoVo> tableList) {
|
||||
this.columnList = columnList;
|
||||
this.tableList = tableList;
|
||||
}
|
||||
|
||||
public Map<String, List<TableColumnDescDto>> getColumnList() {
|
||||
return columnList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.zyplayer.doc.db.controller.vo;
|
||||
|
||||
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class TableDdlVo {
|
||||
private String current;
|
||||
private String mysql;
|
||||
private String sqlserver;
|
||||
private String oracle;
|
||||
private String postgresql;
|
||||
private String hive;
|
||||
|
||||
public String getTableDDLByType() {
|
||||
if (Objects.equals(current, DatabaseProductEnum.MYSQL.name().toLowerCase())) return mysql;
|
||||
if (Objects.equals(current, DatabaseProductEnum.SQLSERVER.name().toLowerCase())) return sqlserver;
|
||||
if (Objects.equals(current, DatabaseProductEnum.ORACLE.name().toLowerCase())) return oracle;
|
||||
if (Objects.equals(current, DatabaseProductEnum.POSTGRESQL.name().toLowerCase())) return postgresql;
|
||||
if (Objects.equals(current, DatabaseProductEnum.HIVE.name().toLowerCase())) return hive;
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getHive() {
|
||||
return hive;
|
||||
}
|
||||
|
||||
public void setHive(String hive) {
|
||||
this.hive = hive;
|
||||
}
|
||||
|
||||
public String getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setCurrent(String current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public String getMysql() {
|
||||
return mysql;
|
||||
}
|
||||
|
||||
public void setMysql(String mysql) {
|
||||
this.mysql = mysql;
|
||||
}
|
||||
|
||||
public String getSqlserver() {
|
||||
return sqlserver;
|
||||
}
|
||||
|
||||
public void setSqlserver(String sqlserver) {
|
||||
this.sqlserver = sqlserver;
|
||||
}
|
||||
|
||||
public String getOracle() {
|
||||
return oracle;
|
||||
}
|
||||
|
||||
public void setOracle(String oracle) {
|
||||
this.oracle = oracle;
|
||||
}
|
||||
|
||||
public String getPostgresql() {
|
||||
return postgresql;
|
||||
}
|
||||
|
||||
public void setPostgresql(String postgresql) {
|
||||
this.postgresql = postgresql;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public class TableStatusVo {
|
||||
private String checksum;
|
||||
private String createOptions;
|
||||
private String comment;
|
||||
private String dbType;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -165,4 +166,12 @@ public class TableStatusVo {
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getDbType() {
|
||||
return dbType;
|
||||
}
|
||||
|
||||
public void setDbType(String dbType) {
|
||||
this.dbType = dbType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ public class UserDbAuthVo {
|
||||
private Long userId;
|
||||
private Integer executeAuth;
|
||||
private Integer descEditAuth;
|
||||
private Integer procEditAuth;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
@@ -37,4 +38,12 @@ public class UserDbAuthVo {
|
||||
public void setDescEditAuth(Integer descEditAuth) {
|
||||
this.descEditAuth = descEditAuth;
|
||||
}
|
||||
|
||||
public Integer getProcEditAuth() {
|
||||
return procEditAuth;
|
||||
}
|
||||
|
||||
public void setProcEditAuth(Integer procEditAuth) {
|
||||
this.procEditAuth = procEditAuth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,15 @@
|
||||
package com.zyplayer.doc.db.framework.configuration;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
|
||||
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ApplicationListenerBean implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
@Resource
|
||||
DatabaseRegistrationBean databaseRegistrationBean;
|
||||
@Resource
|
||||
DbDatasourceService dbDatasourceService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
List<DatabaseFactoryBean> databaseFactoryBeanList = new LinkedList<>();
|
||||
|
||||
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("yn", 1);
|
||||
List<DbDatasource> datasourceList = dbDatasourceService.list(wrapper);
|
||||
for (DbDatasource dbDatasource : datasourceList) {
|
||||
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource);
|
||||
if (databaseFactoryBean != null) {
|
||||
databaseFactoryBeanList.add(databaseFactoryBean);
|
||||
}
|
||||
}
|
||||
databaseRegistrationBean.setDatabaseFactoryBeanList(databaseFactoryBeanList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user