Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc41ebdac1 |
47
README.md
@@ -1,12 +1,7 @@
|
||||
# zyplayer-doc
|
||||
|
||||
#### 项目介绍
|
||||
定位为所有文档的管理项目,swagger文档、dubbo文档、数据库文档....等,提供一整套的解决方案,为开发者服务,欢迎有想法的一起来写,给个Star鼓励下呗!(您的一个Star是快速迭代的动力源泉!)
|
||||
欢迎加群讨论,QQ群号:466363173
|
||||
|
||||
体验地址:[http://doc.zyplayer.com](http://doc.zyplayer.com/zyplayer-doc-manage/static/manage/home.html) 需登录 账号:zyplayer 密码:123456 (未运行dubbo服务,不能体验dubbo文档调试)
|
||||
|
||||
开放文档地址:[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) (无需登录)
|
||||
定位为所有文档的管理项目,swagger文档、数据库文档....等,提供一整套的解决方案,欢迎有想法的一起来写
|
||||
|
||||
#### 软件架构
|
||||
##### 一、zyplayer-doc-core 一些核心、公用的类
|
||||
@@ -15,7 +10,7 @@
|
||||
> 原[zyplayer-doc-db](https://gitee.com/zyplayer/zyplayer-doc-db),具有数据库文档的查看、管理、导出等功能
|
||||
|
||||
##### 三、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)等框架
|
||||
> 后端使用spring-boot、mybatis-plus、springfox-swagger等框架,前端使用[zui](http://zui.sexy/)、[Vue](https://cn.vuejs.org/)等框架
|
||||
|
||||
> 已集成三套优秀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)
|
||||
|
||||
@@ -24,27 +19,16 @@
|
||||
##### 四、zyplayer-doc-swagger 原[swagger-mg-ui](https://gitee.com/zyplayer/swagger-mg-ui),swagger的UI及整套解决方案
|
||||
> 具有 后端存储、代理请求、模拟返回、所有文档管理 等一系列原创功能,不止UI
|
||||
|
||||
##### 五、zyplayer-doc-dubbo 将dubbo的文档在线化管理
|
||||
> 支持zookeeper、nacos的注册中心文档获取,支持在线调试接口
|
||||
|
||||
##### 六、zyplayer-doc-wiki wiki文档工具
|
||||
> 支持文档创建、展示,文件上传、下载,空间隔离,开放文档访问等
|
||||
|
||||
##### 七、zyplayer-doc-grpc grpc文档工具
|
||||
> 用比较变态的方式实现了grpc的文档和在线调试功能,通过http的方式来请求grpc的接口
|
||||
|
||||
> 默认未开启此功能,如需使用需要在zyplayer-doc-manage项目中开启@EnableDocGrpc注解
|
||||
|
||||
#### 运行方式
|
||||
|
||||
1. 创建数据库:zyplayer_doc_manage,执行脚本:[zyplayer_doc_manage.1.0.1.sql](https://gitee.com/zyplayer/zyplayer-doc/blob/master/zyplayer-doc-manage/src/main/resources/sql/zyplayer_doc_manage.1.0.1.sql)
|
||||
1. 创建数据库:zyplayer_doc_manage,执行脚本:[zyplayer_doc_manage.sql](https://gitee.com/zyplayer/zyplayer-doc/blob/master/zyplayer-doc-manage/src/main/resources/sql/zyplayer_doc_manage.sql)
|
||||
|
||||
2. 修改zyplayer-doc-manage项目的application.yml配置文件里面的数据库账号密码
|
||||
|
||||
3. 启动zyplayer-doc-manage项目,访问地址:
|
||||
http://127.0.0.1:8082/zyplayer-doc-manage/static/manage/home.html
|
||||
http://127.0.0.1:8082/zyplayer-doc-manage/statics/manage/home.html
|
||||
未登录会进入登录页面,登陆后自动跳回,默认账号:zyplayer 密码:123456
|
||||
> 注意!!项目页面全是静态的html,如果使用idea启动,有可能访问不了静态页面,需要在这里配置下工作目录,然后重新启动即可
|
||||
> 项目页面全是静态的html,如果使用idea启动,有可能访问不了静态页面,需要在这里配置下工作目录,然后重新启动即可
|
||||

|
||||
|
||||
#### 功能介绍
|
||||
@@ -71,37 +55,18 @@ http://127.0.0.1:8082/zyplayer-doc-manage/static/manage/home.html
|
||||
|
||||
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的配置,访问地址:http://127.0.0.1:8082/zyplayer-doc-manage/doc-dubbo.html
|
||||
|
||||
4. 支持文档查找、文档编辑、在线调试接口
|
||||
|
||||
5. 自动获取参数列表需要指定的类存在,所以请在 pom.xml -> dependencies 最后加上服务所在的包,后端才能通过Class.forName("xx");来找到参数列表,减少录入成本
|
||||
|
||||
6. 数组或List参数,调试参数录入格式例:[1,2] ,后端通过JSON工具转成指定类型,有不支持的类型时欢迎反馈
|
||||
|
||||
##### 四、zyplayer-doc-manage
|
||||
##### 三、zyplayer-doc-manage
|
||||
1. 整合了上面两个功能到此项目,较少熟悉成本,`git clone`下来即可运行
|
||||
|
||||
2. 具有简单的`权限管理`、`人员管理`功能(还没想好具体怎么控制,没需求)
|
||||
|
||||
3. 使用最新的一些技术框架,很简单,初学者拿来学习也是很不错的
|
||||
|
||||
如果觉得此项目对您有帮助,就捐赠一个吧!无关金额,主要是对作者的认可。
|
||||
|
||||
#### 界面展示
|
||||
权限和用户管理:
|
||||

|
||||
数据库文档:
|
||||

|
||||
dubbo文档:
|
||||

|
||||
dubbo接口调试:
|
||||

|
||||
增加文档处:
|
||||

|
||||
使用springfox-swagger-ui访问增加的文档:
|
||||
|
||||
34
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>zyplayer-doc</name>
|
||||
@@ -17,14 +17,36 @@
|
||||
<fastjson.version>1.2.53</fastjson.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<modules>
|
||||
<module>zyplayer-doc-db</module>
|
||||
<module>zyplayer-doc-manage</module>
|
||||
<module>zyplayer-doc-swagger</module>
|
||||
<module>zyplayer-doc-core</module>
|
||||
<module>zyplayer-doc-dubbo</module>
|
||||
<module>zyplayer-doc-wiki</module>
|
||||
<module>zyplayer-doc-data</module>
|
||||
<module>zyplayer-doc-grpc</module>
|
||||
</modules>
|
||||
</project>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
# 本文件用于已部署好的系统检测自己是否需要升级使用
|
||||
lastVersion=1.0.1
|
||||
upgradeContent=1、增加wiki文档模块;2、dubbo文档支持使用元数据生成参数和返回值;3、框架进行了大的拆分;4、增加升级通知;5、细节优化
|
||||
upgradeUrl=https://gitee.com/zyplayer/zyplayer-doc/releases
|
||||
nextStep=1、支持直接同步到git的文档;2、支持微信文章拉取
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<parent>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.0</version>
|
||||
<name>zyplayer-doc-core</name>
|
||||
|
||||
<url>http://maven.apache.org</url>
|
||||
@@ -14,24 +18,9 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<fastjson.version>1.2.53</fastjson.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-data</artifactId>
|
||||
<version>1.0.1</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.6.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<mybatis.plus.boot.starter.version>3.0.6</mybatis.plus.boot.starter.version>
|
||||
<fastjson.version>1.2.53</fastjson.version>
|
||||
<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.1</zyplayer.doc.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis.plus.boot.starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>${alibaba.druid.version}</version>
|
||||
</dependency>
|
||||
<!-- json -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.dozermapper</groupId>
|
||||
<artifactId>dozer-core</artifactId>
|
||||
<version>${dozer.core.version}</version>
|
||||
</dependency>
|
||||
<!-- 在线文档解析页面 -->
|
||||
<!--zyplayer-doc-core-->
|
||||
<dependency>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
<version>${zyplayer.doc.version}</version>
|
||||
</dependency>
|
||||
<!-- velocity 模板引擎, 默认 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>${velocity.engine.core.version}</version>
|
||||
</dependency>
|
||||
<!-- freemarker 模板引擎 -->
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
<!-- 整合spring security -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
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 2019-03-09
|
||||
*/
|
||||
public class WikiPage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 空间ID
|
||||
*/
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 节点类型 0=有子节点 1=终节点
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 赞的数量
|
||||
*/
|
||||
private Integer zanNum;
|
||||
|
||||
/**
|
||||
* 编辑类型 0=可编辑 1=不允许编辑
|
||||
*/
|
||||
private Integer editType;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改人ID
|
||||
*/
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 修改人名字
|
||||
*/
|
||||
private String updateUserName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 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 String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
public Integer getNodeType() {
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(Integer nodeType) {
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
public Integer getZanNum() {
|
||||
return zanNum;
|
||||
}
|
||||
|
||||
public void setZanNum(Integer zanNum) {
|
||||
this.zanNum = zanNum;
|
||||
}
|
||||
public Integer getEditType() {
|
||||
return editType;
|
||||
}
|
||||
|
||||
public void setEditType(Integer editType) {
|
||||
this.editType = editType;
|
||||
}
|
||||
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 Long getUpdateUserId() {
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
public void setUpdateUserId(Long updateUserId) {
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
public String getUpdateUserName() {
|
||||
return updateUserName;
|
||||
}
|
||||
|
||||
public void setUpdateUserName(String updateUserName) {
|
||||
this.updateUserName = updateUserName;
|
||||
}
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WikiPage{" +
|
||||
"id=" + id +
|
||||
", spaceId=" + spaceId +
|
||||
", name=" + name +
|
||||
", parentId=" + parentId +
|
||||
", nodeType=" + nodeType +
|
||||
", zanNum=" + zanNum +
|
||||
", editType=" + editType +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", updateUserId=" + updateUserId +
|
||||
", updateUserName=" + updateUserName +
|
||||
", updateTime=" + updateTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
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 2019-02-24
|
||||
*/
|
||||
public class WikiPageComment 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 parentId;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 创建人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 getPageId() {
|
||||
return pageId;
|
||||
}
|
||||
|
||||
public void setPageId(Long pageId) {
|
||||
this.pageId = pageId;
|
||||
}
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
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 "WikiPageComment{" +
|
||||
"id=" + id +
|
||||
", pageId=" + pageId +
|
||||
", parentId=" + parentId +
|
||||
", content=" + content +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
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 2019-02-24
|
||||
*/
|
||||
public class WikiPageContent implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 页面ID
|
||||
*/
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改人ID
|
||||
*/
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 修改人名字
|
||||
*/
|
||||
private String updateUserName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
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 String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
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 Long getUpdateUserId() {
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
public void setUpdateUserId(Long updateUserId) {
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
public String getUpdateUserName() {
|
||||
return updateUserName;
|
||||
}
|
||||
|
||||
public void setUpdateUserName(String updateUserName) {
|
||||
this.updateUserName = updateUserName;
|
||||
}
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WikiPageContent{" +
|
||||
"id=" + id +
|
||||
", pageId=" + pageId +
|
||||
", content=" + content +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", updateUserId=" + updateUserId +
|
||||
", updateUserName=" + updateUserName +
|
||||
", updateTime=" + updateTime +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
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 2019-03-06
|
||||
*/
|
||||
public class WikiPageFile implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 页面ID
|
||||
*/
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件URL
|
||||
*/
|
||||
private String fileUrl;
|
||||
|
||||
/**
|
||||
* 文件UUID
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改人ID
|
||||
*/
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 修改人名字
|
||||
*/
|
||||
private String updateUserName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 0=有效 1=删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
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 String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
public String getFileUrl() {
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
public void setFileUrl(String fileUrl) {
|
||||
this.fileUrl = fileUrl;
|
||||
}
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
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 Long getUpdateUserId() {
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
public void setUpdateUserId(Long updateUserId) {
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
public String getUpdateUserName() {
|
||||
return updateUserName;
|
||||
}
|
||||
|
||||
public void setUpdateUserName(String updateUserName) {
|
||||
this.updateUserName = updateUserName;
|
||||
}
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WikiPageFile{" +
|
||||
"id=" + id +
|
||||
", pageId=" + pageId +
|
||||
", fileName=" + fileName +
|
||||
", fileUrl=" + fileUrl +
|
||||
", uuid=" + uuid +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", updateUserId=" + updateUserId +
|
||||
", updateUserName=" + updateUserName +
|
||||
", updateTime=" + updateTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
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 2019-03-05
|
||||
*/
|
||||
public class WikiPageZan 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 commentId;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否有效 0=无效 1=有效
|
||||
*/
|
||||
private Integer yn;
|
||||
|
||||
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 getCommentId() {
|
||||
return commentId;
|
||||
}
|
||||
|
||||
public void setCommentId(Long commentId) {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
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 getYn() {
|
||||
return yn;
|
||||
}
|
||||
|
||||
public void setYn(Integer yn) {
|
||||
this.yn = yn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WikiPageZan{" +
|
||||
"id=" + id +
|
||||
", pageId=" + pageId +
|
||||
", commentId=" + commentId +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", yn=" + yn +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
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 2019-03-11
|
||||
*/
|
||||
public class WikiSpace implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 空间名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 空间类型 1=公司 2=个人 3=私人
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String spaceExplain;
|
||||
|
||||
/**
|
||||
* 编辑类型 0=可编辑 1=不允许编辑
|
||||
*/
|
||||
private Integer editType;
|
||||
|
||||
/**
|
||||
* 目录延迟加载 0=否 1=是
|
||||
*/
|
||||
private Integer treeLazyLoad;
|
||||
|
||||
/**
|
||||
* 是否是开放文档 0=否 1=是
|
||||
*/
|
||||
private Integer openDoc;
|
||||
|
||||
/**
|
||||
* 唯一UUID
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* 创建人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 Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
public String getSpaceExplain() {
|
||||
return spaceExplain;
|
||||
}
|
||||
|
||||
public void setSpaceExplain(String spaceExplain) {
|
||||
this.spaceExplain = spaceExplain;
|
||||
}
|
||||
public Integer getEditType() {
|
||||
return editType;
|
||||
}
|
||||
|
||||
public void setEditType(Integer editType) {
|
||||
this.editType = editType;
|
||||
}
|
||||
public Integer getTreeLazyLoad() {
|
||||
return treeLazyLoad;
|
||||
}
|
||||
|
||||
public void setTreeLazyLoad(Integer treeLazyLoad) {
|
||||
this.treeLazyLoad = treeLazyLoad;
|
||||
}
|
||||
public Integer getOpenDoc() {
|
||||
return openDoc;
|
||||
}
|
||||
|
||||
public void setOpenDoc(Integer openDoc) {
|
||||
this.openDoc = openDoc;
|
||||
}
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
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 "WikiSpace{" +
|
||||
"id=" + id +
|
||||
", name=" + name +
|
||||
", type=" + type +
|
||||
", spaceExplain=" + spaceExplain +
|
||||
", editType=" + editType +
|
||||
", treeLazyLoad=" + treeLazyLoad +
|
||||
", openDoc=" + openDoc +
|
||||
", uuid=" + uuid +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageComment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-24
|
||||
*/
|
||||
public interface WikiPageCommentMapper extends BaseMapper<WikiPageComment> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageContent;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-24
|
||||
*/
|
||||
public interface WikiPageContentMapper extends BaseMapper<WikiPageContent> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-06
|
||||
*/
|
||||
public interface WikiPageFileMapper extends BaseMapper<WikiPageFile> {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-09
|
||||
*/
|
||||
public interface WikiPageMapper extends BaseMapper<WikiPage> {
|
||||
|
||||
@Update("update wiki_page set zan_num=zan_num + #{numAdd} where id=#{id}")
|
||||
void updateZanNum(@Param("id") Long id, @Param("numAdd") Integer numAdd);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-05
|
||||
*/
|
||||
public interface WikiPageZanMapper extends BaseMapper<WikiPageZan> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-13
|
||||
*/
|
||||
public interface WikiSpaceMapper extends BaseMapper<WikiSpace> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageComment;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-24
|
||||
*/
|
||||
public interface WikiPageCommentService extends IService<WikiPageComment> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageContent;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-24
|
||||
*/
|
||||
public interface WikiPageContentService extends IService<WikiPageContent> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-06
|
||||
*/
|
||||
public interface WikiPageFileService extends IService<WikiPageFile> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-09
|
||||
*/
|
||||
public interface WikiPageService extends IService<WikiPage> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-05
|
||||
*/
|
||||
public interface WikiPageZanService extends IService<WikiPageZan> {
|
||||
void zanPage(WikiPageZan wikiPageZan);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-13
|
||||
*/
|
||||
public interface WikiSpaceService extends IService<WikiSpace> {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageComment;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageCommentMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageCommentService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-24
|
||||
*/
|
||||
@Service
|
||||
public class WikiPageCommentServiceImpl extends ServiceImpl<WikiPageCommentMapper, WikiPageComment> implements WikiPageCommentService {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageContent;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageContentMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageContentService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-24
|
||||
*/
|
||||
@Service
|
||||
public class WikiPageContentServiceImpl extends ServiceImpl<WikiPageContentMapper, WikiPageContent> implements WikiPageContentService {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageFileMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-06
|
||||
*/
|
||||
@Service
|
||||
public class WikiPageFileServiceImpl extends ServiceImpl<WikiPageFileMapper, WikiPageFile> implements WikiPageFileService {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-09
|
||||
*/
|
||||
@Service
|
||||
public class WikiPageServiceImpl extends ServiceImpl<WikiPageMapper, WikiPage> implements WikiPageService {
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
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.WikiPageZan;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageZanMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageZanService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-05
|
||||
*/
|
||||
@Service
|
||||
public class WikiPageZanServiceImpl extends ServiceImpl<WikiPageZanMapper, WikiPageZan> implements WikiPageZanService {
|
||||
|
||||
@Resource
|
||||
WikiPageMapper wikiPageMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void zanPage(WikiPageZan wikiPageZan) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
UpdateWrapper<WikiPageZan> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("create_user_id", currentUser.getUserId());
|
||||
wrapper.eq("page_id", wikiPageZan.getPageId());
|
||||
wrapper.eq(wikiPageZan.getCommentId() != null, "comment_id", wikiPageZan.getCommentId());
|
||||
WikiPageZan pageZan = this.getOne(wrapper);
|
||||
if (pageZan != null) {
|
||||
if (Objects.equals(wikiPageZan.getYn(), pageZan.getYn())) {
|
||||
return;
|
||||
}
|
||||
wikiPageZan.setId(pageZan.getId());
|
||||
this.updateById(wikiPageZan);
|
||||
} else {
|
||||
wikiPageZan.setCreateTime(new Date());
|
||||
wikiPageZan.setCreateUserId(currentUser.getUserId());
|
||||
wikiPageZan.setCreateUserName(currentUser.getUsername());
|
||||
this.save(wikiPageZan);
|
||||
}
|
||||
int numAdd = wikiPageZan.getYn() == 1 ? 1 : -1;
|
||||
wikiPageMapper.updateZanNum(wikiPageZan.getPageId(), numAdd);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiSpaceMapper;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-13
|
||||
*/
|
||||
@Service
|
||||
public class WikiSpaceServiceImpl extends ServiceImpl<WikiSpaceMapper, WikiSpace> implements WikiSpaceService {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.WikiPageCommentMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.WikiPageContentMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.WikiPageFileMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.WikiPageMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.WikiPageZanMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.WikiSpaceMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.zyplayer.doc.db.framework.configuration;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
@Target(value = { java.lang.annotation.ElementType.TYPE })
|
||||
@Documented
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {
|
||||
"com.zyplayer.doc.db",
|
||||
})
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<!--无论发布在哪、如何修改源码,请勿删除本行原作者信息,感谢-->
|
||||
<meta name="author" content="开发者列表:暮光:城中城,项目地址:https://gitee.com/zyplayer/zyplayer-doc" />
|
||||
<title>数据库文档</title>
|
||||
<link rel="shortcut icon" href="webjars/doc-db/img/api.ico"/>
|
||||
<link rel="stylesheet" href="webjars/zui/css/zui.min.css" />
|
||||
@@ -37,10 +35,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-info">
|
||||
<div style="height: 35px;line-height: 35px;">
|
||||
表名:<span class="table-name"></span>
|
||||
<button class="btn pull-right" type="button" id="aboutBtn" style="margin-right: 30px;">关于</button>
|
||||
</div>
|
||||
<div>表名:<span class="table-name"></span></div>
|
||||
<div class="desc">
|
||||
<div id="tableDescShow">
|
||||
<span class="table-desc"></span>
|
||||
@@ -151,57 +146,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 关于弹出框 -->
|
||||
<div class="modal fade" id="aboutModal">
|
||||
<div class="modal-dialog modal-lg" style="width: 600px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">关闭</span>
|
||||
</button>
|
||||
<h4 class="modal-title">关于zyplayer-doc-db</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" style="line-height: 30px;">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 no-padding">项目地址:</label>
|
||||
<div class="col-md-6 col-sm-10">
|
||||
<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 no-padding">开发人员:</label>
|
||||
<div class="col-md-6 col-sm-10">
|
||||
<a target="_blank" href="http://zyplayer.com">暮光:城中城</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">当前版本:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeNowVersion"></div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">最新版本:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeLastVersion"></div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">升级地址:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeUrl"></div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">升级内容:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeContent"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 no-padding"></div>
|
||||
<div class="col-md-10 col-sm-10">
|
||||
欢迎加群讨论,QQ群号:466363173,欢迎提交需求,欢迎使用和加入开发!
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="webjars/doc-db/js/jquery-3.1.0.min.js"></script>
|
||||
|
||||
@@ -1,43 +1,41 @@
|
||||
html,body{width: 100%;height: 100%;}
|
||||
|
||||
.container{padding-top: 20px;}
|
||||
|
||||
.table-info,.table-columns{margin-top: 10px;}
|
||||
|
||||
.table-info .desc{margin-top: 10px;}
|
||||
#tableDescInput{display: none;}
|
||||
|
||||
#tableDescShow .icon-edit{cursor: pointer;margin-left: 20px;display: none;}
|
||||
|
||||
.modal-table-box{margin-top: 10px; max-height: 500px;overflow-y: auto;}
|
||||
|
||||
#fuzzySearchModal .table td:nth-child(3){word-break:break-all;max-width: 400px;}
|
||||
#doExport{margin-right: 10px;}
|
||||
|
||||
#exportModal .alert{margin-top: 10px;}
|
||||
|
||||
#exportUl{list-style: none;}
|
||||
#exportUl li{float: left; border: 1px solid #ccc;padding: 10px 15px; margin: 0 10px 10px 0; background-color: #ccc;cursor: pointer;}
|
||||
#exportUl li.checked{border: 1px solid #3f51b5;background-color: #8666b8;color:#fff;}
|
||||
|
||||
.upgrade-info{display: none;}
|
||||
|
||||
/* S-覆盖原生样式 */
|
||||
.chosen-container-single .chosen-single div b {margin-top: 8px;}
|
||||
/* E-覆盖原生样式 */
|
||||
|
||||
/* S-JSON展示的样式 */
|
||||
pre.json{margin-top:0px;margin-bottom:0px;}
|
||||
pre.json .canvas{font:10pt georgia;background-color:#ececec;color:#000000;border:1px solid #cecece;}
|
||||
pre.json .objectBrace{color:#00aa00;font-weight:bold;}
|
||||
pre.json .arrayBrace{color:#0033ff;font-weight:bold;}
|
||||
pre.json .propertyName{color:#cc0000;font-weight:bold;}
|
||||
pre.json .string{color:#007777;}
|
||||
pre.json .number{color:#aa00aa;}
|
||||
pre.json .boolean{color:#0000ff;}
|
||||
pre.json .function{color:#aa6633;text-decoration:italic;}
|
||||
pre.json .null{color:#0000ff;}
|
||||
pre.json .comma{color:#000000;font-weight:bold;}
|
||||
pre img{cursor: pointer;}
|
||||
/* E-JSON展示的样式 */
|
||||
|
||||
html,body{width: 100%;height: 100%;}
|
||||
|
||||
.container{padding-top: 20px;}
|
||||
|
||||
.table-info,.table-columns{margin-top: 10px;}
|
||||
|
||||
.table-info .desc{margin-top: 10px;}
|
||||
#tableDescInput{display: none;}
|
||||
|
||||
#tableDescShow .icon-edit{cursor: pointer;margin-left: 20px;display: none;}
|
||||
|
||||
.modal-table-box{margin-top: 10px; max-height: 500px;overflow-y: auto;}
|
||||
|
||||
#fuzzySearchModal .table td:nth-child(3){word-break:break-all;max-width: 400px;}
|
||||
#doExport{margin-right: 10px;}
|
||||
|
||||
#exportModal .alert{margin-top: 10px;}
|
||||
|
||||
#exportUl{list-style: none;}
|
||||
#exportUl li{float: left; border: 1px solid #ccc;padding: 10px 15px; margin: 0 10px 10px 0; background-color: #ccc;cursor: pointer;}
|
||||
#exportUl li.checked{border: 1px solid #3f51b5;background-color: #8666b8;color:#fff;}
|
||||
|
||||
/* S-覆盖原生样式 */
|
||||
.chosen-container-single .chosen-single div b {margin-top: 8px;}
|
||||
/* E-覆盖原生样式 */
|
||||
|
||||
/* S-JSON展示的样式 */
|
||||
pre.json{margin-top:0px;margin-bottom:0px;}
|
||||
pre.json .canvas{font:10pt georgia;background-color:#ececec;color:#000000;border:1px solid #cecece;}
|
||||
pre.json .objectBrace{color:#00aa00;font-weight:bold;}
|
||||
pre.json .arrayBrace{color:#0033ff;font-weight:bold;}
|
||||
pre.json .propertyName{color:#cc0000;font-weight:bold;}
|
||||
pre.json .string{color:#007777;}
|
||||
pre.json .number{color:#aa00aa;}
|
||||
pre.json .boolean{color:#0000ff;}
|
||||
pre.json .function{color:#aa6633;text-decoration:italic;}
|
||||
pre.json .null{color:#0000ff;}
|
||||
pre.json .comma{color:#000000;font-weight:bold;}
|
||||
pre img{cursor: pointer;}
|
||||
/* E-JSON展示的样式 */
|
||||
|
||||
|
||||
@@ -186,12 +186,6 @@ function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction
|
||||
|
||||
},
|
||||
complete : function(msg) {
|
||||
if (msg.responseText.startWith("<!doctype html>")) {
|
||||
if (msg.responseText.indexOf("THIS_IS_LOGIN_PAGE_FLAG") > 0) {
|
||||
Toast.error('操作失败,登录已失效,请登陆后重试', 3000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(typeof completeFunction == "function") {
|
||||
completeFunction(msg,id);
|
||||
}
|
||||
|
||||
@@ -1,395 +1,372 @@
|
||||
|
||||
var pageConfig = {
|
||||
host: '',
|
||||
tableRelationDataIndex: 0,
|
||||
}
|
||||
|
||||
// 表关系图表
|
||||
var tableRelationCharts;
|
||||
|
||||
$(document).ready(function(){
|
||||
// 无论发布在哪、如何修改源码,请勿删除本行原作者信息,感谢
|
||||
console.log("%c项目信息:\n开发者列表:暮光:城中城\n项目地址:https://gitee.com/zyplayer/zyplayer-doc","color:red");
|
||||
$('select.chosen-select').chosen({
|
||||
no_results_text: '没有找到', // 当检索时没有找到匹配项时显示的提示文本
|
||||
disable_search_threshold: 0, // 10 个以下的选择项则不显示检索框
|
||||
search_contains: true, // 从任意位置开始检索
|
||||
width: '100%'
|
||||
});
|
||||
$('#checkAllTable').click(function(e){
|
||||
$("#exportUl li").addClass("checked");
|
||||
});
|
||||
$('#notCheckAllTable').click(function(e){
|
||||
$("#exportUl li").removeClass("checked");
|
||||
});
|
||||
$('#choiseExportDatabase').on('change', function(e){
|
||||
var host = $('#choiseExportHost').val();
|
||||
var dbName = $('#choiseExportDatabase').val();
|
||||
postService("zyplayer-doc-db/doc-db/getTableList", {host: host, dbName: dbName}, function(result){
|
||||
$('#exportUl').empty();
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
$("#exportUl").append('<li>'+result.data[i].tableName+'</li>');
|
||||
}
|
||||
$('#exportModal').modal('ajustPosition', 'fit');
|
||||
});
|
||||
});
|
||||
$('#choiseExportHost').on('change', function(e){
|
||||
var host = $(this).val();
|
||||
postService("zyplayer-doc-db/doc-db/getDatabaseList", {host: host}, function(result){
|
||||
$('#choiseExportDatabase').empty();
|
||||
$("#choiseExportDatabase").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var dbName = result.data[i].dbName;
|
||||
$("#choiseExportDatabase").append('<option value="'+dbName+'">'+dbName+'</option>');
|
||||
}
|
||||
$('#choiseExportDatabase').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseFuzzyHost').on('change', function(e){
|
||||
var host = $(this).val();
|
||||
postService("zyplayer-doc-db/doc-db/getDatabaseList", {host: host}, function(result){
|
||||
$('#choiseFuzzyDatabase').empty();
|
||||
$("#choiseFuzzyDatabase").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var dbName = result.data[i].dbName;
|
||||
$("#choiseFuzzyDatabase").append('<option value="'+dbName+'">'+dbName+'</option>');
|
||||
}
|
||||
$('#choiseFuzzyDatabase').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseHost').on('change', function(e){
|
||||
pageConfig.host = $(this).val();
|
||||
postService("zyplayer-doc-db/doc-db/getDatabaseList", {host: pageConfig.host}, function(result){
|
||||
$('#choiseDatabase').empty();
|
||||
$('#choiseTable').empty();
|
||||
$("#choiseDatabase").append('<option value=""></option>');
|
||||
$("#choiseTable").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var dbName = result.data[i].dbName;
|
||||
$("#choiseDatabase").append('<option value="'+dbName+'">'+dbName+'</option>');
|
||||
}
|
||||
$('#choiseDatabase').trigger('chosen:updated');
|
||||
$('#choiseTable').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseDatabase').on('change', function(e){
|
||||
var dbName = $(this).val();
|
||||
var param = {host: pageConfig.host, dbName: dbName};
|
||||
postService("zyplayer-doc-db/doc-db/getTableList", param, function(result){
|
||||
$('#choiseTable').empty();
|
||||
$("#choiseTable").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var tableName = result.data[i].tableName;
|
||||
$("#choiseTable").append('<option value="'+tableName+'">'+tableName+'</option>');
|
||||
}
|
||||
$('#choiseTable').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseTable').on('change', function(e){
|
||||
getTableColumnList();
|
||||
});
|
||||
$('#tableDescShow .icon-edit').click(function(e){
|
||||
var nowDesc = $("#tableDescShow .table-desc").html();
|
||||
$("#tableDescInput").val((nowDesc == "暂无注释") ? "" : nowDesc);
|
||||
$("#tableDescShow").hide();
|
||||
$("#tableDescInput").show().focus();
|
||||
});
|
||||
$("#tableDescInput").blur(function(){
|
||||
$("#tableDescShow").show();
|
||||
$("#tableDescInput").hide();
|
||||
updateTableDesc();
|
||||
});
|
||||
$("#fuzzySearchBtn").click(function(){
|
||||
$('#fuzzySearchModal').modal({moveable:true, backdrop: 'static'});
|
||||
$('#choiseFuzzyHost').trigger('chosen:updated');
|
||||
});
|
||||
$("#exportBtn").click(function(){
|
||||
$('#exportModal').modal({moveable:true, backdrop: 'static'});
|
||||
});
|
||||
$("#doExport").click(function(){
|
||||
var host = $('#choiseExportHost').val();
|
||||
var dbName = $('#choiseExportDatabase').val();
|
||||
var tableNames = "";
|
||||
$('#exportUl li.checked').text(function(index, value){
|
||||
if(tableNames != "") {tableNames += ",";}
|
||||
tableNames += value;
|
||||
});
|
||||
if(isEmpty(host)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(dbName)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(tableNames)){
|
||||
Toast.warn("请输选择需要导出的表");return;
|
||||
}
|
||||
window.open("zyplayer-doc-db/doc-db/exportDatabase?host="+host
|
||||
+"&dbName="+dbName
|
||||
+"&tableNames="+tableNames);
|
||||
});
|
||||
$("#exportUl").on("click", "li", function(){
|
||||
$(this).toggleClass("checked");
|
||||
});
|
||||
$("#showEchartsBtn").click(function(){
|
||||
$("#tableRelationBox").toggleClass("hide");
|
||||
if($("#tableRelationBox").hasClass("hide")){
|
||||
$(this).text("显示表关系图");
|
||||
} else {
|
||||
$(this).text("隐藏表关系图");
|
||||
tableRelationCharts.resize();
|
||||
}
|
||||
});
|
||||
$("#doSearch").click(function(){
|
||||
fuzzySearchByDesc();
|
||||
});
|
||||
$("#aboutBtn").click(function(){
|
||||
$('#aboutModal').modal({moveable:true, backdrop: 'static'});
|
||||
});
|
||||
$("#tableCloumnsTable tbody").on("click", ".column-desc", function(event){
|
||||
$(this).find("span").hide();
|
||||
$(this).find(".desc-input").show().focus();
|
||||
}).on("blur", ".column-desc", function(event){
|
||||
var newDesc = $(this).find(".desc-input").val();
|
||||
var columnName = $(this).find(".desc-input").attr("column");
|
||||
var oldDesc = $(this).find("span").text();
|
||||
$(this).find("span").show();
|
||||
$(this).find(".desc-input").hide();
|
||||
if(newDesc != oldDesc){
|
||||
var objThis = this;
|
||||
var param = getChoiseDbInfo(3);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
param.newDesc = newDesc;
|
||||
param.columnName = columnName;
|
||||
postService("zyplayer-doc-db/doc-db/updateTableColumnDesc", param, function(msg){
|
||||
$(objThis).find("span").text(newDesc);
|
||||
});
|
||||
}
|
||||
});
|
||||
initData();
|
||||
checkSystemUpgrade();
|
||||
});
|
||||
|
||||
function initData(){
|
||||
postService("zyplayer-doc-db/doc-db/getDataSourceList", {}, function(result){
|
||||
$('#choiseHost,#choiseFuzzyHost,#choiseExportHost').empty();
|
||||
if(validateResult(result)) {
|
||||
$("#choiseHost,#choiseFuzzyHost,#choiseExportHost").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
$("#choiseHost,#choiseFuzzyHost,#choiseExportHost").append('<option value="'+result.data[i]+'">'+result.data[i]+'</option>');
|
||||
}
|
||||
}
|
||||
$('#choiseHost').trigger('chosen:updated');
|
||||
$('#choiseFuzzyHost').trigger('chosen:updated');
|
||||
$('#choiseExportHost').trigger('chosen:updated');
|
||||
});
|
||||
tableRelationCharts = echarts.init(document.getElementById('tableRelationCharts'));
|
||||
tableRelationCharts.setOption(tableRelationOption);
|
||||
tableRelationCharts.on('click', function (params) {
|
||||
//console.log(params.data);
|
||||
var dataIndex = params.data.index;
|
||||
var description = params.data.description;
|
||||
// 用户ID,T:user_info.id
|
||||
// 用户ID,T:order_db.user_info.id
|
||||
var indexOf = description.indexOf("T:");
|
||||
if(indexOf < 0) {
|
||||
Toast.warn("该字段未关联表");
|
||||
return;
|
||||
}
|
||||
var dbAndTable = description.substring(indexOf + 2, description.length);
|
||||
var dbNameChoise, tableNameChoise;
|
||||
var tempSplit = dbAndTable.split(".");
|
||||
if(tempSplit.length == 3) {
|
||||
dbNameChoise = tempSplit[0];
|
||||
tableNameChoise = tempSplit[1];
|
||||
} else if(tempSplit.length == 2) {
|
||||
tableNameChoise = tempSplit[0];
|
||||
} else {
|
||||
tableNameChoise = dbAndTable;
|
||||
}
|
||||
var children = findChildren(tableRelationData, dataIndex);
|
||||
if(children != null && children.children.length <= 0) {
|
||||
// 查询表字段
|
||||
var param = getChoiseDbInfo(2);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
if(isNotEmpty(dbNameChoise)){
|
||||
param.dbName = dbNameChoise;
|
||||
}
|
||||
param.tableName = tableNameChoise;
|
||||
postService("zyplayer-doc-db/doc-db/getTableColumnList", param, function(msg){
|
||||
var columnList = msg.data.columnList
|
||||
if(!columnList || columnList.length <= 0) {
|
||||
Toast.warn("未找到该字段关联的表信息");return;
|
||||
}
|
||||
changetableRelationOption(children, columnList);
|
||||
tableRelationCharts.setOption(tableRelationOption);
|
||||
var height = pageConfig.tableRelationDataIndex * 25;
|
||||
$("#tableRelationBox").css("height", height + "px");
|
||||
tableRelationCharts.resize();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function changetableRelationOption(data, columnList){
|
||||
var childrenArr = [];
|
||||
for (var i = 0; i < columnList.length; i++) {
|
||||
var item = columnList[i];
|
||||
var description = getNotEmptyStr(item.description);
|
||||
var indexOf = description.indexOf("T:");
|
||||
var dbAndTable = "";
|
||||
if(indexOf >= 0) {
|
||||
dbAndTable = " " + description.substring(indexOf + 2, description.length);
|
||||
}
|
||||
childrenArr.push({
|
||||
name: item.name + " " + item.type + dbAndTable,
|
||||
children: [],
|
||||
collapsed: false,
|
||||
index: pageConfig.tableRelationDataIndex++,
|
||||
description: getNotEmptyStr(item.description),
|
||||
length: item.length
|
||||
});
|
||||
}
|
||||
data.children = childrenArr;
|
||||
}
|
||||
|
||||
function findChildren(source, dataIndex){
|
||||
var result = null;
|
||||
echarts.util.each(source.children, function (datum, index) {
|
||||
if(result != null) {
|
||||
return;
|
||||
}
|
||||
if(datum.index == dataIndex) {
|
||||
result = datum;
|
||||
} else if(datum.children && datum.children.length > 0) {
|
||||
result = findChildren(datum, dataIndex);
|
||||
}
|
||||
});
|
||||
if(result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function getTableColumnList(){
|
||||
var param = getChoiseDbInfo(3);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
$("#tableDescShow .icon-edit").hide();
|
||||
$("#tableCloumnsTable tbody").empty();
|
||||
$(".table-name").text(param.tableName);
|
||||
$(".table-desc").text("暂无注释");
|
||||
postService("zyplayer-doc-db/doc-db/getTableColumnList", param, function(msg){
|
||||
var columnList = msg.data.columnList
|
||||
for (var i = 0; i < columnList.length; i++) {
|
||||
var item = columnList[i];
|
||||
//var isidentity = isNull(item.isidentity) ? '-' : (1 == item.isidentity ? '是' : '否');
|
||||
$("#tableCloumnsTable tbody").append(
|
||||
'<tr>'
|
||||
+'<td>' + item.name + '</td>'
|
||||
+'<td>' + (1 == item.isidentity ? '是' : '否') + '</td>'
|
||||
+'<td>' + getNotEmptyStr(item.type) + '</td>'
|
||||
+'<td>' + getNotEmptyStr(item.length) + '</td>'
|
||||
+'<td>' + (1 == item.nullable ? '允许' : '不允许') + '</td>'
|
||||
+'<td>' + ("true" == item.ispramary ? '是' : '否') + '</td>'
|
||||
+'<td class="column-desc"><span>' + getNotEmptyStr(item.description) + '</span>'
|
||||
+'<input type="text" class="desc-input form-control" style="display:none;width: 100%;" column="' + item.name + '" value="' + (isEmpty(item.description)?'':item.description) + '">'
|
||||
+'</tr>'
|
||||
);
|
||||
}
|
||||
var tableInfo = msg.data.tableInfo;
|
||||
if (!!tableInfo && isNotEmpty(tableInfo.description)) {
|
||||
$(".table-desc").text(getNotEmptyStr(tableInfo.description));
|
||||
}
|
||||
$("#tableDescShow .icon-edit").show();
|
||||
pageConfig.tableRelationDataIndex = 0;
|
||||
changetableRelationOption(tableRelationData, columnList);
|
||||
tableRelationData.name = tableInfo.tableName;
|
||||
tableRelationCharts.setOption(tableRelationOption);
|
||||
var height = pageConfig.tableRelationDataIndex * 25;
|
||||
$("#tableRelationBox").css("height", height + "px");
|
||||
tableRelationCharts.resize();
|
||||
});
|
||||
}
|
||||
|
||||
function updateTableDesc(){
|
||||
var tableDescInput = $("#tableDescInput").val();
|
||||
var param = getChoiseDbInfo(3);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
param.newDesc = tableDescInput;
|
||||
postService("zyplayer-doc-db/doc-db/updateTableDesc", param, function(msg){
|
||||
$("#tableDescShow .table-desc").text(tableDescInput);
|
||||
});
|
||||
}
|
||||
|
||||
function getChoiseDbInfo(type) {
|
||||
var host = $("#choiseHost").val();
|
||||
var dbName = $("#choiseDatabase").val();
|
||||
var tableName = $("#choiseTable").val();
|
||||
if(type >= 1 && isEmpty(host)){
|
||||
Toast.warn("请先选择连接");return null;
|
||||
}
|
||||
if(type >= 2 && isEmpty(dbName)){
|
||||
Toast.warn("请先选择库名");return null;
|
||||
}
|
||||
if(type >= 3 && isEmpty(tableName)){
|
||||
Toast.warn("请先选择表名");return null;
|
||||
}
|
||||
return {host: host, dbName: dbName, tableName: tableName};
|
||||
}
|
||||
|
||||
function fuzzySearchByDesc(){
|
||||
var host = $("#choiseFuzzyHost").val();
|
||||
var dbName = $("#choiseFuzzyDatabase").val();
|
||||
var searchText = $("#searchText").val();
|
||||
if(isEmpty(host)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(dbName)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(searchText)){
|
||||
Toast.warn("请输入模糊匹配的内容");return;
|
||||
}
|
||||
$("#doSearch .icon").removeClass("hidden");
|
||||
var param = {host: host, dbName: dbName, searchText: searchText};
|
||||
postService("zyplayer-doc-db/doc-db/getTableAndColumnBySearch", param, function(msg){
|
||||
$("#fuzzySearchTable tbody").empty();
|
||||
for (var i = 0; i < msg.data.length; i++) {
|
||||
var item = msg.data[i];
|
||||
$("#fuzzySearchTable tbody").append(
|
||||
'<tr>'
|
||||
+'<td>' + item.tableName + '</td>'
|
||||
+'<td>' + item.columnName + '</td>'
|
||||
+'<td>' + getNotEmptyStr(item.description) + '</td>'
|
||||
+'</tr>'
|
||||
);
|
||||
}
|
||||
$('#fuzzySearchModal').modal('ajustPosition', 'fit');
|
||||
}, function(){
|
||||
$("#doSearch .icon").addClass("hidden");
|
||||
});
|
||||
}
|
||||
|
||||
function checkSystemUpgrade() {
|
||||
ajaxTemp("system/info/upgrade", "post", "json", {}, function (json) {
|
||||
if (json.errCode == 200 && !!json.data) {
|
||||
$(".upgrade-info").show();
|
||||
$("#upgradeNowVersion").html(json.data.nowVersion);
|
||||
$("#upgradeLastVersion").html(json.data.lastVersion);
|
||||
$("#upgradeUrl").html("<a target='_blank' href='" + json.data.upgradeUrl + "'>" + json.data.upgradeUrl + "</a>");
|
||||
$("#upgradeContent").html(json.data.upgradeContent);
|
||||
console.log("zyplayer-doc发现新版本:"
|
||||
+ "\n升级地址:" + json.data.upgradeUrl
|
||||
+ "\n当前版本:" + json.data.nowVersion
|
||||
+ "\n最新版本:" + json.data.lastVersion
|
||||
+ "\n升级内容:" + json.data.upgradeContent
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var pageConfig = {
|
||||
host: '',
|
||||
tableRelationDataIndex: 0,
|
||||
}
|
||||
|
||||
// 表关系图表
|
||||
var tableRelationCharts;
|
||||
|
||||
$(document).ready(function(){
|
||||
$('select.chosen-select').chosen({
|
||||
no_results_text: '没有找到', // 当检索时没有找到匹配项时显示的提示文本
|
||||
disable_search_threshold: 0, // 10 个以下的选择项则不显示检索框
|
||||
search_contains: true, // 从任意位置开始检索
|
||||
width: '100%'
|
||||
});
|
||||
$('#checkAllTable').click(function(e){
|
||||
$("#exportUl li").addClass("checked");
|
||||
});
|
||||
$('#notCheckAllTable').click(function(e){
|
||||
$("#exportUl li").removeClass("checked");
|
||||
});
|
||||
$('#choiseExportDatabase').on('change', function(e){
|
||||
var host = $('#choiseExportHost').val();
|
||||
var dbName = $('#choiseExportDatabase').val();
|
||||
postService("zyplayer-doc-db/doc-db/getTableList", {host: host, dbName: dbName}, function(result){
|
||||
$('#exportUl').empty();
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
$("#exportUl").append('<li>'+result.data[i].tableName+'</li>');
|
||||
}
|
||||
$('#exportModal').modal('ajustPosition', 'fit');
|
||||
});
|
||||
});
|
||||
$('#choiseExportHost').on('change', function(e){
|
||||
var host = $(this).val();
|
||||
postService("zyplayer-doc-db/doc-db/getDatabaseList", {host: host}, function(result){
|
||||
$('#choiseExportDatabase').empty();
|
||||
$("#choiseExportDatabase").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var dbName = result.data[i].dbName;
|
||||
$("#choiseExportDatabase").append('<option value="'+dbName+'">'+dbName+'</option>');
|
||||
}
|
||||
$('#choiseExportDatabase').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseFuzzyHost').on('change', function(e){
|
||||
var host = $(this).val();
|
||||
postService("zyplayer-doc-db/doc-db/getDatabaseList", {host: host}, function(result){
|
||||
$('#choiseFuzzyDatabase').empty();
|
||||
$("#choiseFuzzyDatabase").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var dbName = result.data[i].dbName;
|
||||
$("#choiseFuzzyDatabase").append('<option value="'+dbName+'">'+dbName+'</option>');
|
||||
}
|
||||
$('#choiseFuzzyDatabase').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseHost').on('change', function(e){
|
||||
pageConfig.host = $(this).val();
|
||||
postService("zyplayer-doc-db/doc-db/getDatabaseList", {host: pageConfig.host}, function(result){
|
||||
$('#choiseDatabase').empty();
|
||||
$('#choiseTable').empty();
|
||||
$("#choiseDatabase").append('<option value=""></option>');
|
||||
$("#choiseTable").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var dbName = result.data[i].dbName;
|
||||
$("#choiseDatabase").append('<option value="'+dbName+'">'+dbName+'</option>');
|
||||
}
|
||||
$('#choiseDatabase').trigger('chosen:updated');
|
||||
$('#choiseTable').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseDatabase').on('change', function(e){
|
||||
var dbName = $(this).val();
|
||||
var param = {host: pageConfig.host, dbName: dbName};
|
||||
postService("zyplayer-doc-db/doc-db/getTableList", param, function(result){
|
||||
$('#choiseTable').empty();
|
||||
$("#choiseTable").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
var tableName = result.data[i].tableName;
|
||||
$("#choiseTable").append('<option value="'+tableName+'">'+tableName+'</option>');
|
||||
}
|
||||
$('#choiseTable').trigger('chosen:updated');
|
||||
});
|
||||
});
|
||||
$('#choiseTable').on('change', function(e){
|
||||
getTableColumnList();
|
||||
});
|
||||
$('#tableDescShow .icon-edit').click(function(e){
|
||||
var nowDesc = $("#tableDescShow .table-desc").html();
|
||||
$("#tableDescInput").val((nowDesc == "暂无注释") ? "" : nowDesc);
|
||||
$("#tableDescShow").hide();
|
||||
$("#tableDescInput").show().focus();
|
||||
});
|
||||
$("#tableDescInput").blur(function(){
|
||||
$("#tableDescShow").show();
|
||||
$("#tableDescInput").hide();
|
||||
updateTableDesc();
|
||||
});
|
||||
$("#fuzzySearchBtn").click(function(){
|
||||
$('#fuzzySearchModal').modal({moveable:true, backdrop: 'static'});
|
||||
$('#choiseFuzzyHost').trigger('chosen:updated');
|
||||
});
|
||||
$("#exportBtn").click(function(){
|
||||
$('#exportModal').modal({moveable:true, backdrop: 'static'});
|
||||
});
|
||||
$("#doExport").click(function(){
|
||||
var host = $('#choiseExportHost').val();
|
||||
var dbName = $('#choiseExportDatabase').val();
|
||||
var tableNames = "";
|
||||
$('#exportUl li.checked').text(function(index, value){
|
||||
if(tableNames != "") {tableNames += ",";}
|
||||
tableNames += value;
|
||||
});
|
||||
if(isEmpty(host)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(dbName)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(tableNames)){
|
||||
Toast.warn("请输选择需要导出的表");return;
|
||||
}
|
||||
window.open("zyplayer-doc-db/doc-db/exportDatabase?host="+host
|
||||
+"&dbName="+dbName
|
||||
+"&tableNames="+tableNames);
|
||||
});
|
||||
$("#exportUl").on("click", "li", function(){
|
||||
$(this).toggleClass("checked");
|
||||
});
|
||||
$("#showEchartsBtn").click(function(){
|
||||
$("#tableRelationBox").toggleClass("hide");
|
||||
if($("#tableRelationBox").hasClass("hide")){
|
||||
$(this).text("显示表关系图");
|
||||
} else {
|
||||
$(this).text("隐藏表关系图");
|
||||
tableRelationCharts.resize();
|
||||
}
|
||||
});
|
||||
$("#doSearch").click(function(){
|
||||
fuzzySearchByDesc();
|
||||
});
|
||||
$("#tableCloumnsTable tbody").on("click", ".column-desc", function(event){
|
||||
$(this).find("span").hide();
|
||||
$(this).find(".desc-input").show().focus();
|
||||
}).on("blur", ".column-desc", function(event){
|
||||
var newDesc = $(this).find(".desc-input").val();
|
||||
var columnName = $(this).find(".desc-input").attr("column");
|
||||
var oldDesc = $(this).find("span").text();
|
||||
$(this).find("span").show();
|
||||
$(this).find(".desc-input").hide();
|
||||
if(newDesc != oldDesc){
|
||||
var objThis = this;
|
||||
var param = getChoiseDbInfo(3);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
param.newDesc = newDesc;
|
||||
param.columnName = columnName;
|
||||
postService("zyplayer-doc-db/doc-db/updateTableColumnDesc", param, function(msg){
|
||||
$(objThis).find("span").text(newDesc);
|
||||
});
|
||||
}
|
||||
});
|
||||
initData();
|
||||
});
|
||||
|
||||
function initData(){
|
||||
postService("zyplayer-doc-db/doc-db/getDataSourceList", {}, function(result){
|
||||
$('#choiseHost,#choiseFuzzyHost,#choiseExportHost').empty();
|
||||
if(validateResult(result)) {
|
||||
$("#choiseHost,#choiseFuzzyHost,#choiseExportHost").append('<option value=""></option>');
|
||||
for (var i = 0; i < result.data.length; i++) {
|
||||
$("#choiseHost,#choiseFuzzyHost,#choiseExportHost").append('<option value="'+result.data[i]+'">'+result.data[i]+'</option>');
|
||||
}
|
||||
}
|
||||
$('#choiseHost').trigger('chosen:updated');
|
||||
$('#choiseFuzzyHost').trigger('chosen:updated');
|
||||
$('#choiseExportHost').trigger('chosen:updated');
|
||||
});
|
||||
tableRelationCharts = echarts.init(document.getElementById('tableRelationCharts'));
|
||||
tableRelationCharts.setOption(tableRelationOption);
|
||||
tableRelationCharts.on('click', function (params) {
|
||||
//console.log(params.data);
|
||||
var dataIndex = params.data.index;
|
||||
var description = params.data.description;
|
||||
// 用户ID,T:user_info.id
|
||||
// 用户ID,T:order_db.user_info.id
|
||||
var indexOf = description.indexOf("T:");
|
||||
if(indexOf < 0) {
|
||||
Toast.warn("该字段未关联表");
|
||||
return;
|
||||
}
|
||||
var dbAndTable = description.substring(indexOf + 2, description.length);
|
||||
var dbNameChoise, tableNameChoise;
|
||||
var tempSplit = dbAndTable.split(".");
|
||||
if(tempSplit.length == 3) {
|
||||
dbNameChoise = tempSplit[0];
|
||||
tableNameChoise = tempSplit[1];
|
||||
} else if(tempSplit.length == 2) {
|
||||
tableNameChoise = tempSplit[0];
|
||||
} else {
|
||||
tableNameChoise = dbAndTable;
|
||||
}
|
||||
var children = findChildren(tableRelationData, dataIndex);
|
||||
if(children != null && children.children.length <= 0) {
|
||||
// 查询表字段
|
||||
var param = getChoiseDbInfo(2);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
if(isNotEmpty(dbNameChoise)){
|
||||
param.dbName = dbNameChoise;
|
||||
}
|
||||
param.tableName = tableNameChoise;
|
||||
postService("zyplayer-doc-db/doc-db/getTableColumnList", param, function(msg){
|
||||
var columnList = msg.data.columnList
|
||||
if(!columnList || columnList.length <= 0) {
|
||||
Toast.warn("未找到该字段关联的表信息");return;
|
||||
}
|
||||
changetableRelationOption(children, columnList);
|
||||
tableRelationCharts.setOption(tableRelationOption);
|
||||
var height = pageConfig.tableRelationDataIndex * 25;
|
||||
$("#tableRelationBox").css("height", height + "px");
|
||||
tableRelationCharts.resize();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function changetableRelationOption(data, columnList){
|
||||
var childrenArr = [];
|
||||
for (var i = 0; i < columnList.length; i++) {
|
||||
var item = columnList[i];
|
||||
var description = getNotEmptyStr(item.description);
|
||||
var indexOf = description.indexOf("T:");
|
||||
var dbAndTable = "";
|
||||
if(indexOf >= 0) {
|
||||
dbAndTable = " " + description.substring(indexOf + 2, description.length);
|
||||
}
|
||||
childrenArr.push({
|
||||
name: item.name + " " + item.type + dbAndTable,
|
||||
children: [],
|
||||
collapsed: false,
|
||||
index: pageConfig.tableRelationDataIndex++,
|
||||
description: getNotEmptyStr(item.description),
|
||||
length: item.length
|
||||
});
|
||||
}
|
||||
data.children = childrenArr;
|
||||
}
|
||||
|
||||
function findChildren(source, dataIndex){
|
||||
var result = null;
|
||||
echarts.util.each(source.children, function (datum, index) {
|
||||
if(result != null) {
|
||||
return;
|
||||
}
|
||||
if(datum.index == dataIndex) {
|
||||
result = datum;
|
||||
} else if(datum.children && datum.children.length > 0) {
|
||||
result = findChildren(datum, dataIndex);
|
||||
}
|
||||
});
|
||||
if(result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function getTableColumnList(){
|
||||
var param = getChoiseDbInfo(3);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
$("#tableDescShow .icon-edit").hide();
|
||||
$("#tableCloumnsTable tbody").empty();
|
||||
$(".table-name").text(param.tableName);
|
||||
$(".table-desc").text("暂无注释");
|
||||
postService("zyplayer-doc-db/doc-db/getTableColumnList", param, function(msg){
|
||||
var columnList = msg.data.columnList
|
||||
for (var i = 0; i < columnList.length; i++) {
|
||||
var item = columnList[i];
|
||||
//var isidentity = isNull(item.isidentity) ? '-' : (1 == item.isidentity ? '是' : '否');
|
||||
$("#tableCloumnsTable tbody").append(
|
||||
'<tr>'
|
||||
+'<td>' + item.name + '</td>'
|
||||
+'<td>' + (1 == item.isidentity ? '是' : '否') + '</td>'
|
||||
+'<td>' + getNotEmptyStr(item.type) + '</td>'
|
||||
+'<td>' + getNotEmptyStr(item.length) + '</td>'
|
||||
+'<td>' + (1 == item.nullable ? '允许' : '不允许') + '</td>'
|
||||
+'<td>' + ("true" == item.ispramary ? '是' : '否') + '</td>'
|
||||
+'<td class="column-desc"><span>' + getNotEmptyStr(item.description) + '</span>'
|
||||
+'<input type="text" class="desc-input form-control" style="display:none;width: 100%;" column="' + item.name + '" value="' + (isEmpty(item.description)?'':item.description) + '">'
|
||||
+'</tr>'
|
||||
);
|
||||
}
|
||||
var tableInfo = msg.data.tableInfo;
|
||||
if (!!tableInfo && isNotEmpty(tableInfo.description)) {
|
||||
$(".table-desc").text(getNotEmptyStr(tableInfo.description));
|
||||
}
|
||||
$("#tableDescShow .icon-edit").show();
|
||||
pageConfig.tableRelationDataIndex = 0;
|
||||
changetableRelationOption(tableRelationData, columnList);
|
||||
tableRelationData.name = tableInfo.tableName;
|
||||
tableRelationCharts.setOption(tableRelationOption);
|
||||
var height = pageConfig.tableRelationDataIndex * 25;
|
||||
$("#tableRelationBox").css("height", height + "px");
|
||||
tableRelationCharts.resize();
|
||||
});
|
||||
}
|
||||
|
||||
function updateTableDesc(){
|
||||
var tableDescInput = $("#tableDescInput").val();
|
||||
var param = getChoiseDbInfo(3);
|
||||
if(param == null){
|
||||
return;
|
||||
}
|
||||
param.newDesc = tableDescInput;
|
||||
postService("zyplayer-doc-db/doc-db/updateTableDesc", param, function(msg){
|
||||
$("#tableDescShow .table-desc").text(tableDescInput);
|
||||
});
|
||||
}
|
||||
|
||||
function getChoiseDbInfo(type) {
|
||||
var host = $("#choiseHost").val();
|
||||
var dbName = $("#choiseDatabase").val();
|
||||
var tableName = $("#choiseTable").val();
|
||||
if(type >= 1 && isEmpty(host)){
|
||||
Toast.warn("请先选择连接");return null;
|
||||
}
|
||||
if(type >= 2 && isEmpty(dbName)){
|
||||
Toast.warn("请先选择库名");return null;
|
||||
}
|
||||
if(type >= 3 && isEmpty(tableName)){
|
||||
Toast.warn("请先选择表名");return null;
|
||||
}
|
||||
return {host: host, dbName: dbName, tableName: tableName};
|
||||
}
|
||||
|
||||
function fuzzySearchByDesc(){
|
||||
var host = $("#choiseFuzzyHost").val();
|
||||
var dbName = $("#choiseFuzzyDatabase").val();
|
||||
var searchText = $("#searchText").val();
|
||||
if(isEmpty(host)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(dbName)){
|
||||
Toast.warn("请先选择库名");return;
|
||||
}
|
||||
if(isEmpty(searchText)){
|
||||
Toast.warn("请输入模糊匹配的内容");return;
|
||||
}
|
||||
$("#doSearch .icon").removeClass("hidden");
|
||||
var param = {host: host, dbName: dbName, searchText: searchText};
|
||||
postService("zyplayer-doc-db/doc-db/getTableAndColumnBySearch", param, function(msg){
|
||||
$("#fuzzySearchTable tbody").empty();
|
||||
for (var i = 0; i < msg.data.length; i++) {
|
||||
var item = msg.data[i];
|
||||
$("#fuzzySearchTable tbody").append(
|
||||
'<tr>'
|
||||
+'<td>' + item.tableName + '</td>'
|
||||
+'<td>' + item.columnName + '</td>'
|
||||
+'<td>' + getNotEmptyStr(item.description) + '</td>'
|
||||
+'</tr>'
|
||||
);
|
||||
}
|
||||
$('#fuzzySearchModal').modal('ajustPosition', 'fit');
|
||||
}, function(){
|
||||
$("#doSearch .icon").addClass("hidden");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# zyplayer-doc-dubbo
|
||||
|
||||
#### 项目介绍
|
||||
dubbo文档的管理项目,支持文档自动扫描,文档展示和修改,支持参数自动扫描获取,接口在线调试
|
||||
|
||||
#### 软件架构
|
||||
|
||||
后端使用spring boot,前端使用vue、element-ui、JQuery等
|
||||
|
||||
#### 安装教程
|
||||
|
||||
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的配置,访问地址:http://127.0.0.1:8082/zyplayer-doc-manage/doc-dubbo.html
|
||||
|
||||
4. 支持文档查找、文档编辑、在线调试接口
|
||||
|
||||
5. 自动获取参数列表需要指定的类存在,所以请在 pom.xml -> dependencies 最后加上服务所在的包,后端才能通过Class.forName("xx");来找到参数列表,减少录入成本
|
||||
|
||||
6. 数组或List参数,调试参数录入格式例:[1,2] ,后端通过JSON工具转成指定类型,有不支持的类型时欢迎反馈
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本项目
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-dubbo</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>zyplayer-doc-dubbo</name>
|
||||
|
||||
<description>dubbo文档工具</description>
|
||||
<url>https://gitee.com/zyplayer/zyplayer-doc/zyplayer-doc-dubbo</url>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>zyplayer</id>
|
||||
<name>暮光:城中城</name>
|
||||
<email>806783409@qq.com</email>
|
||||
<roles>
|
||||
<role>Java Development Engineer</role>
|
||||
</roles>
|
||||
<timezone>2018-05-22 16:06:06</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.2.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<!-- 打包跳过单元测试 -->
|
||||
<skipTests>true</skipTests>
|
||||
<destDir>${project.build.outputDirectory}/META-INF/resources/webjars/${project.artifactId}/${project.version}</destDir>
|
||||
<zyplayer.doc.version>1.0.1</zyplayer.doc.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.44</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-http</artifactId>
|
||||
<version>4.1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
<version>${zyplayer.doc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-recipes</artifactId>
|
||||
<version>2.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<!-- 业务包 -->
|
||||
</dependencies>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</connection>
|
||||
<developerConnection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</developerConnection>
|
||||
<url>git@git.oschina.net:zyplayer/zyplayer-doc.git</url>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<targetPath>META-INF/resources/</targetPath>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/webapp</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<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,452 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.controller;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.dubbo.controller.param.DubboRequestParam;
|
||||
import com.zyplayer.doc.dubbo.controller.vo.DubboInfoVo;
|
||||
import com.zyplayer.doc.dubbo.framework.bean.DubboDocInfo;
|
||||
import com.zyplayer.doc.dubbo.framework.bean.DubboInfo;
|
||||
import com.zyplayer.doc.dubbo.framework.bean.NacosDubboInfo;
|
||||
import com.zyplayer.doc.dubbo.framework.bean.ReferenceConfigHolder;
|
||||
import com.zyplayer.doc.dubbo.framework.constant.StorageKeys;
|
||||
import com.zyplayer.doc.dubbo.framework.service.MgDubboStorageService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.curator.RetryPolicy;
|
||||
import org.apache.curator.framework.CuratorFramework;
|
||||
import org.apache.curator.framework.CuratorFrameworkFactory;
|
||||
import org.apache.curator.retry.ExponentialBackoffRetry;
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.UrlUtils;
|
||||
import org.apache.dubbo.metadata.definition.model.FullServiceDefinition;
|
||||
import org.apache.dubbo.metadata.definition.model.MethodDefinition;
|
||||
import org.apache.dubbo.metadata.identifier.MetadataIdentifier;
|
||||
import org.apache.dubbo.rpc.service.GenericService;
|
||||
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 java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/zyplayer-doc-dubbo/doc-dubbo")
|
||||
public class DubboController {
|
||||
private static Logger logger = LoggerFactory.getLogger(DubboController.class);
|
||||
|
||||
private final static String DEFAULT_ROOT = "dubbo";
|
||||
private final static String METADATA_NODE_NAME = "service.data";
|
||||
private String root;
|
||||
|
||||
@Value("${zyplayer.doc.dubbo.zookeeper.url:}")
|
||||
private String serviceZookeeperUrl;
|
||||
@Value("${zyplayer.doc.dubbo.zookeeper.metadata-url:}")
|
||||
private String metadataZookeeperUrl;
|
||||
@Value("${zyplayer.doc.dubbo.nacos.url:}")
|
||||
private String nacosUrl;
|
||||
@Value("${zyplayer.doc.dubbo.nacos.service:}")
|
||||
private String nacosService;
|
||||
@Resource
|
||||
private MgDubboStorageService mgDubboStorageService;
|
||||
|
||||
private CuratorFramework serverClient;
|
||||
private CuratorFramework metadataClient;
|
||||
|
||||
private void initServerClient() {
|
||||
if (serverClient == null && StringUtils.isNotBlank(serviceZookeeperUrl)) {
|
||||
synchronized (DEFAULT_ROOT) {
|
||||
if (serverClient == null) {
|
||||
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
|
||||
serverClient = CuratorFrameworkFactory.newClient(serviceZookeeperUrl, retryPolicy);
|
||||
serverClient.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initMetadataClient() {
|
||||
if (metadataClient == null && StringUtils.isNotBlank(metadataZookeeperUrl)) {
|
||||
synchronized (DEFAULT_ROOT) {
|
||||
if (metadataClient == null) {
|
||||
URL url = UrlUtils.parseURL(metadataZookeeperUrl, Collections.emptyMap());
|
||||
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
|
||||
if (!group.startsWith(Constants.PATH_SEPARATOR)) {
|
||||
group = Constants.PATH_SEPARATOR + group;
|
||||
}
|
||||
this.root = group;
|
||||
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
|
||||
metadataClient = CuratorFrameworkFactory.newClient(metadataZookeeperUrl, retryPolicy);
|
||||
metadataClient.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新获取所有的服务列表
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
**/
|
||||
@PostMapping(value = "/reloadService")
|
||||
public DocResponseJson loadService() throws Exception {
|
||||
List<DubboInfo> providerList;
|
||||
if (StringUtils.isBlank(serviceZookeeperUrl)) {
|
||||
if (StringUtils.isBlank(nacosUrl) || StringUtils.isBlank(nacosService)) {
|
||||
return DocResponseJson.warn("zyplayer.doc.dubbo.zookeeper.url、zyplayer.doc.dubbo.nacos.url 参数均未配置");
|
||||
}
|
||||
logger.info("zookeeper参数未配置,使用nacos配置");
|
||||
providerList = this.getDubboInfoByNacos();
|
||||
} else {
|
||||
providerList = this.getDubboInfoByZookeeper();
|
||||
}
|
||||
mgDubboStorageService.put(StorageKeys.DUBBO_SERVICE_LIST, JSON.toJSONString(providerList));
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求执行服务
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
**/
|
||||
@PostMapping(value = "/request")
|
||||
public DocResponseJson request(DubboRequestParam param) {
|
||||
DubboInfo.DubboNodeInfo dubboNodeInfo = new DubboInfo.DubboNodeInfo();
|
||||
dubboNodeInfo.setIp(param.getIp());
|
||||
dubboNodeInfo.setPort(param.getPort());
|
||||
dubboNodeInfo.setInterfaceX(param.getService());
|
||||
String paramTypeStr = Optional.ofNullable(param.getParamTypes()).orElse("");
|
||||
String paramsStr = Optional.ofNullable(param.getParams()).orElse("");
|
||||
List<String> typeList = JSON.parseArray(paramTypeStr, String.class);
|
||||
List<String> paramList = JSON.parseArray(paramsStr, String.class);
|
||||
List<String> queryTypeList = new LinkedList<>();
|
||||
List<Object> queryParamList = new LinkedList<>();
|
||||
for (int i = 0; i < paramList.size(); i++) {
|
||||
String typeStr = typeList.get(i);
|
||||
String paramStr = paramList.get(i);
|
||||
try {
|
||||
if (typeStr.endsWith("[]")) {
|
||||
String type = typeStr.substring(0, typeStr.length() - 2);
|
||||
Class<?> aClass = Class.forName(type);
|
||||
List<?> objects = JSON.parseArray(paramStr, aClass);
|
||||
queryTypeList.add(typeStr);
|
||||
queryParamList.add(objects);
|
||||
} else if (typeStr.matches("java\\.util\\.List<.+>")) {
|
||||
Pattern pattern = Pattern.compile("java\\.util\\.List<(.+)>");
|
||||
Matcher matcher = pattern.matcher(typeStr);
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
Class<?> aClass = Class.forName(group);
|
||||
List<?> objects = JSON.parseArray(paramStr, aClass);
|
||||
queryParamList.add(objects);
|
||||
queryTypeList.add("java.util.List");
|
||||
}
|
||||
} else {
|
||||
Class<?> aClass = Class.forName(typeStr);
|
||||
Object object = JSON.parseObject(paramStr, aClass);
|
||||
queryParamList.add(object);
|
||||
queryTypeList.add(typeStr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 未找到对应类型,请手动引入项目包
|
||||
logger.warn("未找到对应类型,请手动引入项目包:{}", typeStr);
|
||||
queryParamList.add(paramStr);
|
||||
queryTypeList.add(typeStr);
|
||||
}
|
||||
}
|
||||
GenericService bean = ReferenceConfigHolder.getBean(dubboNodeInfo);
|
||||
try {
|
||||
Object result = bean.$invoke(param.getMethod(), queryTypeList.toArray(new String[]{}), queryParamList.toArray());
|
||||
return DocResponseJson.ok(result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocResponseJson.warn("请求失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档列表
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
**/
|
||||
@PostMapping(value = "/getDocList")
|
||||
public DocResponseJson getDocList() {
|
||||
String dubboServiceList = mgDubboStorageService.get(StorageKeys.DUBBO_SERVICE_LIST);
|
||||
String dubboServiceDoc = mgDubboStorageService.get(StorageKeys.DUBBO_SERVICE_DOC);
|
||||
if (StringUtils.isBlank(dubboServiceList)) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
DubboInfoVo dubboInfoVo = new DubboInfoVo();
|
||||
List<DubboInfo> providerList = JSON.parseArray(dubboServiceList, DubboInfo.class);
|
||||
dubboInfoVo.setServerList(providerList);
|
||||
if (StringUtils.isNotBlank(dubboServiceDoc)) {
|
||||
List<DubboDocInfo> docInfoList = JSON.parseArray(dubboServiceDoc, DubboDocInfo.class);
|
||||
Map<String, DubboDocInfo> docInfoMap = docInfoList.stream().collect(Collectors.toMap(DubboDocInfo::getFunction, val -> val));
|
||||
dubboInfoVo.setDocMap(docInfoMap);
|
||||
}
|
||||
return DocResponseJson.ok(dubboInfoVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档详情,依据类名生成
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
**/
|
||||
@PostMapping(value = "/findDocInfo")
|
||||
public DocResponseJson findDocInfo(DubboRequestParam param) {
|
||||
DubboDocInfo definition = this.getDefinitionByJar(param);
|
||||
if (definition == null) {
|
||||
definition = this.getDefinitionByMetadata(param);
|
||||
}
|
||||
if (definition == null) {
|
||||
return DocResponseJson.warn("未找到指定类,请引入相关包或开启metadata,类名:" + param.getService());
|
||||
}
|
||||
Map<String, DubboDocInfo> docInfoMap = new HashMap<>();
|
||||
String dubboServiceDoc = mgDubboStorageService.get(StorageKeys.DUBBO_SERVICE_DOC);
|
||||
if (StringUtils.isNotBlank(dubboServiceDoc)) {
|
||||
List<DubboDocInfo> docInfoList = JSON.parseArray(dubboServiceDoc, DubboDocInfo.class);
|
||||
docInfoMap = docInfoList.stream().collect(Collectors.toMap(DubboDocInfo::getFunction, val -> val));
|
||||
}
|
||||
String function = param.getService() + "." + param.getMethod();
|
||||
DubboDocInfo dubboDocInfo = docInfoMap.get(function);
|
||||
if (dubboDocInfo == null) {
|
||||
dubboDocInfo = new DubboDocInfo();
|
||||
dubboDocInfo.setParams(definition.getParams());
|
||||
dubboDocInfo.setFunction(function);
|
||||
dubboDocInfo.setVersion(1);
|
||||
dubboDocInfo.setResultType(definition.getResultType());
|
||||
dubboDocInfo.setService(param.getService());
|
||||
dubboDocInfo.setMethod(param.getMethod());
|
||||
docInfoMap.put(function, dubboDocInfo);
|
||||
List<DubboDocInfo> docInfoList = new ArrayList<>(docInfoMap.values());
|
||||
mgDubboStorageService.put(StorageKeys.DUBBO_SERVICE_DOC, JSON.toJSONString(docInfoList));
|
||||
}
|
||||
return DocResponseJson.ok(dubboDocInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文档
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
**/
|
||||
@PostMapping(value = "/saveDoc")
|
||||
public DocResponseJson saveDoc(DubboDocInfo param, String paramsJson) {
|
||||
String dubboServiceDoc = mgDubboStorageService.get(StorageKeys.DUBBO_SERVICE_DOC);
|
||||
Map<String, DubboDocInfo> docInfoMap = new HashMap<>();
|
||||
if (StringUtils.isNotBlank(dubboServiceDoc)) {
|
||||
List<DubboDocInfo> docInfoList = JSON.parseArray(dubboServiceDoc, DubboDocInfo.class);
|
||||
docInfoMap = docInfoList.stream().collect(Collectors.toMap(DubboDocInfo::getFunction, val -> val));
|
||||
}
|
||||
String function = param.getService() + "." + param.getMethod();
|
||||
DubboDocInfo dubboDocInfo = docInfoMap.get(function);
|
||||
if (dubboDocInfo != null) {
|
||||
Integer newVersion = Optional.ofNullable(param.getVersion()).orElse(1);
|
||||
Integer oldVersion = Optional.ofNullable(dubboDocInfo.getVersion()).orElse(1);
|
||||
if (oldVersion > newVersion) {
|
||||
return DocResponseJson.warn("已有用户在您之前修改过文档,请刷新后再修改");
|
||||
}
|
||||
param.setVersion(oldVersion + 1);
|
||||
if (StringUtils.isEmpty(param.getExplain())) {
|
||||
param.setExplain(dubboDocInfo.getExplain());
|
||||
}
|
||||
if (StringUtils.isEmpty(param.getResult())) {
|
||||
param.setResult(dubboDocInfo.getResult());
|
||||
}
|
||||
param.setParams(dubboDocInfo.getParams());
|
||||
} else {
|
||||
param.setVersion(1);
|
||||
}
|
||||
if (StringUtils.isNotBlank(paramsJson)) {
|
||||
param.setParams(JSON.parseArray(paramsJson, DubboDocInfo.DubboDocParam.class));
|
||||
}
|
||||
param.setFunction(function);
|
||||
docInfoMap.put(function, param);
|
||||
List<DubboDocInfo> docInfoList = new ArrayList<>(docInfoMap.values());
|
||||
mgDubboStorageService.put(StorageKeys.DUBBO_SERVICE_DOC, JSON.toJSONString(docInfoList));
|
||||
return DocResponseJson.ok(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过nacos方式获取所有服务
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
**/
|
||||
private List<DubboInfo> getDubboInfoByNacos() {
|
||||
List<DubboInfo> providerList = new LinkedList<>();
|
||||
String[] nacosServiceArr = nacosService.split(";");
|
||||
for (String service : nacosServiceArr) {
|
||||
String resultStr = HttpUtil.get(nacosUrl + "/v1/ns/instance/list?serviceName=providers:" + service);
|
||||
NacosDubboInfo dubboInstance = JSON.parseObject(resultStr, NacosDubboInfo.class);
|
||||
List<NacosDubboInfo.HostsBean> hosts = dubboInstance.getHosts();
|
||||
DubboInfo dubboInfo = new DubboInfo();
|
||||
List<DubboInfo.DubboNodeInfo> nodeList = new LinkedList<>();
|
||||
for (NacosDubboInfo.HostsBean host : hosts) {
|
||||
DubboInfo.DubboNodeInfo dubboNodeInfo = new DubboInfo.DubboNodeInfo();
|
||||
dubboNodeInfo.setIp(host.getIp());
|
||||
dubboNodeInfo.setPort(host.getPort());
|
||||
dubboNodeInfo.setInterfaceX(host.getMetadata().getInterfaceX());
|
||||
dubboNodeInfo.setMethods(host.getMetadata().getMethods().split(","));
|
||||
dubboNodeInfo.setApplication(host.getMetadata().getApplication());
|
||||
nodeList.add(dubboNodeInfo);
|
||||
}
|
||||
dubboInfo.setInterfaceX(service);
|
||||
dubboInfo.setNodeList(nodeList);
|
||||
providerList.add(dubboInfo);
|
||||
}
|
||||
return providerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过Zookeeper方式获取所有服务
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
**/
|
||||
private List<DubboInfo> getDubboInfoByZookeeper() throws Exception {
|
||||
this.initServerClient();
|
||||
List<String> dubboList = serverClient.getChildren().forPath("/dubbo");
|
||||
if (dubboList == null || dubboList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<DubboInfo> providerList = new LinkedList<>();
|
||||
for (String dubboStr : dubboList) {
|
||||
String path = "/dubbo/" + dubboStr + "/providers";
|
||||
if (serverClient.checkExists().forPath(path) == null) {
|
||||
continue;
|
||||
}
|
||||
List<String> providers = serverClient.getChildren().forPath(path);
|
||||
List<DubboInfo.DubboNodeInfo> nodeList = providers.stream().map(val -> {
|
||||
String tempStr = val;
|
||||
try {
|
||||
tempStr = URLDecoder.decode(val, "utf-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// IP和端口
|
||||
String ipPort = tempStr.substring(tempStr.indexOf("://") + 3);
|
||||
ipPort = ipPort.substring(0, ipPort.indexOf("/"));
|
||||
String[] ipPortArr = ipPort.split(":");
|
||||
// 参数
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
String params = tempStr.substring(tempStr.indexOf("?"));
|
||||
String[] paramsArr = params.split("&");
|
||||
for (String param : paramsArr) {
|
||||
String[] split = param.split("=");
|
||||
paramMap.put(split[0], split[1]);
|
||||
}
|
||||
DubboInfo.DubboNodeInfo dubboNodeInfo = new DubboInfo.DubboNodeInfo();
|
||||
dubboNodeInfo.setIp(ipPortArr[0]);
|
||||
dubboNodeInfo.setPort(NumberUtils.toInt(ipPortArr[1]));
|
||||
dubboNodeInfo.setInterfaceX(paramMap.get("interface"));
|
||||
dubboNodeInfo.setMethods(paramMap.get("methods").split(","));
|
||||
dubboNodeInfo.setApplication(paramMap.get("application"));
|
||||
return dubboNodeInfo;
|
||||
}).collect(Collectors.toList());
|
||||
DubboInfo dubboInfo = new DubboInfo();
|
||||
dubboInfo.setInterfaceX(dubboStr);
|
||||
dubboInfo.setNodeList(nodeList);
|
||||
providerList.add(dubboInfo);
|
||||
}
|
||||
return providerList;
|
||||
}
|
||||
|
||||
private DubboDocInfo getDefinitionByMetadata(DubboRequestParam param) {
|
||||
try {
|
||||
this.initMetadataClient();
|
||||
String path = getNodePath(param.getService(), null, null, param.getApplication());
|
||||
if (metadataClient.checkExists().forPath(path) == null) {
|
||||
return null;
|
||||
}
|
||||
String resultType = null;
|
||||
String metadata = new String(metadataClient.getData().forPath(path));
|
||||
FullServiceDefinition definition = JSON.parseObject(metadata, FullServiceDefinition.class);
|
||||
List<DubboDocInfo.DubboDocParam> paramList = new LinkedList<>();
|
||||
for (MethodDefinition method : definition.getMethods()) {
|
||||
if (Objects.equals(method.getName(), param.getMethod())) {
|
||||
String[] parameterTypes = method.getParameterTypes();
|
||||
resultType = method.getReturnType();
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
DubboDocInfo.DubboDocParam docParam = new DubboDocInfo.DubboDocParam();
|
||||
docParam.setParamType(parameterTypes[i]);
|
||||
docParam.setParamName("arg" + i);
|
||||
paramList.add(docParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
DubboDocInfo dubboDocInfo = new DubboDocInfo();
|
||||
dubboDocInfo.setParams(paramList);
|
||||
dubboDocInfo.setResultType(resultType);
|
||||
return dubboDocInfo;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DubboDocInfo getDefinitionByJar(DubboRequestParam param) {
|
||||
String resultType = null;
|
||||
List<DubboDocInfo.DubboDocParam> paramList = new LinkedList<>();
|
||||
try {
|
||||
Class clazz = Class.forName(param.getService());
|
||||
Method[] methods = clazz.getMethods();
|
||||
for (Method method : methods) {
|
||||
String methodName = method.getName();
|
||||
if (methodName.equals(param.getMethod())) {
|
||||
resultType = method.getGenericReturnType().getTypeName();
|
||||
Type[] parameterTypes = method.getGenericParameterTypes();
|
||||
Parameter[] parameters = method.getParameters();
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
DubboDocInfo.DubboDocParam docParam = new DubboDocInfo.DubboDocParam();
|
||||
docParam.setParamName(parameters[i].getName());
|
||||
docParam.setParamType(parameterTypes[i].getTypeName());
|
||||
paramList.add(docParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
DubboDocInfo dubboDocInfo = new DubboDocInfo();
|
||||
dubboDocInfo.setParams(paramList);
|
||||
dubboDocInfo.setResultType(resultType);
|
||||
return dubboDocInfo;
|
||||
}
|
||||
|
||||
String toRootDir() {
|
||||
if (root.equals(Constants.PATH_SEPARATOR)) {
|
||||
return root;
|
||||
}
|
||||
return root + Constants.PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
String getNodePath(String serviceInterface, String version, String group, String application) {
|
||||
MetadataIdentifier metadataIdentifier = new MetadataIdentifier(serviceInterface, version, group, Constants.PROVIDER_SIDE, application);
|
||||
return toRootDir() + metadataIdentifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.PATH) + Constants.PATH_SEPARATOR + METADATA_NODE_NAME;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.controller.param;
|
||||
|
||||
/**
|
||||
* 请求参数对象
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
*/
|
||||
public class DubboRequestParam {
|
||||
private String application;
|
||||
private String service;
|
||||
private String method;
|
||||
private String ip;
|
||||
private Integer port;
|
||||
private String paramTypes;
|
||||
private String params;
|
||||
|
||||
public String getParamTypes() {
|
||||
return paramTypes;
|
||||
}
|
||||
|
||||
public void setParamTypes(String paramTypes) {
|
||||
this.paramTypes = paramTypes;
|
||||
}
|
||||
|
||||
public String getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(String service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public String getApplication() {
|
||||
return application;
|
||||
}
|
||||
|
||||
public void setApplication(String application) {
|
||||
this.application = application;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.controller.vo;
|
||||
|
||||
import com.zyplayer.doc.dubbo.framework.bean.DubboDocInfo;
|
||||
import com.zyplayer.doc.dubbo.framework.bean.DubboInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年1月10日
|
||||
**/
|
||||
public class DubboInfoVo {
|
||||
private List<DubboInfo> serverList;
|
||||
private Map<String, DubboDocInfo> docMap;
|
||||
|
||||
public List<DubboInfo> getServerList() {
|
||||
return serverList;
|
||||
}
|
||||
|
||||
public void setServerList(List<DubboInfo> serverList) {
|
||||
this.serverList = serverList;
|
||||
}
|
||||
|
||||
public Map<String, DubboDocInfo> getDocMap() {
|
||||
return docMap;
|
||||
}
|
||||
|
||||
public void setDocMap(Map<String, DubboDocInfo> docMap) {
|
||||
this.docMap = docMap;
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请求参数对象
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
*/
|
||||
public class DubboDocInfo {
|
||||
private String service;
|
||||
private String method;
|
||||
private String function;
|
||||
private String explain;
|
||||
private String result;
|
||||
private String resultType;
|
||||
private Integer version;
|
||||
private List<DubboDocParam> params;
|
||||
|
||||
public static class DubboDocParam {
|
||||
private String paramName;
|
||||
private String paramType;
|
||||
private String paramDesc;
|
||||
private Object paramValue;
|
||||
private Integer required;
|
||||
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public void setParamName(String paramName) {
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
public String getParamType() {
|
||||
return paramType;
|
||||
}
|
||||
|
||||
public void setParamType(String paramType) {
|
||||
this.paramType = paramType;
|
||||
}
|
||||
|
||||
public String getParamDesc() {
|
||||
return paramDesc;
|
||||
}
|
||||
|
||||
public void setParamDesc(String paramDesc) {
|
||||
this.paramDesc = paramDesc;
|
||||
}
|
||||
|
||||
public Object getParamValue() {
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
public void setParamValue(Object paramValue) {
|
||||
this.paramValue = paramValue;
|
||||
}
|
||||
|
||||
public Integer getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(Integer required) {
|
||||
this.required = required;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
public String getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(String service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getExplain() {
|
||||
return explain;
|
||||
}
|
||||
|
||||
public void setExplain(String explain) {
|
||||
this.explain = explain;
|
||||
}
|
||||
|
||||
public List<DubboDocParam> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(List<DubboDocParam> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public String getFunction() {
|
||||
return function;
|
||||
}
|
||||
|
||||
public void setFunction(String function) {
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getResultType() {
|
||||
return resultType;
|
||||
}
|
||||
|
||||
public void setResultType(String resultType) {
|
||||
this.resultType = resultType;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年1月10日
|
||||
**/
|
||||
public class DubboInfo {
|
||||
@JSONField(name = "interface")
|
||||
private String interfaceX;
|
||||
private List<DubboNodeInfo> nodeList;
|
||||
|
||||
public static class DubboNodeInfo {
|
||||
private Integer port;
|
||||
private String ip;
|
||||
@JSONField(name = "interface")
|
||||
private String interfaceX;
|
||||
private String[] methods;
|
||||
private String application;
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getInterfaceX() {
|
||||
return interfaceX;
|
||||
}
|
||||
|
||||
public void setInterfaceX(String interfaceX) {
|
||||
this.interfaceX = interfaceX;
|
||||
}
|
||||
|
||||
public String[] getMethods() {
|
||||
return methods;
|
||||
}
|
||||
|
||||
public void setMethods(String[] methods) {
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
public String getApplication() {
|
||||
return application;
|
||||
}
|
||||
|
||||
public void setApplication(String application) {
|
||||
this.application = application;
|
||||
}
|
||||
}
|
||||
|
||||
public List<DubboNodeInfo> getNodeList() {
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
public void setNodeList(List<DubboNodeInfo> nodeList) {
|
||||
this.nodeList = nodeList;
|
||||
}
|
||||
|
||||
public String getInterfaceX() {
|
||||
return interfaceX;
|
||||
}
|
||||
|
||||
public void setInterfaceX(String interfaceX) {
|
||||
this.interfaceX = interfaceX;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,333 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年1月10日
|
||||
**/
|
||||
public class NacosDubboInfo {
|
||||
|
||||
/**
|
||||
* metadata : {}
|
||||
* dom : providers:com.zyplayer.dubbo.service.UserService
|
||||
* cacheMillis : 10000
|
||||
* useSpecifiedURL : false
|
||||
* hosts : [{"valid":true,"marked":false,"metadata":{"side":"provider","protocol":"dubbo","application":"dubbo-provider","methods":"getUserDetail,getUserList","dubbo":"2.0.2","pid":"8164","interface":"com.zyplayer.dubbo.service.UserService","category":"providers","generic":"false","anyhost":"true","bean.name":"ServiceBean:com.zyplayer.dubbo.service.UserService","timestamp":"1549953970871"},"instanceId":"127.0.0.1#22223#DEFAULT#providers:com.zyplayer.dubbo.service.UserService","port":22223,"ip":"127.0.0.1","clusterName":"DEFAULT","weight":1,"serviceName":"providers:com.zyplayer.dubbo.service.UserService","enabled":true}]
|
||||
* checksum : 2489ae2874f2f490caf7d6195192d6c71549954548862
|
||||
* lastRefTime : 1549954548862
|
||||
* env :
|
||||
* clusters :
|
||||
*/
|
||||
|
||||
private MetadataBean metadata;
|
||||
private String dom;
|
||||
private int cacheMillis;
|
||||
private boolean useSpecifiedURL;
|
||||
private String checksum;
|
||||
private long lastRefTime;
|
||||
private String env;
|
||||
private String clusters;
|
||||
private List<HostsBean> hosts;
|
||||
|
||||
public MetadataBean getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(MetadataBean metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public String getDom() {
|
||||
return dom;
|
||||
}
|
||||
|
||||
public void setDom(String dom) {
|
||||
this.dom = dom;
|
||||
}
|
||||
|
||||
public int getCacheMillis() {
|
||||
return cacheMillis;
|
||||
}
|
||||
|
||||
public void setCacheMillis(int cacheMillis) {
|
||||
this.cacheMillis = cacheMillis;
|
||||
}
|
||||
|
||||
public boolean isUseSpecifiedURL() {
|
||||
return useSpecifiedURL;
|
||||
}
|
||||
|
||||
public void setUseSpecifiedURL(boolean useSpecifiedURL) {
|
||||
this.useSpecifiedURL = useSpecifiedURL;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public void setChecksum(String checksum) {
|
||||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public long getLastRefTime() {
|
||||
return lastRefTime;
|
||||
}
|
||||
|
||||
public void setLastRefTime(long lastRefTime) {
|
||||
this.lastRefTime = lastRefTime;
|
||||
}
|
||||
|
||||
public String getEnv() {
|
||||
return env;
|
||||
}
|
||||
|
||||
public void setEnv(String env) {
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
public String getClusters() {
|
||||
return clusters;
|
||||
}
|
||||
|
||||
public void setClusters(String clusters) {
|
||||
this.clusters = clusters;
|
||||
}
|
||||
|
||||
public List<HostsBean> getHosts() {
|
||||
return hosts;
|
||||
}
|
||||
|
||||
public void setHosts(List<HostsBean> hosts) {
|
||||
this.hosts = hosts;
|
||||
}
|
||||
|
||||
public static class MetadataBean {
|
||||
}
|
||||
|
||||
public static class HostsBean {
|
||||
/**
|
||||
* valid : true
|
||||
* marked : false
|
||||
* metadata : {"side":"provider","protocol":"dubbo","application":"dubbo-provider","methods":"getUserDetail,getUserList","dubbo":"2.0.2","pid":"8164","interface":"com.zyplayer.dubbo.service.UserService","category":"providers","generic":"false","anyhost":"true","bean.name":"ServiceBean:com.zyplayer.dubbo.service.UserService","timestamp":"1549953970871"}
|
||||
* instanceId : 127.0.0.1#22223#DEFAULT#providers:com.zyplayer.dubbo.service.UserService
|
||||
* port : 22223
|
||||
* ip : 127.0.0.1
|
||||
* clusterName : DEFAULT
|
||||
* weight : 1
|
||||
* serviceName : providers:com.zyplayer.dubbo.service.UserService
|
||||
* enabled : true
|
||||
*/
|
||||
|
||||
private boolean valid;
|
||||
private boolean marked;
|
||||
private MetadataBeanX metadata;
|
||||
private String instanceId;
|
||||
private int port;
|
||||
private String ip;
|
||||
private String clusterName;
|
||||
private int weight;
|
||||
private String serviceName;
|
||||
private boolean enabled;
|
||||
|
||||
public boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void setValid(boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
|
||||
public boolean isMarked() {
|
||||
return marked;
|
||||
}
|
||||
|
||||
public void setMarked(boolean marked) {
|
||||
this.marked = marked;
|
||||
}
|
||||
|
||||
public MetadataBeanX getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(MetadataBeanX metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public String getInstanceId() {
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
public void setInstanceId(String instanceId) {
|
||||
this.instanceId = instanceId;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName;
|
||||
}
|
||||
|
||||
public void setClusterName(String clusterName) {
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(int weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public static class MetadataBeanX {
|
||||
/**
|
||||
* side : provider
|
||||
* protocol : dubbo
|
||||
* application : dubbo-provider
|
||||
* methods : getUserDetail,getUserList
|
||||
* dubbo : 2.0.2
|
||||
* pid : 8164
|
||||
* interface : com.zyplayer.dubbo.service.UserService
|
||||
* category : providers
|
||||
* generic : false
|
||||
* anyhost : true
|
||||
* bean.name : ServiceBean:com.zyplayer.dubbo.service.UserService
|
||||
* timestamp : 1549953970871
|
||||
*/
|
||||
|
||||
private String side;
|
||||
private String protocol;
|
||||
private String application;
|
||||
private String methods;
|
||||
private String dubbo;
|
||||
private String pid;
|
||||
@JSONField(name = "interface")
|
||||
private String interfaceX;
|
||||
private String category;
|
||||
private String generic;
|
||||
private String anyhost;
|
||||
private String timestamp;
|
||||
|
||||
public String getSide() {
|
||||
return side;
|
||||
}
|
||||
|
||||
public void setSide(String side) {
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public String getApplication() {
|
||||
return application;
|
||||
}
|
||||
|
||||
public void setApplication(String application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public String getMethods() {
|
||||
return methods;
|
||||
}
|
||||
|
||||
public void setMethods(String methods) {
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
public String getDubbo() {
|
||||
return dubbo;
|
||||
}
|
||||
|
||||
public void setDubbo(String dubbo) {
|
||||
this.dubbo = dubbo;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getInterfaceX() {
|
||||
return interfaceX;
|
||||
}
|
||||
|
||||
public void setInterfaceX(String interfaceX) {
|
||||
this.interfaceX = interfaceX;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getGeneric() {
|
||||
return generic;
|
||||
}
|
||||
|
||||
public void setGeneric(String generic) {
|
||||
this.generic = generic;
|
||||
}
|
||||
|
||||
public String getAnyhost() {
|
||||
return anyhost;
|
||||
}
|
||||
|
||||
public void setAnyhost(String anyhost) {
|
||||
this.anyhost = anyhost;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.bean;
|
||||
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.ReferenceConfig;
|
||||
import org.apache.dubbo.rpc.service.GenericService;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年1月10日
|
||||
**/
|
||||
public class ReferenceConfigHolder {
|
||||
private static Map<String, ReferenceConfig> referenceConfigMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static GenericService getBean(DubboInfo.DubboNodeInfo dubboNodeInfo) {
|
||||
String name = dubboNodeInfo.getInterfaceX();
|
||||
String url = "dubbo://" + dubboNodeInfo.getIp() + ":" + dubboNodeInfo.getPort() + "/" + dubboNodeInfo.getInterfaceX();
|
||||
ReferenceConfig referenceConfig = referenceConfigMap.get(url);
|
||||
if (referenceConfig == null) {
|
||||
ApplicationConfig application = new ApplicationConfig();
|
||||
application.setName("zyplayer-doc-consume");
|
||||
// 参考:http://dubbo.apache.org/zh-cn/docs/user/configuration/api.html
|
||||
// 此实例很重,封装了与注册中心的连接以及与提供者的连接,请自行缓存,否则可能造成内存和连接泄漏
|
||||
referenceConfig = new ReferenceConfig<>();
|
||||
// 如果点对点直连,可以用reference.setUrl()指定目标地址,设置url后将绕过注册中心,
|
||||
// 其中,协议对应provider.setProtocol()的值,端口对应provider.setPort()的值,
|
||||
// 路径对应service.setPath()的值,如果未设置path,缺省path为接口名
|
||||
referenceConfig.setUrl(url);
|
||||
referenceConfig.setInterface(name.substring(name.lastIndexOf(".") + 1));
|
||||
referenceConfig.setGeneric(true);
|
||||
referenceConfig.setApplication(application);
|
||||
referenceConfigMap.put(url, referenceConfig);
|
||||
}
|
||||
// 本项目没有dubbo里面申明的类,快放弃时看源码发现可以设置generic返回一个GenericService对象,通过$invoke去操作具体方法,感觉又打开了一扇大门
|
||||
// 本项目选择的不入侵的方式管理文档,所以文档里面就必须手动加参数,写文档那些了
|
||||
return (GenericService) referenceConfig.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {
|
||||
"com.zyplayer.doc.dubbo",
|
||||
})
|
||||
public @interface EnableDocDubbo {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.constant;
|
||||
|
||||
/**
|
||||
* 存储数据的KEY常量类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月21日
|
||||
*/
|
||||
public class StorageKeys {
|
||||
// 所有文档地址
|
||||
public static final String DUBBO_SERVICE_DOC = "dubbo-service-doc";
|
||||
public static final String DUBBO_SERVICE_LIST = "dubbo-service-list";
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class MgDubboStorage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String key;
|
||||
|
||||
private String value;
|
||||
|
||||
public MgDubboStorage() {
|
||||
|
||||
}
|
||||
|
||||
public MgDubboStorage(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.zyplayer.doc.dubbo.framework.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 实现此类才能使用服务器端的存贮功能
|
||||
* dubbo的文档需要手动写的,比较重要,所以重起一个存储service,实现类尽量操作另外的库
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月19日
|
||||
*/
|
||||
public interface MgDubboStorageService {
|
||||
|
||||
/**
|
||||
* 获取存储的值
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月19日
|
||||
* @param key 参数
|
||||
* @return 值
|
||||
*/
|
||||
String get(String key);
|
||||
|
||||
/**
|
||||
* 模糊获取存储的值
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月19日
|
||||
* @param key 参数
|
||||
* @param value 值
|
||||
* @return 值
|
||||
*/
|
||||
List<MgDubboStorage> like(String key, String value);
|
||||
|
||||
/**
|
||||
* 存储数据
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月19日
|
||||
* @param key 参数
|
||||
* @param value 值
|
||||
*/
|
||||
void put(String key, String value);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月19日
|
||||
* @param key 参数
|
||||
*/
|
||||
void remove(String key);
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
一些地址:
|
||||
http://127.0.0.1:8082/zyplayer-doc-manage/zyplayer-doc-dubbo/doc-dubbo/getList
|
||||
http://127.0.0.1.56:8848/nacos/index.html
|
||||
|
||||
|
||||
zookeeper 格式:
|
||||
路劲:ls /dubbo/com.zyplayer.dubbo.service.UserService/providers
|
||||
格式:
|
||||
dubbo://127.0.0.1:22223/com.zyplayer.dubbo.service.UserService
|
||||
?anyhost=true
|
||||
&application=dubbo-provider
|
||||
&bean.name=ServiceBean:com.zyplayer.dubbo.service.UserService
|
||||
&dubbo=2.0.2
|
||||
&generic=false
|
||||
&interface=com.zyplayer.dubbo.service.UserService
|
||||
&methods=getUserDetail,getUserList
|
||||
&pid=36580
|
||||
&side=provider
|
||||
×tamp=1549955979708
|
||||
|
||||
nacos 格式:
|
||||
文档:https://nacos.io/zh-cn/docs/open-API.html
|
||||
请求地址:http://127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=providers:com.zyplayer.dubbo.service.UserService
|
||||
格式:
|
||||
{
|
||||
"metadata": {},
|
||||
"dom": "providers:com.zyplayer.dubbo.service.UserService",
|
||||
"cacheMillis": 10000,
|
||||
"useSpecifiedURL": false,
|
||||
"hosts": [{
|
||||
"valid": true,
|
||||
"marked": false,
|
||||
"metadata": {
|
||||
"side": "provider",
|
||||
"protocol": "dubbo",
|
||||
"application": "dubbo-provider",
|
||||
"methods": "getUserDetail,getUserList",
|
||||
"dubbo": "2.0.2",
|
||||
"pid": "8164",
|
||||
"interface": "com.zyplayer.dubbo.service.UserService",
|
||||
"category": "providers",
|
||||
"generic": "false",
|
||||
"anyhost": "true",
|
||||
"bean.name": "ServiceBean:com.zyplayer.dubbo.service.UserService",
|
||||
"timestamp": "1549953970871"
|
||||
},
|
||||
"instanceId": "127.0.0.1#22223#DEFAULT#providers:com.zyplayer.dubbo.service.UserService",
|
||||
"port": 22223,
|
||||
"ip": "127.0.0.1",
|
||||
"clusterName": "DEFAULT",
|
||||
"weight": 1.0,
|
||||
"serviceName": "providers:com.zyplayer.dubbo.service.UserService",
|
||||
"enabled": true
|
||||
}],
|
||||
"checksum": "2489ae2874f2f490caf7d6195192d6c71549955797122",
|
||||
"lastRefTime": 1549955797122,
|
||||
"env": "",
|
||||
"clusters": ""
|
||||
}
|
||||
|
||||
|
||||
@@ -1,482 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<!--无论发布在哪、如何修改源码,请勿删除本行原作者信息,感谢-->
|
||||
<meta name="author" content="开发者列表:暮光:城中城,项目地址:https://gitee.com/zyplayer/zyplayer-doc" />
|
||||
<title>dubbo文档管理系统</title>
|
||||
<link rel="shortcut icon" href="webjars/doc-dubbo/img/dubbo.ico"/>
|
||||
<link rel="stylesheet" href="webjars/doc-dubbo/css/element-ui.css">
|
||||
<link rel="stylesheet" href="webjars/doc-dubbo/css/doc-dubbo.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<el-container style="height: 100%;">
|
||||
<el-aside width="auto" style="height: 100%;">
|
||||
<div class="logo" @click="aboutDialogVisible = true">zyplayer-doc-dubbo</div>
|
||||
<div style="padding: 10px;">
|
||||
<div align="center"><el-button type="primary" v-on:click="reloadService" icon="el-icon-refresh" style="width: 100%;">重新加载服务列表</el-button></div>
|
||||
<!--<el-row><el-switch v-model="isCollapse"></el-switch></el-row>-->
|
||||
<el-input v-model="searchKeywords" placeholder="搜索文档" style="margin: 10px 0;">
|
||||
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywords"></el-button>
|
||||
</el-input>
|
||||
<!--<el-menu default-active="" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">-->
|
||||
<!--<el-submenu index="1">-->
|
||||
<!--<template slot="title">-->
|
||||
<!--<i class="el-icon-setting"></i>-->
|
||||
<!--<span slot="title">文档管理</span>-->
|
||||
<!--</template>-->
|
||||
<!--<el-menu-item index="1-1">管理服务列表</el-menu-item>-->
|
||||
<!--</el-submenu>-->
|
||||
<!--</el-menu>-->
|
||||
<el-tree :data="pathIndex" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
|
||||
</div>
|
||||
</el-aside>
|
||||
<el-container>
|
||||
<el-tabs type="border-card" style="width: 100%;">
|
||||
<el-tab-pane label="接口说明">
|
||||
<div v-if="!dubboInfo.interface">
|
||||
请先选择服务
|
||||
</div>
|
||||
<el-form v-else label-width="80px">
|
||||
<el-form-item label="服务:">
|
||||
{{dubboInfo.interface}}
|
||||
</el-form-item>
|
||||
<el-form-item label="方法:">
|
||||
{{dubboInfo.method}}
|
||||
</el-form-item>
|
||||
<el-form-item label="说明:">
|
||||
<div v-if="dubboInfoExplainShow">
|
||||
<pre>{{dubboInfo.docInfo.explain}}<el-button @click.prevent="dubboInfoExplainShow = false;" style="float: right;">编辑</el-button></pre>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-input type="textarea" :rows="4" placeholder="维护人员、使用说明、便于搜索的信息" v-model="docInfoExplainInput"></el-input>
|
||||
<el-button @click.prevent="dubboInfoExplainShow = true;" style="float: right;margin: 5px;">取消</el-button>
|
||||
<el-button type="primary" @click.prevent="saveDocInfoExplain" style="float: right;margin: 5px;">保存</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="节点:">
|
||||
<el-table :data="dubboInfo.nodeList" border style="width: 100%">
|
||||
<el-table-column prop="application" label="应用"></el-table-column>
|
||||
<el-table-column prop="ip" label="IP"></el-table-column>
|
||||
<el-table-column prop="port" label="端口"></el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
<el-form-item label="参数:">
|
||||
<!--<div slot="label">-->
|
||||
<!--<el-tooltip placement="top">-->
|
||||
<!--<div slot="content">1. 顺序必须和参数的顺序一致<br/>2. 参数名意义不大,可不填</div>-->
|
||||
<!--<i class="el-icon-info" style="color: #aaa;"></i>-->
|
||||
<!--</el-tooltip>-->
|
||||
<!--参数:-->
|
||||
<!--</div>-->
|
||||
<el-table :data="docParamList" border style="width: 100%; margin-bottom: 5px;">
|
||||
<el-table-column label="顺序" width="100">
|
||||
<template slot-scope="scope">{{scope.$index}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参数名" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.paramName"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" width="300">
|
||||
<template slot-scope="scope">{{scope.row.paramType}}</template>
|
||||
<!--<template slot-scope="scope">-->
|
||||
<!--<el-select v-model="scope.row.paramType" filterable allow-create clearable placeholder="请选择" style="width: 100%;">-->
|
||||
<!--<el-option v-for="item in paramTypeOptions" :key="item.value" :label="item.value" :value="item.value"></el-option>-->
|
||||
<!--</el-select>-->
|
||||
<!--</template>-->
|
||||
</el-table-column>
|
||||
<el-table-column label="说明">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.paramDesc"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-button @click.prevent="saveDocInfoParam" type="primary" style="float: right;margin: 5px;">保存</el-button>
|
||||
<!--<el-button @click.prevent="addDocParam" style="float: right;margin: 5px;">添加</el-button>-->
|
||||
</el-form-item>
|
||||
<el-form-item label="返回值:">
|
||||
{{dubboInfo.docInfo.resultType}}
|
||||
</el-form-item>
|
||||
<el-form-item label="结果:">
|
||||
<div v-if="dubboInfoResultShow">
|
||||
<pre>{{dubboInfo.docInfo.result}}<el-button @click.prevent="dubboInfoResultShow = false;" style="float: right;">编辑</el-button></pre>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-input type="textarea" :rows="4" placeholder="结果集说明等" v-model="docInfoResultInput"></el-input>
|
||||
<el-button @click.prevent="dubboInfoResultShow = true;" style="float: right;margin: 5px;">取消</el-button>
|
||||
<el-button type="primary" @click.prevent="saveDocInfoResult" style="float: right;margin: 5px;">保存</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="在线调试">
|
||||
<div v-if="!dubboInfo.interface">
|
||||
请先选择服务
|
||||
</div>
|
||||
<div v-loading="onlineDebugLoading" v-else>
|
||||
<el-input placeholder="请输入内容" v-model="dubboInfo.function" class="input-with-select">
|
||||
<el-select v-model="requestHostValue" slot="prepend" placeholder="请选择" style="width: 200px;">
|
||||
<el-option v-for="item in requestHostOptions" :key="item.value" :label="item.value" :value="item.value"></el-option>
|
||||
</el-select>
|
||||
<el-button slot="append" @click.prevent="requestExecute">执行</el-button>
|
||||
</el-input>
|
||||
<el-form label-width="100px" label-position="top">
|
||||
<el-form-item label="请求参数:">
|
||||
<el-table :data="docParamRequestList" border style="width: 100%; margin: 10px 0;">
|
||||
<el-table-column label="顺序" width="100">
|
||||
<template slot-scope="scope">{{scope.$index}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参数名">
|
||||
<template slot-scope="scope">{{scope.row.paramName}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型">
|
||||
<template slot-scope="scope">{{scope.row.paramType}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参数值">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.paramValue"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明">
|
||||
<template slot-scope="scope">{{scope.row.paramDesc}}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
<el-form-item label="请求结果:">
|
||||
<div v-html="requestResult"></div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-container>
|
||||
</el-container>
|
||||
<el-dialog title="关于zyplayer-doc-dubbo" :visible.sync="aboutDialogVisible" width="600px">
|
||||
<el-form>
|
||||
<el-form-item label="项目地址:">
|
||||
<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc</a>
|
||||
</el-form-item>
|
||||
<el-form-item label="开发人员:">
|
||||
<a target="_blank" href="http://zyplayer.com">暮光:城中城</a>
|
||||
</el-form-item>
|
||||
<template v-if="upgradeInfo.lastVersion">
|
||||
<el-form-item label="当前版本:">{{upgradeInfo.nowVersion}}</el-form-item>
|
||||
<el-form-item label="最新版本:">{{upgradeInfo.lastVersion}}</el-form-item>
|
||||
<el-form-item label="升级地址:">
|
||||
<a target="_blank" :href="upgradeInfo.upgradeUrl">{{upgradeInfo.upgradeUrl}}</a>
|
||||
</el-form-item>
|
||||
<el-form-item label="升级内容:">{{upgradeInfo.upgradeContent}}</el-form-item>
|
||||
</template>
|
||||
<el-form-item label="">
|
||||
欢迎加群讨论,QQ群号:466363173,欢迎提交需求,欢迎使用和加入开发!
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="webjars/doc-dubbo/vue/vue.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-dubbo/js/element-ui.js"></script>
|
||||
<!-- ajax 用到了jquery -->
|
||||
<script type="text/javascript" src="webjars/doc-dubbo/js/jquery-3.1.0.min.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-dubbo/js/common.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-dubbo/js/toast.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-dubbo/js/formatjson.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-dubbo/js/doc-dubbo-tree.js"></script>
|
||||
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
isCollapse: false,
|
||||
aboutDialogVisible: false,
|
||||
onlineDebugLoading: false,
|
||||
pathIndex: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
},
|
||||
// 展示的信息
|
||||
dubboInfo: {},
|
||||
dubboInfoExplainShow: true,
|
||||
docInfoExplainInput: "",
|
||||
dubboInfoResultShow: true,
|
||||
docInfoResultInput: "",
|
||||
// 请求的IP端口下拉选项
|
||||
requestHostOptions: [],
|
||||
requestHostValue: "",
|
||||
requestResult: "",
|
||||
// 依据目录树存储的map全局对象
|
||||
treePathDataMap: new Map(),
|
||||
// dubbo列表
|
||||
dubboDocList: [],
|
||||
dubboDocMap: [],
|
||||
// 搜索的输入内容
|
||||
searchKeywords: "",
|
||||
docParamList: [],
|
||||
docParamRequestList: [],
|
||||
// 参数类型选项
|
||||
paramTypeOptions: [{
|
||||
value: 'java.lang.String'
|
||||
}, {
|
||||
value: 'java.lang.Long'
|
||||
}, {
|
||||
value: 'java.lang.Integer'
|
||||
}],
|
||||
paramTypeValue: "java.lang.String",
|
||||
// 升级信息
|
||||
upgradeInfo: {},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
mounted: function () {
|
||||
// 无论发布在哪、如何修改源码,请勿删除本行原作者信息,感谢
|
||||
console.log("%c项目信息:\n开发者列表:暮光:城中城\n项目地址:https://gitee.com/zyplayer/zyplayer-doc", "color:red");
|
||||
this.doGetServiceList();
|
||||
this.checkSystemUpgrade();
|
||||
},
|
||||
methods: {
|
||||
handleOpen(key, keyPath) {
|
||||
console.log(key, keyPath);
|
||||
},
|
||||
handleClose(key, keyPath) {
|
||||
console.log(key, keyPath);
|
||||
},
|
||||
handleNodeClick(data) {
|
||||
if (data.children == null) {
|
||||
console.log(data);
|
||||
var path = data.interface;
|
||||
var application = data.application;
|
||||
var docInfo = app.dubboDocMap[path];
|
||||
if (!!docInfo) {
|
||||
this.createDocInfo(path, data.method);
|
||||
} else {
|
||||
var service = path.substring(0, path.lastIndexOf("."));
|
||||
var method = path.substring(path.lastIndexOf(".") + 1, path.length);
|
||||
var param = {service: service, method: method, application: application};
|
||||
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/findDocInfo", "post", "json", param, function (json) {
|
||||
if (validateResult(json)) {
|
||||
if (!!json.data) {
|
||||
app.dubboDocMap[json.data.function] = json.data;
|
||||
}
|
||||
app.createDocInfo(path, method);
|
||||
}
|
||||
});
|
||||
}
|
||||
//console.log(app.dubboInfo);
|
||||
}
|
||||
},
|
||||
createDocInfo(path, method) {
|
||||
var docInfo = app.dubboDocMap[path];
|
||||
var dubboInfo = app.treePathDataMap.get(path);
|
||||
dubboInfo.method = method;
|
||||
dubboInfo.function = path;
|
||||
dubboInfo.docInfo = docInfo || {};
|
||||
// 清空再赋值才会重新渲染
|
||||
app.dubboInfo = {};
|
||||
app.dubboInfo = dubboInfo;
|
||||
app.docInfoExplainInput = dubboInfo.docInfo.explain;
|
||||
app.docParamList = [];
|
||||
app.docParamList = dubboInfo.docInfo.params || [];
|
||||
this.createDocParamRequestList();
|
||||
// 请求相关
|
||||
app.requestResult = "";
|
||||
app.requestHostValue = "";
|
||||
app.requestHostOptions = [];
|
||||
for (var i = 0; i < dubboInfo.nodeList.length; i++) {
|
||||
var item = dubboInfo.nodeList[i];
|
||||
app.requestHostOptions.push({
|
||||
value: item.ip + ":" + item.port
|
||||
});
|
||||
}
|
||||
if (app.requestHostOptions.length > 0) {
|
||||
app.requestHostValue = app.requestHostOptions[0].value;
|
||||
}
|
||||
},
|
||||
reloadService(){
|
||||
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/reloadService", "post", "json", {}, function (json) {
|
||||
if (validateResult(json)) {
|
||||
app.$message({
|
||||
message: '加载成功!',
|
||||
type: 'success'
|
||||
});
|
||||
app.doGetServiceList();
|
||||
}
|
||||
});
|
||||
},
|
||||
searchByKeywords() {
|
||||
app.pathIndex = createTreeViewByTreeWithMerge(app.dubboDocList, app.searchKeywords);
|
||||
},
|
||||
doGetServiceList() {
|
||||
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/getDocList", "post", "json", {}, function (json) {
|
||||
if (validateResult(json)) {
|
||||
app.dubboDocList = json.data.serverList || [];
|
||||
app.dubboDocMap = json.data.docMap || {};
|
||||
app.pathIndex = createTreeViewByTreeWithMerge(app.dubboDocList);
|
||||
}
|
||||
});
|
||||
},
|
||||
saveDocInfoExplain(){
|
||||
this.doSaveDocInfo(app.docInfoExplainInput, null, null, true);
|
||||
},
|
||||
saveDocInfoResult(){
|
||||
this.doSaveDocInfo(null, null, app.docInfoResultInput, true);
|
||||
},
|
||||
saveDocInfoParam() {
|
||||
var docParamList = [];
|
||||
for (var i = 0; i < app.docParamList.length; i++) {
|
||||
var item = app.docParamList[i];
|
||||
if (isNotEmpty(item.paramType)) {
|
||||
docParamList.push(item);
|
||||
}
|
||||
}
|
||||
var paramsJson = JSON.stringify(docParamList);
|
||||
this.doSaveDocInfo(null, paramsJson, null, true);
|
||||
},
|
||||
createDocParamRequestList() {
|
||||
var docParamList = [];
|
||||
for (var i = 0; i < app.docParamList.length; i++) {
|
||||
var item = app.docParamList[i];
|
||||
if (isNotEmpty(item.paramType) || isNotEmpty(item.paramDesc)) {
|
||||
docParamList.push(item);
|
||||
}
|
||||
}
|
||||
app.docParamRequestList = docParamList;
|
||||
},
|
||||
doSaveDocInfo(explain, params, result, showSuccess){
|
||||
var param = {
|
||||
service: app.dubboInfo.interface,
|
||||
method: app.dubboInfo.method,
|
||||
resultType: app.dubboInfo.resultType,
|
||||
paramValue: app.dubboInfo.paramValue,
|
||||
version: app.dubboInfo.docInfo.version || 0,
|
||||
explain: explain,
|
||||
result: result,
|
||||
paramsJson: params,
|
||||
};
|
||||
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/saveDoc", "post", "json", param, function (json) {
|
||||
if (validateResult(json)) {
|
||||
app.dubboDocMap[json.data.function] = json.data;
|
||||
app.dubboInfo.docInfo = json.data;
|
||||
app.dubboInfoExplainShow = true;
|
||||
app.dubboInfoResultShow = true;
|
||||
app.docParamList = json.data.params || [];
|
||||
app.createDocParamRequestList();
|
||||
if (showSuccess) {
|
||||
Toast.success("保存成功!");
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
addDocParam() {
|
||||
var leadAdd = app.docParamList.length <= 0;
|
||||
if (!leadAdd) {
|
||||
var last = app.docParamList[app.docParamList.length - 1];
|
||||
if (isNotEmpty(last.paramType) || isNotEmpty(last.paramDesc)) {
|
||||
leadAdd = true;
|
||||
}
|
||||
}
|
||||
if (leadAdd) {
|
||||
app.docParamList.push({
|
||||
paramName: '',
|
||||
paramType: '',
|
||||
paramDesc: '',
|
||||
paramValue: '',
|
||||
});
|
||||
}
|
||||
},
|
||||
requestExecute() {
|
||||
var fuc = app.dubboInfo.function;
|
||||
var hostValue = app.requestHostValue;
|
||||
var service = fuc.substring(0, fuc.lastIndexOf("."));
|
||||
var method = fuc.substring(fuc.lastIndexOf(".") + 1, fuc.length);
|
||||
var ip = hostValue.substring(0, hostValue.lastIndexOf(":"));
|
||||
var port = hostValue.substring(hostValue.lastIndexOf(":") + 1, hostValue.length);
|
||||
var paramTypes = [];
|
||||
var params = [];
|
||||
for (var i = 0; i < app.docParamList.length; i++) {
|
||||
var item = app.docParamList[i];
|
||||
if (isNotEmpty(item.paramType) && isNotEmpty(item.paramValue)) {
|
||||
paramTypes.push(item.paramType);
|
||||
params.push(item.paramValue);
|
||||
}
|
||||
}
|
||||
var param = {
|
||||
service: service,
|
||||
method: method,
|
||||
ip: ip,
|
||||
port: port,
|
||||
paramTypes: JSON.stringify(paramTypes),
|
||||
params: JSON.stringify(params),
|
||||
};
|
||||
app.requestResult = "";
|
||||
app.onlineDebugLoading = true;
|
||||
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/request", "post", "json", param, function (json) {
|
||||
app.onlineDebugLoading = false;
|
||||
if (json.errCode == 200) {
|
||||
try {
|
||||
app.requestResult = Formatjson.processObjectToHtmlPre(JSON.parse(json.data), 0, false, false, false, false);
|
||||
} catch (e) {
|
||||
try {
|
||||
app.requestResult = Formatjson.processObjectToHtmlPre(json.data, 0, false, false, false, false);
|
||||
} catch (e) {
|
||||
app.requestResult = json.data;
|
||||
}
|
||||
}
|
||||
var paramsJson = JSON.stringify(app.docParamRequestList);
|
||||
app.doSaveDocInfo(null, paramsJson, null, false);
|
||||
} else {
|
||||
app.requestResult = json.errMsg;
|
||||
}
|
||||
});
|
||||
},
|
||||
checkSystemUpgrade() {
|
||||
ajaxTemp("system/info/upgrade", "post", "json", {}, function (json) {
|
||||
if (json.errCode == 200 && !!json.data) {
|
||||
app.upgradeInfo = json.data;
|
||||
console.log("zyplayer-doc发现新版本:"
|
||||
+ "\n升级地址:" + json.data.upgradeUrl
|
||||
+ "\n当前版本:" + json.data.nowVersion
|
||||
+ "\n最新版本:" + json.data.lastVersion
|
||||
+ "\n升级内容:" + json.data.upgradeContent
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
html,body,#app {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
pre{margin: 0;}
|
||||
.el-menu {
|
||||
box-sizing: border-box;
|
||||
border-right: 0;
|
||||
margin-right: 3px;
|
||||
}
|
||||
.el-tree{
|
||||
margin-right: 3px;
|
||||
}
|
||||
.el-tree-node__content{
|
||||
padding-right: 20px;
|
||||
}
|
||||
.el-tabs--border-card>.el-tabs__content{
|
||||
height: calc(100vh - 100px);overflow-y: auto;
|
||||
}
|
||||
.logo{
|
||||
background: linear-gradient(-90deg, #03DDE4 0%, #30AFED 51%, #8755FF 100%); cursor: pointer;
|
||||
width: 100%; height:60px;line-height:60px;font-size: 25px;color: #fff;text-align: center;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
/* S-JSON展示的样式 */
|
||||
pre.json {
|
||||
display: block;
|
||||
padding: 9.5px;
|
||||
margin: 0 0 0 10px;
|
||||
font-size: 12px;
|
||||
line-height: 1.38461538;
|
||||
color: #333;
|
||||
word-break: break-all;
|
||||
word-wrap: break-word;
|
||||
background-color: #f5f5f5;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
pre.json .canvas{font:10pt georgia;background-color:#ececec;color:#000000;border:1px solid #cecece;}
|
||||
pre.json .object-brace{color:#00aa00;font-weight:bold;}
|
||||
pre.json .array-brace{color:#0033ff;font-weight:bold;}
|
||||
pre.json .property-name{color:#cc0000;font-weight:bold;}
|
||||
pre.json .string{color:#007777;}
|
||||
pre.json .number{color:#aa00aa;}
|
||||
pre.json .boolean{color:#0000ff;}
|
||||
pre.json .function{color:#aa6633;text-decoration:italic;}
|
||||
pre.json .null{color:#0000ff;}
|
||||
pre.json .comma{color:#000000;font-weight:bold;}
|
||||
pre.json .annotation{color:#aaa;}
|
||||
pre img{cursor: pointer;}
|
||||
/* E-JSON展示的样式 */
|
||||
|
||||
|
Before Width: | Height: | Size: 340 B |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 331 B |
@@ -1,318 +0,0 @@
|
||||
/**
|
||||
* 一些公用方法
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function deserialize(value) {
|
||||
if (typeof value !== 'string' || isEmpty(value)) {
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
try {
|
||||
return eval('(' + value + ')');// 处理变态的单双引号共存字符串
|
||||
} catch (e) {
|
||||
return value || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateResult(result) {
|
||||
if(result.errCode == 200) {
|
||||
return true;
|
||||
} else {
|
||||
Toast.error(result.errMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getNowDate() {
|
||||
var date = new Date();
|
||||
var month = date.getMonth() + 1;
|
||||
var strDate = date.getDate();
|
||||
if (month >= 1 && month <= 9) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (strDate >= 0 && strDate <= 9) {
|
||||
strDate = "0" + strDate;
|
||||
}
|
||||
var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
function getNowTime() {
|
||||
var date = new Date();
|
||||
var hours = date.getHours();
|
||||
var minutes = date.getMinutes();
|
||||
var seconds = date.getSeconds();
|
||||
if (hours >= 1 && hours <= 9) {
|
||||
hours = "0" + hours;
|
||||
}
|
||||
if (minutes >= 0 && minutes <= 9) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
if (seconds >= 0 && seconds <= 9) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
var currentdate = hours + ":" + minutes + ":" + seconds;
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
function getNowDateTime() {
|
||||
var currentdate = getNowDate() + " " + getNowTime();
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回不为空的字符串,为空返回def
|
||||
*/
|
||||
function getNotEmptyStr(str, def) {
|
||||
if (isEmpty(str)) {
|
||||
return isEmpty(def) ? "" : def;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空对象
|
||||
* @param obj
|
||||
* @returns
|
||||
*/
|
||||
function isEmptyObject(obj){
|
||||
return isEmpty(obj) || $.isEmptyObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isEmpty(str){
|
||||
return (str == "" || str == null || str == undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否不是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isNotEmpty(str){
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转字符串,使用空格分隔
|
||||
* @param array
|
||||
* @returns
|
||||
*/
|
||||
function arrToString(array){
|
||||
var temStr = "";
|
||||
if(isEmpty(array)){
|
||||
return temStr;
|
||||
}
|
||||
array.forEach(function(e){
|
||||
if(isNotEmpty(temStr)) {
|
||||
temStr += " ";
|
||||
}
|
||||
temStr += e;
|
||||
});
|
||||
return temStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组array中是否包含str字符串
|
||||
* @param array
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function haveString(array, str){
|
||||
if(isEmpty(array)) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if(array[i] == str) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回对象的第一个属性
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttribute(data) {
|
||||
for ( var key in data) {
|
||||
return data[key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果对象只有一个属性则返回第一个属性,否则返回null
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttributeIfOnly(data) {
|
||||
var len = 0, value = "";
|
||||
for ( var key in data) {
|
||||
if (++len > 1) {
|
||||
return null;
|
||||
}
|
||||
value = data[key];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax处理事件模板
|
||||
*
|
||||
* @url 后台处理的url,即action
|
||||
* @dataSentType 数据发送的方式,有post,get方式
|
||||
* @dataReceiveType 数据接收格式,有html json text等
|
||||
* @paramsStr 传入后台的参数
|
||||
* @successFunction ajax成功后执行的函数名 ajaxTemp("", "GET", "html", {}, function(){},
|
||||
* function(){}, "");
|
||||
*/
|
||||
function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||
$.ajax({
|
||||
url : url, // 后台处理程序
|
||||
sync : false,
|
||||
type : dataSentType, // 数据发送方式
|
||||
dataType : dataReceiveType, // 接受数据格式
|
||||
traditional: true,
|
||||
data : eval(paramsStr),
|
||||
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
success : function(msg) {
|
||||
if(typeof successFunction == "function") {
|
||||
successFunction(msg,id);
|
||||
}
|
||||
},
|
||||
beforeSend : function() {
|
||||
|
||||
},
|
||||
complete : function(msg) {
|
||||
if (msg.responseText.startWith("<!doctype html>")) {
|
||||
if (msg.responseText.indexOf("THIS_IS_LOGIN_PAGE_FLAG") > 0) {
|
||||
app.$confirm('操作失败,登录已失效,请登陆后重试', '提示', {
|
||||
confirmButtonText: '去登陆',
|
||||
cancelButtonText: '知道了',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
window.open("static/manage/login.html");
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(typeof completeFunction == "function") {
|
||||
completeFunction(msg,id);
|
||||
}
|
||||
},
|
||||
error : function(msg) {
|
||||
if(typeof errorFunction == "function") {
|
||||
errorFunction(msg,id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function postWithFile(url, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||
$.ajax({
|
||||
url: url, // 后台处理程序
|
||||
sync: false,
|
||||
type: "POST", // 数据发送方式
|
||||
dataType: "JSON", // 接受数据格式
|
||||
data: eval(paramsStr),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (msg) {
|
||||
if (typeof successFunction == "function") {
|
||||
successFunction(msg, id);
|
||||
}
|
||||
},
|
||||
beforeSend: function () {
|
||||
|
||||
},
|
||||
complete: function (msg) {
|
||||
if (typeof completeFunction == "function") {
|
||||
completeFunction(msg, id);
|
||||
}
|
||||
},
|
||||
error: function (msg) {
|
||||
if (typeof errorFunction == "function") {
|
||||
errorFunction(msg, id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cookie
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
function getCookie(name) {
|
||||
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||
if(arr=document.cookie.match(reg)){
|
||||
return unescape(arr[2]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串格式化
|
||||
*/
|
||||
String.prototype.format = function(args) {
|
||||
if (arguments.length > 0) {
|
||||
var result = this;
|
||||
if (arguments.length == 1 && typeof (args) == "object") {
|
||||
for ( var key in args) {
|
||||
var reg = new RegExp("({" + key + "})", "g");
|
||||
result = result.replace(reg, args[key]);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] == undefined) {
|
||||
return "";
|
||||
} else {
|
||||
var reg = new RegExp("({[" + i + "]})", "g");
|
||||
result = result.replace(reg, arguments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
String.prototype.endWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substring(this.length - str.length) == str);
|
||||
};
|
||||
|
||||
String.prototype.startWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substr(0, str.length) == str);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取父窗口的exports
|
||||
* @returns
|
||||
*/
|
||||
function getExport(){
|
||||
return window.parent.window.exports;
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/**
|
||||
* 以树形方式生成并展示:
|
||||
* /api
|
||||
* /data
|
||||
* /getDateList
|
||||
* post
|
||||
* get
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年5月26日
|
||||
*/
|
||||
|
||||
/**
|
||||
* 把原始的json字符串转换成对象列表的方式,方便后续使用
|
||||
* @param json swagger的原始对象
|
||||
* @returns
|
||||
*/
|
||||
function createTreeViewByTree(json, keywords) {
|
||||
var pathIndex = [];
|
||||
if (isEmptyObject(json)) {
|
||||
return;
|
||||
}
|
||||
//console.log(paths);
|
||||
var lastId = "";
|
||||
for (var i = 0; i < json.length; i++) {
|
||||
var interface = json[i].interface;
|
||||
//console.log(key, paths[key]);
|
||||
if (!findInPathsValue(json[i], keywords)) {
|
||||
continue;
|
||||
}
|
||||
if (json[i].nodeList.length <= 0) {
|
||||
continue;
|
||||
}
|
||||
var methods = json[i].nodeList[0].methods;
|
||||
var application = json[i].nodeList[0].application;
|
||||
for (var j = 0; j < methods.length; j++) {
|
||||
var interfaceTemp = interface + "." + methods[j];
|
||||
var keyArr = interfaceTemp.split(".");
|
||||
var nowPathObj = null;
|
||||
keyArr.forEach(function(val, index) {
|
||||
//console.log(val, index);
|
||||
if(isEmpty(val) && index == 0) {
|
||||
return;
|
||||
}
|
||||
var nowPath = val;
|
||||
if (nowPathObj == null) {
|
||||
nowPathObj = findNode(pathIndex, nowPath);
|
||||
if (nowPathObj == null) {
|
||||
nowPathObj = {
|
||||
id: pathIndex.length,
|
||||
label: nowPath, children: []
|
||||
};
|
||||
pathIndex.push(nowPathObj);
|
||||
}
|
||||
lastId = nowPathObj.id;
|
||||
nowPathObj = nowPathObj.children;
|
||||
} else {
|
||||
var tempPathObj = findNode(nowPathObj, nowPath);
|
||||
if(tempPathObj == null) {
|
||||
tempPathObj = {
|
||||
id: lastId + "." + nowPathObj.length,
|
||||
label: nowPath, children: []
|
||||
};
|
||||
nowPathObj.push(tempPathObj);
|
||||
}
|
||||
lastId = tempPathObj.id;
|
||||
nowPathObj = tempPathObj.children;
|
||||
if (index == keyArr.length - 1) {
|
||||
var tempPath = interfaceTemp;
|
||||
tempPathObj.children = null;
|
||||
tempPathObj.method = methods[j];
|
||||
tempPathObj.interface = tempPath;
|
||||
tempPathObj.application = application;
|
||||
app.treePathDataMap.set(tempPath, json[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// console.log(pathIndex);
|
||||
return pathIndex;
|
||||
}
|
||||
|
||||
function createTreeViewByTreeWithMerge(json, keywords) {
|
||||
var pathIndex = createTreeViewByTree(json, keywords);
|
||||
mergeNode(pathIndex);
|
||||
return pathIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找node节点
|
||||
*/
|
||||
function findNode(arr, service){
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if(arr[i].label == service) {
|
||||
return arr[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多层级合并
|
||||
*/
|
||||
function mergeNode(node) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var tempNode = node[i];
|
||||
if (tempNode.children == null
|
||||
|| tempNode.children[0].children == null
|
||||
|| tempNode.children[0].children[0].children == null) {
|
||||
continue;
|
||||
}
|
||||
if (tempNode.children.length == 1) {
|
||||
tempNode.label = tempNode.label + "." + tempNode.children[0].label;
|
||||
tempNode.children = tempNode.children[0].children;
|
||||
i--;
|
||||
}
|
||||
mergeNode(tempNode.children);
|
||||
}
|
||||
}
|
||||
|
||||
function findInPathsValue(pathsValue, keywords) {
|
||||
if (isEmpty(keywords)) {
|
||||
return true;
|
||||
}
|
||||
keywords = keywords.toLowerCase();
|
||||
// 找路径和说明里面包含关键字的
|
||||
var interface = pathsValue.interface;
|
||||
if (isNotEmpty(interface) && interface.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (pathsValue.nodeList.length > 0) {
|
||||
for (var i = 0; i < pathsValue.nodeList.length; i++) {
|
||||
var node = pathsValue.nodeList[i];
|
||||
if (getNotEmptyStr(node.application).toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (!!node.methods && node.methods.length > 0) {
|
||||
for (var j = 0; j < node.methods.length; j++) {
|
||||
var method = node.methods[j];
|
||||
if (method.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
var path = interface + "." + method;
|
||||
var docInfo = app.dubboDocMap[path];
|
||||
if (!!docInfo) {
|
||||
if (getNotEmptyStr(docInfo.explain).toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (getNotEmptyStr(docInfo.result).toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
|
||||
/**
|
||||
* 将对象处理成json格式化和着色的html
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var Formatjson = {
|
||||
// 需要在对象或列表后面添加注释的对象,例:{userList: "用户列表"}
|
||||
// 那么在名字为userList的对象或列表后面都会加上:“用户列表” 这个注释
|
||||
annotationObject: {},
|
||||
tabStr: " ",
|
||||
isArray: function(obj) {
|
||||
return obj && typeof obj === 'object' && typeof obj.length === 'number'
|
||||
&& !(obj.propertyIsEnumerable('length'));
|
||||
},
|
||||
processObjectToHtmlPre: function(obj, indent, addComma, isArray, isPropertyContent, showAnnotation) {
|
||||
var htmlStr = this.processObject(obj, "", indent, addComma, isArray, isPropertyContent, showAnnotation);
|
||||
htmlStr = '<pre class="json">' + htmlStr + '</pre>';
|
||||
return htmlStr;
|
||||
},
|
||||
processObject: function(obj, keyName, indent, addComma, isArray, isPropertyContent, showAnnotation) {
|
||||
var html = "";
|
||||
var comma = (addComma) ? "<span class='comma'>,</span> " : "";
|
||||
var type = typeof obj;
|
||||
if (this.isArray(obj)) {
|
||||
if (obj.length == 0) {
|
||||
html += this.getRow(indent, "<span class='array-brace'>[ ]</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
var clpsHtml = '<span><img class="option-img" src="webjars/doc-dubbo/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
var annotation = '';
|
||||
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
|
||||
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
|
||||
}
|
||||
html += this.getRow(indent, "<span class='array-brace'>[</span>"+clpsHtml+annotation, isPropertyContent);
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
html += this.processObject(obj[i], "", indent + 1, i < (obj.length - 1), true, false, showAnnotation);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='array-brace'>]</span>" + comma);
|
||||
}
|
||||
} else if (type == 'object' && obj == null) {
|
||||
html += this.formatLiteral("null", "", comma, indent, isArray, "null");
|
||||
} else if (type == 'object') {
|
||||
var numProps = 0;
|
||||
for ( var prop in obj) {
|
||||
numProps++;
|
||||
}
|
||||
if (numProps == 0) {
|
||||
html += this.getRow(indent, "<span class='object-brace'>{ }</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
var clpsHtml = '<span><img class="option-img" src="webjars/doc-dubbo/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
var annotation = '';
|
||||
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
|
||||
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
|
||||
}
|
||||
html += this.getRow(indent, "<span class='object-brace'>{</span>"+clpsHtml+annotation, isPropertyContent);
|
||||
var j = 0;
|
||||
for ( var prop in obj) {
|
||||
var processStr = '<span class="property-name">"' + prop + '"</span>: ' + this.processObject(obj[prop], prop, indent + 1, ++j < numProps, false, true, showAnnotation);
|
||||
html += this.getRow(indent + 1, processStr);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='object-brace'>}</span>" + comma);
|
||||
}
|
||||
} else if (type == 'number') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "number");
|
||||
} else if (type == 'boolean') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "boolean");
|
||||
} else if (type == 'function') {
|
||||
obj = this.formatFunction(indent, obj);
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "function");
|
||||
} else if (type == 'undefined') {
|
||||
html += this.formatLiteral("undefined", "", comma, indent, isArray, "null");
|
||||
} else {
|
||||
html += this.formatLiteral(obj, "\"", comma, indent, isArray, "string");
|
||||
}
|
||||
return html;
|
||||
},
|
||||
expImgClicked: function(img){
|
||||
var container = img.parentNode.nextSibling;
|
||||
if(!container) return;
|
||||
var disp = "none";
|
||||
var src = "webjars/doc-dubbo/img/collapsed.png";
|
||||
if(container.style.display == "none"){
|
||||
disp = "inline";
|
||||
src = "webjars/doc-dubbo/img/expanded.png";
|
||||
}
|
||||
container.style.display = disp;
|
||||
img.src = src;
|
||||
},
|
||||
formatLiteral: function(literal, quote, comma, indent, isArray, style) {
|
||||
if (typeof literal == 'string') {
|
||||
literal = literal.split("<").join("<").split(">").join(">");
|
||||
}
|
||||
var str = "<span class='" + style + "'>" + quote + literal + quote + comma + "</span>";
|
||||
if (isArray) {
|
||||
str = this.getRow(indent, str);
|
||||
}
|
||||
return str;
|
||||
},
|
||||
formatFunction: function(indent, obj) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
var funcStrArray = obj.toString().split("\n");
|
||||
var str = "";
|
||||
for (var i = 0; i < funcStrArray.length; i++) {
|
||||
str += ((i == 0) ? "" : tabs) + funcStrArray[i] + "\n";
|
||||
}
|
||||
return str;
|
||||
},
|
||||
getRow: function(indent, data, isPropertyContent) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent && !isPropertyContent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
if (data != null && data.length > 0 && data.charAt(data.length - 1) != "\n") {
|
||||
data = data + "\n";
|
||||
}
|
||||
return tabs + data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/**
|
||||
* 提示工具类
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var Toast = {
|
||||
notOpen: function () {
|
||||
app.$message({
|
||||
message: '该功能暂未开放,敬请期待!',
|
||||
type: 'warning',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
success: function (msg, time) {
|
||||
app.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'success',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
warn: function (msg, time) {
|
||||
app.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'warning',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
error: function (msg, time) {
|
||||
app.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'error',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -1,161 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-grpc</artifactId>
|
||||
<version>1.0.1</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.2.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
|
||||
<grpc.version>1.16.1</grpc.version>
|
||||
<protoc.version>3.6.1</protoc.version> <!-- Same version as grpc-proto -->
|
||||
<grpc-java-spring.version>0.0.3</grpc-java-spring.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.56</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-netty</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-protobuf</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nxest.grpc</groupId>
|
||||
<artifactId>grpc-java-spring</artifactId>
|
||||
<version>${grpc-java-spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</connection>
|
||||
<developerConnection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</developerConnection>
|
||||
<url>git@git.oschina.net:zyplayer/zyplayer-doc.git</url>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.5.0.Final</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<targetPath>META-INF/resources/</targetPath>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/webapp</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-resource</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>add-resource</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<directory>src/main/proto</directory>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.xolstice.maven.plugins</groupId>
|
||||
<artifactId>protobuf-maven-plugin</artifactId>
|
||||
<version>0.5.1</version>
|
||||
<configuration>
|
||||
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
|
||||
</protocArtifact>
|
||||
<pluginId>grpc-java</pluginId>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
|
||||
</pluginArtifact>
|
||||
<protoSourceRoot>src/main/proto</protoSourceRoot>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>compile-custom</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,405 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.nxest.grpc.client.GrpcChannelFactory;
|
||||
import com.nxest.grpc.server.GrpcService;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.grpc.controller.po.ColumnInfo;
|
||||
import com.zyplayer.doc.grpc.controller.po.GrpcDocInfo;
|
||||
import com.zyplayer.doc.grpc.controller.po.GrpcServiceAndColumn;
|
||||
import com.zyplayer.doc.grpc.controller.po.MethodParam;
|
||||
import com.zyplayer.doc.grpc.framework.config.DocGrpcContext;
|
||||
import com.zyplayer.doc.grpc.framework.config.DocGrpcService;
|
||||
import com.zyplayer.doc.grpc.framework.config.SpringContextUtil;
|
||||
import com.zyplayer.doc.grpc.framework.consts.Const;
|
||||
import io.grpc.Channel;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.Metadata;
|
||||
import io.grpc.netty.NettyChannelBuilder;
|
||||
import io.grpc.stub.AbstractStub;
|
||||
import io.grpc.stub.MetadataUtils;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* grpc文档控制器
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/zyplayer-doc-grpc")
|
||||
public class GrpcDocController {
|
||||
|
||||
@Autowired(required = false)
|
||||
DocGrpcContext docGrpcContext;
|
||||
|
||||
private static Map<String, ColumnInfo> allColumnsMap = new HashMap<>();
|
||||
private static Map<String, Object> allBlockingStubMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 查找所有文档
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
@RequestMapping("/service")
|
||||
public DocResponseJson service() {
|
||||
List<Object> grpcServiceList = SpringContextUtil.getBeanWithAnnotation(DocGrpcService.class);
|
||||
if (grpcServiceList == null || grpcServiceList.size() <= 0) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
List<GrpcDocInfo> grpcDocInfoList = new LinkedList<>();
|
||||
for (Object service : grpcServiceList) {
|
||||
List<GrpcDocInfo> infoList = this.getServiceInfoByJar(service.getClass());
|
||||
if (infoList != null) {
|
||||
grpcDocInfoList.addAll(infoList);
|
||||
}
|
||||
}
|
||||
// 找所有的参数列表
|
||||
Map<String, ColumnInfo> columnsMap = new HashMap<>();
|
||||
for (GrpcDocInfo grpcDocInfo : grpcDocInfoList) {
|
||||
this.setColumnsInfo(grpcDocInfo.getParamType(), columnsMap);
|
||||
this.setColumnsInfo(grpcDocInfo.getResultType(), columnsMap);
|
||||
}
|
||||
GrpcServiceAndColumn grpcServiceAndColumn = new GrpcServiceAndColumn();
|
||||
grpcServiceAndColumn.setServiceList(grpcDocInfoList);
|
||||
grpcServiceAndColumn.setColumnMap(columnsMap);
|
||||
return DocResponseJson.ok(grpcServiceAndColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行grpc请求
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
@RequestMapping("/execute")
|
||||
public DocResponseJson execute(String docService, String params) throws Exception {
|
||||
List<GrpcDocInfo> grpcDocInfoList = this.getServiceInfoByJar(Class.forName(docService));
|
||||
JSONObject executeResult = null;
|
||||
if (grpcDocInfoList != null && grpcDocInfoList.size() > 0) {
|
||||
JSONObject paramMap = JSON.parseObject(params);
|
||||
try {
|
||||
executeResult = this.executeFunction(grpcDocInfoList.get(0), paramMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocResponseJson.warn("执行方法失败");
|
||||
}
|
||||
}
|
||||
return DocResponseJson.ok(executeResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置字段信息到map
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private void setColumnsInfo(String typeName, Map<String, ColumnInfo> columnsMap) {
|
||||
if (!columnsMap.containsKey(typeName)) {
|
||||
if (allColumnsMap.containsKey(typeName)) {
|
||||
columnsMap.put(typeName, allColumnsMap.get(typeName));
|
||||
} else {
|
||||
ColumnInfo columnInfo = this.findColumnInfo(typeName);
|
||||
columnsMap.put(typeName, columnInfo);
|
||||
allColumnsMap.put(typeName, columnInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行grpc方法
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private JSONObject executeFunction(GrpcDocInfo grpcDocInfo, JSONObject paramMap) throws Exception {
|
||||
Object newBuilder = this.createParamBuilder(grpcDocInfo.getParamType(), paramMap);
|
||||
if (newBuilder == null) {
|
||||
throw new ConfirmException("参数组装失败");
|
||||
}
|
||||
if (docGrpcContext == null) {
|
||||
throw new ConfirmException("注入grpc服务失败");
|
||||
}
|
||||
// 创建参数对象
|
||||
Method build = newBuilder.getClass().getMethod("build");
|
||||
Object request = build.invoke(newBuilder);
|
||||
System.out.println(request.toString());
|
||||
// 为创建过则创建
|
||||
Object blockingStub = allBlockingStubMap.get(grpcDocInfo.getService());
|
||||
if (blockingStub == null) {
|
||||
// 找到父类
|
||||
// Class<?> serviceClass = Class.forName(grpcDocInfo.getService());
|
||||
// String serviceSuperName = serviceClass.getSuperclass().getName();
|
||||
String serviceSuperName = grpcDocInfo.getService();
|
||||
int index = serviceSuperName.lastIndexOf(".");
|
||||
serviceSuperName = serviceSuperName.substring(0, index) + "$" + serviceSuperName.substring(index + 1);
|
||||
String superClassName = serviceSuperName.substring(0, serviceSuperName.indexOf("$"));
|
||||
// 注册
|
||||
Class<?> superClass = Class.forName(superClassName);
|
||||
Method newBlockingStubMethod = superClass.getMethod("newBlockingStub", Channel.class);
|
||||
SslContext sslContext = docGrpcContext.getSslContext();
|
||||
ManagedChannel channel = NettyChannelBuilder.forAddress(docGrpcContext.getHost(), docGrpcContext.getPort())
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
blockingStub = newBlockingStubMethod.invoke(null, channel);
|
||||
Metadata metadata = docGrpcContext.getMetadata();
|
||||
if (metadata != null) {
|
||||
blockingStub = MetadataUtils.attachHeaders((AbstractStub) blockingStub, metadata);
|
||||
}
|
||||
allBlockingStubMap.put(grpcDocInfo.getService(), blockingStub);
|
||||
}
|
||||
Method sayHello = blockingStub.getClass().getMethod(grpcDocInfo.getMethod(), Class.forName(grpcDocInfo.getParamType()));
|
||||
// 执行请求
|
||||
Object response = sayHello.invoke(blockingStub, request);
|
||||
List<ColumnInfo> columnInfos = this.findClassColumns(response.getClass());
|
||||
return this.protobufToJson(response, columnInfos);
|
||||
}
|
||||
|
||||
/**
|
||||
* grpc对象转json字符串
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private JSONObject protobufToJson(Object response, List<ColumnInfo> columnInfos) throws Exception {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
for (ColumnInfo columnInfo : columnInfos) {
|
||||
Method getMethod = response.getClass().getMethod("get" + this.toUpperCaseFirstOne(columnInfo.getName()));
|
||||
Object paramValue = getMethod.invoke(response);
|
||||
if (columnInfo.getParam() != null && columnInfo.getParam().size() > 0) {
|
||||
JSONObject jsonObjectSub = this.protobufToJson(paramValue, columnInfo.getParam());
|
||||
jsonObject.put(columnInfo.getName(), jsonObjectSub);
|
||||
} else {
|
||||
if ("com.google.protobuf.ByteString".equals(columnInfo.getType())) {
|
||||
ByteString byteString = (ByteString) paramValue;
|
||||
jsonObject.put(columnInfo.getName(), byteString.toStringUtf8());
|
||||
} else {
|
||||
jsonObject.put(columnInfo.getName(), paramValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建参数的builder对象
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private Object createParamBuilder(String paramType, JSONObject paramMap) {
|
||||
try {
|
||||
Class<?> aClassSub = Class.forName(paramType);
|
||||
Method newBuilderMethod = aClassSub.getMethod("newBuilder");
|
||||
Object newBuilder = newBuilderMethod.invoke(aClassSub);
|
||||
List<MethodParam> functionTemp = this.getSetterFunction(newBuilder.getClass());
|
||||
for (MethodParam paramTemp : functionTemp) {
|
||||
Class<?> baseTypeClass = Const.BASE_TYPE.get(paramTemp.getType());
|
||||
if (baseTypeClass != null) {
|
||||
Method setNameSub = newBuilder.getClass().getMethod(paramTemp.getSetterName(), baseTypeClass);
|
||||
Object paramObjTemp;
|
||||
// 特殊类型参数处理
|
||||
if ("com.google.protobuf.ByteString".equals(paramTemp.getType())) {
|
||||
String stringValue = paramMap.getString(paramTemp.getName());
|
||||
paramObjTemp = ByteString.copyFrom(stringValue, "UTF-8");
|
||||
} else {
|
||||
paramObjTemp = paramMap.getObject(paramTemp.getName(), baseTypeClass);
|
||||
}
|
||||
// 不为空则设置参数值
|
||||
if (paramObjTemp != null) {
|
||||
newBuilder = setNameSub.invoke(newBuilder, paramObjTemp);
|
||||
}
|
||||
} else {
|
||||
Class<?> typeClassSub = Class.forName(paramTemp.getType());
|
||||
Object newBuilderSub = this.createParamBuilder(paramTemp.getType(), paramMap.getJSONObject(paramTemp.getName()));
|
||||
if (newBuilderSub == null) {
|
||||
return null;
|
||||
}
|
||||
Method build = newBuilderSub.getClass().getMethod("build");
|
||||
Object request = build.invoke(newBuilderSub);
|
||||
Method setNameSub = newBuilder.getClass().getMethod(paramTemp.getSetterName(), typeClassSub);
|
||||
newBuilder = setNameSub.invoke(newBuilder, request);
|
||||
}
|
||||
}
|
||||
return newBuilder;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首字母小写
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private String toLowerCaseFirstOne(String str) {
|
||||
if (Character.isLowerCase(str.charAt(0))) {
|
||||
return str;
|
||||
} else {
|
||||
return Character.toLowerCase(str.charAt(0)) + str.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首字母大写
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private String toUpperCaseFirstOne(String str) {
|
||||
if (Character.isUpperCase(str.charAt(0))) {
|
||||
return str;
|
||||
} else {
|
||||
return Character.toUpperCase(str.charAt(0)) + str.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到所有的setter方法
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private List<MethodParam> getSetterFunction(Class<?> clazz) {
|
||||
List<MethodParam> result = new LinkedList<>();
|
||||
Method[] methods = clazz.getDeclaredMethods();
|
||||
StringBuilder nameSb = new StringBuilder();
|
||||
for (Method method : methods) {
|
||||
String methodName = method.getName();
|
||||
if (!methodName.startsWith("set") || methodName.endsWith("Bytes")
|
||||
|| methodName.equals("setField") || methodName.equals("setRepeatedField")
|
||||
|| methodName.equals("setUnknownFields")) {
|
||||
continue;
|
||||
}
|
||||
Type[] parameterTypes = method.getGenericParameterTypes();
|
||||
if (parameterTypes.length == 1) {
|
||||
String typeName = parameterTypes[0].getTypeName();
|
||||
if (typeName.endsWith("$Builder")) {
|
||||
continue;
|
||||
}
|
||||
MethodParam param = new MethodParam();
|
||||
param.setSetterName(methodName);
|
||||
param.setType(typeName);
|
||||
String paramName = methodName.substring(3);
|
||||
param.setName(this.toLowerCaseFirstOne(paramName));
|
||||
result.add(param);
|
||||
}
|
||||
nameSb.append(methodName).append(",");
|
||||
}
|
||||
//System.out.println(nameSb);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到所有的字段信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private ColumnInfo findColumnInfo(String paramType) {
|
||||
ColumnInfo columnInfo = new ColumnInfo();
|
||||
try {
|
||||
String paramName = paramType.substring(paramType.lastIndexOf(".") + 1);
|
||||
columnInfo.setName(this.toLowerCaseFirstOne(paramName));
|
||||
columnInfo.setType(paramType);
|
||||
List<ColumnInfo> columnInfos = this.findClassColumns(Class.forName(paramType));
|
||||
columnInfo.setParam(columnInfos);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return columnInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到所有的字段信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private List<ColumnInfo> findClassColumns(Class<?> clazz) throws Exception {
|
||||
Method getMoney = clazz.getMethod("newBuilder");
|
||||
Object newBuilder = getMoney.invoke(clazz);
|
||||
|
||||
List<MethodParam> paramList = this.getSetterFunction(newBuilder.getClass());
|
||||
List<ColumnInfo> subInfoList = new LinkedList<>();
|
||||
for (MethodParam param : paramList) {
|
||||
ColumnInfo info = new ColumnInfo();
|
||||
info.setType(param.getType());
|
||||
info.setName(param.getName());
|
||||
if (!Const.BASE_TYPE.containsKey(param.getType())) {
|
||||
List<ColumnInfo> classColumn = this.findClassColumns(Class.forName(param.getType()));
|
||||
info.setParam(classColumn);
|
||||
}
|
||||
subInfoList.add(info);
|
||||
}
|
||||
return subInfoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到服务,组装方法、参数和返回值等
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
private List<GrpcDocInfo> getServiceInfoByJar(Class<?> clazz) {
|
||||
List<GrpcDocInfo> providerList = new LinkedList<>();
|
||||
try {
|
||||
Method[] methods = clazz.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
String methodName = method.getName();
|
||||
String resultType = "";
|
||||
String paramType = "";
|
||||
Type[] parameterTypes = method.getGenericParameterTypes();
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
String typeName = parameterTypes[i].getTypeName();
|
||||
if (i == 0) {
|
||||
paramType = parameterTypes[i].getTypeName();
|
||||
} else if (typeName.matches("io.grpc.stub.StreamObserver<.+>")) {
|
||||
Pattern pattern = Pattern.compile("io.grpc.stub.StreamObserver<(.+)>");
|
||||
Matcher matcher = pattern.matcher(typeName);
|
||||
if (matcher.find()) {
|
||||
resultType = matcher.group(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
GrpcDocInfo grpcDocInfo = new GrpcDocInfo();
|
||||
DocGrpcService annotation = clazz.getAnnotation(DocGrpcService.class);
|
||||
if (annotation != null) {
|
||||
grpcDocInfo.setService(annotation.service());
|
||||
} else {
|
||||
grpcDocInfo.setService(clazz.getName());
|
||||
}
|
||||
grpcDocInfo.setDocService(clazz.getName());
|
||||
grpcDocInfo.setMethod(methodName);
|
||||
grpcDocInfo.setParamType(paramType);
|
||||
grpcDocInfo.setResultType(resultType);
|
||||
providerList.add(grpcDocInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return providerList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.controller.po;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* grpc字段信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
public class ColumnInfo {
|
||||
private String name;
|
||||
private String type;
|
||||
private String desc;
|
||||
private List<ColumnInfo> param;
|
||||
|
||||
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 String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public List<ColumnInfo> getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setParam(List<ColumnInfo> param) {
|
||||
this.param = param;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.controller.po;
|
||||
|
||||
/**
|
||||
* 请求参数对象
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
*/
|
||||
public class GrpcDocInfo {
|
||||
private String method;
|
||||
private String service;
|
||||
private String docService;
|
||||
private String explain;
|
||||
private String result;
|
||||
private String paramType;
|
||||
private String resultType;
|
||||
private Integer version;
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(String service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public String getExplain() {
|
||||
return explain;
|
||||
}
|
||||
|
||||
public void setExplain(String explain) {
|
||||
this.explain = explain;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getResultType() {
|
||||
return resultType;
|
||||
}
|
||||
|
||||
public void setResultType(String resultType) {
|
||||
this.resultType = resultType;
|
||||
}
|
||||
|
||||
public String getParamType() {
|
||||
return paramType;
|
||||
}
|
||||
|
||||
public void setParamType(String paramType) {
|
||||
this.paramType = paramType;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getDocService() {
|
||||
return docService;
|
||||
}
|
||||
|
||||
public void setDocService(String docService) {
|
||||
this.docService = docService;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.controller.po;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 服务和字段信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年2月10日
|
||||
*/
|
||||
public class GrpcServiceAndColumn {
|
||||
private List<GrpcDocInfo> serviceList;
|
||||
private Map<String, ColumnInfo> columnMap;
|
||||
|
||||
public List<GrpcDocInfo> getServiceList() {
|
||||
return serviceList;
|
||||
}
|
||||
|
||||
public void setServiceList(List<GrpcDocInfo> serviceList) {
|
||||
this.serviceList = serviceList;
|
||||
}
|
||||
|
||||
public Map<String, ColumnInfo> getColumnMap() {
|
||||
return columnMap;
|
||||
}
|
||||
|
||||
public void setColumnMap(Map<String, ColumnInfo> columnMap) {
|
||||
this.columnMap = columnMap;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.controller.po;
|
||||
|
||||
/**
|
||||
* grpc方法信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
public class MethodParam {
|
||||
private String name;
|
||||
private String type;
|
||||
private String setterName;
|
||||
|
||||
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 String getSetterName() {
|
||||
return setterName;
|
||||
}
|
||||
|
||||
public void setSetterName(String setterName) {
|
||||
this.setterName = setterName;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.framework.config;
|
||||
|
||||
import io.grpc.Metadata;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
|
||||
public interface DocGrpcContext {
|
||||
|
||||
SslContext getSslContext();
|
||||
|
||||
String getHost();
|
||||
|
||||
Metadata getMetadata();
|
||||
|
||||
Integer getPort();
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.framework.config;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* grpc服务的注解
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Service
|
||||
public @interface DocGrpcService {
|
||||
|
||||
String service() default "";
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.framework.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 开启grpc的注解
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {
|
||||
"com.zyplayer.doc.grpc",
|
||||
})
|
||||
public @interface EnableDocGrpc {
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
//package com.zyplayer.doc.grpc.framework.config;
|
||||
//
|
||||
//import com.nxest.grpc.client.*;
|
||||
//import com.nxest.grpc.client.configure.GrpcClientProperties;
|
||||
//import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//
|
||||
///**
|
||||
// * grpc配置
|
||||
// *
|
||||
// * @author 暮光:城中城
|
||||
// * @since 2019年3月31日
|
||||
// */
|
||||
//@Configuration
|
||||
////@AutoConfigureAfter(GrpcServerConfiguration.class)
|
||||
//public class GrpcClientConfiguration {
|
||||
//
|
||||
// @Resource
|
||||
// private GrpcProperties grpcProperties;
|
||||
//
|
||||
// @Bean
|
||||
// public GrpcClientProperties clientProperties() {
|
||||
// return grpcProperties.getClient();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public GrpcChannelFactory channelFactory() {
|
||||
// return new AddressChannelFactory(clientProperties());
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public GrpcClientInterceptorDiscoverer clientInterceptorDiscoverer() {
|
||||
// return new AnnotationClientInterceptorDiscoverer();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// @ConditionalOnClass(GrpcClient.class)
|
||||
// public GrpcClientBeanPostProcessor grpcClientBeanPostProcessor() {
|
||||
// return new GrpcClientBeanPostProcessor(channelFactory(), clientInterceptorDiscoverer());
|
||||
// }
|
||||
//}
|
||||
@@ -1,34 +0,0 @@
|
||||
//package com.zyplayer.doc.grpc.framework.config;
|
||||
//
|
||||
//import com.nxest.grpc.client.configure.GrpcClientProperties;
|
||||
//import com.nxest.grpc.server.configure.GrpcServerProperties;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
///**
|
||||
// * grpc配置文件
|
||||
// *
|
||||
// * @author 暮光:城中城
|
||||
// * @since 2019年3月31日
|
||||
// */
|
||||
//@Configuration
|
||||
//@ConfigurationProperties(prefix = "grpc")
|
||||
//public class GrpcProperties {
|
||||
//
|
||||
// /**
|
||||
// * Grpc server properties
|
||||
// */
|
||||
// private final GrpcServerProperties server = new GrpcServerProperties();
|
||||
// /**
|
||||
// * Grpc client properties
|
||||
// */
|
||||
// private final GrpcClientProperties client = new GrpcClientProperties();
|
||||
//
|
||||
// public GrpcServerProperties getServer() {
|
||||
// return server;
|
||||
// }
|
||||
//
|
||||
// public GrpcClientProperties getClient() {
|
||||
// return client;
|
||||
// }
|
||||
//}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.framework.config;
|
||||
|
||||
import com.nxest.grpc.server.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* grpc服务
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
//@Configuration
|
||||
//public class GrpcServerConfiguration {
|
||||
//
|
||||
// @Resource
|
||||
// private GrpcProperties grpcProperties;
|
||||
//
|
||||
// @Bean
|
||||
// public GrpcServiceDiscoverer serviceDiscoverer() {
|
||||
// return new AnnotationGrpcServiceDiscoverer();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public GrpcServerFactory severFactory() {
|
||||
// return new NettyGrpcServerFactory(serviceDiscoverer(), grpcProperties.getServer());
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "grpcServer", initMethod = "start", destroyMethod = "destroy")
|
||||
// public GrpcServer serverRunner() {
|
||||
// return severFactory().createServer();
|
||||
// }
|
||||
//}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.framework.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* context工具类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
@Component
|
||||
public class SpringContextUtil implements ApplicationContextAware {
|
||||
|
||||
public static ApplicationContext context;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
context = applicationContext;
|
||||
}
|
||||
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clz) {
|
||||
return context.getBean(clz);
|
||||
}
|
||||
|
||||
public static Object getBean(String string) {
|
||||
return getApplicationContext().getBean(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类
|
||||
*
|
||||
* @param annotationType annotation
|
||||
* @return 类对象
|
||||
*/
|
||||
public static List<Object> getBeanWithAnnotation(Class<? extends Annotation> annotationType) {
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(annotationType);
|
||||
return new LinkedList<>(beansWithAnnotation.values());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.zyplayer.doc.grpc.framework.consts;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年3月31日
|
||||
*/
|
||||
public class Const {
|
||||
|
||||
/** 所有基础类型 */
|
||||
public static final Map<String, Class<?>> BASE_TYPE;
|
||||
static {
|
||||
BASE_TYPE = new HashMap<>();
|
||||
BASE_TYPE.put(String.class.getName(), String.class);
|
||||
BASE_TYPE.put(Integer.class.getName(), Integer.class);
|
||||
BASE_TYPE.put(Long.class.getName(), Long.class);
|
||||
BASE_TYPE.put(Double.class.getName(), Double.class);
|
||||
BASE_TYPE.put(Date.class.getName(), Date.class);
|
||||
BASE_TYPE.put(Byte.class.getName(), Byte.class);
|
||||
BASE_TYPE.put(Float.class.getName(), Float.class);
|
||||
BASE_TYPE.put(BigDecimal.class.getName(), BigDecimal.class);
|
||||
BASE_TYPE.put(ByteString.class.getName(), ByteString.class);
|
||||
|
||||
BASE_TYPE.put(char.class.getName(), char.class);
|
||||
BASE_TYPE.put(int.class.getName(), int.class);
|
||||
BASE_TYPE.put(long.class.getName(), long.class);
|
||||
BASE_TYPE.put(double.class.getName(), double.class);
|
||||
BASE_TYPE.put(byte.class.getName(), byte.class);
|
||||
BASE_TYPE.put(float.class.getName(), float.class);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
//package com.zyplayer.doc.grpc.service;
|
||||
//
|
||||
//
|
||||
//import com.google.protobuf.Empty;
|
||||
//import com.google.protobuf.Timestamp;
|
||||
//import com.nxest.grpc.server.GrpcService;
|
||||
//import com.zyplayer.doc.grpc.proto.HelloRequest;
|
||||
//import com.zyplayer.doc.grpc.proto.HelloResponse;
|
||||
//import com.zyplayer.doc.grpc.proto.TimeResponse;
|
||||
//import com.zyplayer.doc.grpc.proto.ZyplayerGreeterGrpc;
|
||||
//import io.grpc.stub.StreamObserver;
|
||||
//
|
||||
///**
|
||||
// * grpc服务测试类,需要mvn compile项目
|
||||
// * @author 暮光:城中城
|
||||
// * @since 2019年3月31日
|
||||
// */
|
||||
//@GrpcService
|
||||
//public class HelloWorldService extends ZyplayerGreeterGrpc.ZyplayerGreeterImplBase {
|
||||
//
|
||||
// @Override
|
||||
// public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
|
||||
// HelloResponse reply = HelloResponse.newBuilder().setMessage("Hello " + request.getName()).build();
|
||||
// responseObserver.onNext(reply);
|
||||
// responseObserver.onCompleted();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sayTime(Empty request, StreamObserver<TimeResponse> responseObserver) {
|
||||
// TimeResponse reply = TimeResponse.newBuilder().setTime(Timestamp.newBuilder().build()).build();
|
||||
// responseObserver.onNext(reply);
|
||||
// responseObserver.onCompleted();
|
||||
// }
|
||||
//}
|
||||
@@ -1,40 +0,0 @@
|
||||
//package com.zyplayer.doc.grpc.service;
|
||||
//
|
||||
//
|
||||
//import com.google.protobuf.ByteString;
|
||||
//import com.nxest.grpc.server.GrpcService;
|
||||
//import com.zyplayer.doc.grpc.proto.BaseMsg;
|
||||
//import com.zyplayer.doc.grpc.proto.ChatMsg;
|
||||
//import com.zyplayer.doc.grpc.proto.User;
|
||||
//import com.zyplayer.doc.grpc.proto.ZyplayerChatGrpc;
|
||||
//import io.grpc.stub.StreamObserver;
|
||||
//
|
||||
///**
|
||||
// * grpc服务测试类,需要mvn compile项目
|
||||
// * @author 暮光:城中城
|
||||
// * @since 2019年3月31日
|
||||
// */
|
||||
//@GrpcService
|
||||
//public class ZyplayerChatService extends ZyplayerChatGrpc.ZyplayerChatImplBase {
|
||||
//
|
||||
// @Override
|
||||
// public void sendText(ChatMsg request, StreamObserver<ChatMsg> responseObserver) {
|
||||
// User user = null;
|
||||
// try {
|
||||
// user = User.newBuilder().setCookies(ByteString.copyFrom("xxx", "utf-8")).build();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// BaseMsg baseMsg = BaseMsg.newBuilder().setCmd(1).setUser(user).build();
|
||||
// ChatMsg reply = ChatMsg.newBuilder().setToken("sendText").setIP("xx.xx.xx.xx").setBaseMsg(baseMsg).build();
|
||||
// responseObserver.onNext(reply);
|
||||
// responseObserver.onCompleted();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendImage(ChatMsg request, StreamObserver<ChatMsg> responseObserver) {
|
||||
// ChatMsg reply = ChatMsg.newBuilder().setToken("sendImage").setIP("xx.xx.xx.xx").build();
|
||||
// responseObserver.onNext(reply);
|
||||
// responseObserver.onCompleted();
|
||||
// }
|
||||
//}
|
||||
@@ -1,36 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package helloworld;
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_package = "com.zyplayer.doc.grpc.proto";
|
||||
option java_outer_classname = "HelloWorldProto";
|
||||
|
||||
// The greeting service definition.
|
||||
service ZyplayerGreeter {
|
||||
// Sends a greeting
|
||||
rpc sayHello (HelloRequest) returns (HelloResponse) {}
|
||||
|
||||
// Sends the current time
|
||||
rpc sayTime (google.protobuf.Empty) returns (TimeResponse) {}
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message HelloRequest {
|
||||
string name = 1;
|
||||
string content = 2;
|
||||
int32 time = 3;
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
message HelloResponse {
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
// The response message containing the time
|
||||
message TimeResponse {
|
||||
google.protobuf.Timestamp time = 1;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
syntax = "proto3";
|
||||
option java_outer_classname = "ChatProto";
|
||||
option java_package = "com.zyplayer.doc.grpc.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
package wechat;
|
||||
option java_multiple_files = true;
|
||||
service ZyplayerChat {
|
||||
// 处理请求
|
||||
rpc sendText (ChatMsg) returns (ChatMsg) {}
|
||||
|
||||
rpc sendImage (ChatMsg) returns (ChatMsg) {}
|
||||
}
|
||||
// 完整的grpc结构体
|
||||
message ChatMsg {
|
||||
BaseMsg baseMsg = 1;
|
||||
string token = 2;
|
||||
string version = 3;
|
||||
int32 timeStamp = 4;
|
||||
string iP = 5;
|
||||
}
|
||||
// 请求消息结构体
|
||||
message BaseMsg {
|
||||
int32 ret = 1;
|
||||
int32 cmd = 2;
|
||||
User user = 3;
|
||||
}
|
||||
// 用户结构体
|
||||
message User {
|
||||
int64 uin = 1;
|
||||
bytes cookies = 2;
|
||||
bytes sessionKey = 3;
|
||||
bytes nickname = 4;
|
||||
}
|
||||
@@ -1,405 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<!--无论发布在哪、如何修改源码,请勿删除本行原作者信息,感谢-->
|
||||
<meta name="author" content="开发者列表:暮光:城中城,项目地址:https://gitee.com/zyplayer/zyplayer-doc" />
|
||||
<title>grpc文档管理系统</title>
|
||||
<link rel="shortcut icon" href="webjars/doc-grpc/img/grpc.png"/>
|
||||
<link rel="stylesheet" href="webjars/doc-grpc/css/element-ui.css">
|
||||
<link rel="stylesheet" href="webjars/doc-grpc/css/doc-grpc.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<el-container style="height: 100%;">
|
||||
<el-aside width="auto" style="height: 100%;">
|
||||
<div class="logo" @click="aboutDialogVisible = true">zyplayer-doc-grpc</div>
|
||||
<div style="padding: 10px;">
|
||||
<!-- <div align="center"><el-button type="primary" v-on:click="reloadService" icon="el-icon-refresh" style="width: 100%;">重新加载服务列表</el-button></div>-->
|
||||
<el-input v-model="searchKeywords" placeholder="搜索文档" style="margin: 10px 0;">
|
||||
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywords"></el-button>
|
||||
</el-input>
|
||||
<el-tree :data="pathIndex" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
|
||||
</div>
|
||||
</el-aside>
|
||||
<el-container>
|
||||
<el-tabs type="border-card" style="width: 100%;">
|
||||
<el-tab-pane label="接口说明">
|
||||
<div v-if="!grpcInfo.service">
|
||||
请先选择服务
|
||||
</div>
|
||||
<el-form v-else label-width="80px">
|
||||
<el-form-item label="服务:">
|
||||
{{grpcInfo.service}}
|
||||
</el-form-item>
|
||||
<el-form-item label="方法:">
|
||||
{{grpcInfo.method}}
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="说明:">-->
|
||||
<!-- <div v-if="grpcInfoExplainShow">-->
|
||||
<!-- <pre>{{grpcInfo.docInfo.explain}}<el-button @click.prevent="grpcInfoExplainShow = false;" style="float: right;">编辑</el-button></pre>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div v-else>-->
|
||||
<!-- <el-input type="textarea" :rows="4" placeholder="维护人员、使用说明、便于搜索的信息" v-model="docInfoExplainInput"></el-input>-->
|
||||
<!-- <el-button @click.prevent="grpcInfoExplainShow = true;" style="float: right;margin: 5px;">取消</el-button>-->
|
||||
<!-- <el-button type="primary" @click.prevent="saveDocInfoExplain" style="float: right;margin: 5px;">保存</el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="参数:">
|
||||
<div v-html="grpcInfo.paramColumn"></div>
|
||||
</el-form-item>
|
||||
<el-form-item label="返回值:">
|
||||
<div v-html="grpcInfo.resultColumn"></div>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="结果:">-->
|
||||
<!-- <div v-if="grpcInfoResultShow">-->
|
||||
<!-- <pre>{{grpcInfo.docInfo.result}}<el-button @click.prevent="grpcInfoResultShow = false;" style="float: right;">编辑</el-button></pre>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div v-else>-->
|
||||
<!-- <el-input type="textarea" :rows="4" placeholder="结果集说明等" v-model="docInfoResultInput"></el-input>-->
|
||||
<!-- <el-button @click.prevent="grpcInfoResultShow = true;" style="float: right;margin: 5px;">取消</el-button>-->
|
||||
<!-- <el-button type="primary" @click.prevent="saveDocInfoResult" style="float: right;margin: 5px;">保存</el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- </el-form-item>-->
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="在线调试">
|
||||
<div v-if="!grpcInfo.service">
|
||||
请先选择服务
|
||||
</div>
|
||||
<div v-loading="onlineDebugLoading" v-else>
|
||||
<el-input placeholder="请输入内容" v-model="grpcInfo.function" class="input-with-select">
|
||||
<el-button slot="append" @click.prevent="requestExecute">执行</el-button>
|
||||
</el-input>
|
||||
<el-form label-width="100px" label-position="top">
|
||||
<el-form-item label="请求参数:">
|
||||
<el-input type="textarea" :rows="20" placeholder="请求参数" v-model="paramColumnRequest"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="请求结果:">
|
||||
<div v-html="requestResult"></div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-container>
|
||||
</el-container>
|
||||
<el-dialog title="关于zyplayer-doc-grpc" :visible.sync="aboutDialogVisible" width="600px">
|
||||
<el-form>
|
||||
<el-form-item label="项目地址:">
|
||||
<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc</a>
|
||||
</el-form-item>
|
||||
<el-form-item label="开发人员:">
|
||||
<a target="_blank" href="http://zyplayer.com">暮光:城中城</a>
|
||||
</el-form-item>
|
||||
<template v-if="upgradeInfo.lastVersion">
|
||||
<el-form-item label="当前版本:">{{upgradeInfo.nowVersion}}</el-form-item>
|
||||
<el-form-item label="最新版本:">{{upgradeInfo.lastVersion}}</el-form-item>
|
||||
<el-form-item label="升级地址:">
|
||||
<a target="_blank" :href="upgradeInfo.upgradeUrl">{{upgradeInfo.upgradeUrl}}</a>
|
||||
</el-form-item>
|
||||
<el-form-item label="升级内容:">{{upgradeInfo.upgradeContent}}</el-form-item>
|
||||
</template>
|
||||
<el-form-item label="">
|
||||
欢迎加群讨论,QQ群号:466363173,欢迎提交需求,欢迎使用和加入开发!
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="webjars/doc-grpc/vue/vue.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-grpc/js/element-ui.js"></script>
|
||||
<!-- ajax 用到了jquery -->
|
||||
<script type="text/javascript" src="webjars/doc-grpc/js/jquery-3.1.0.min.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-grpc/js/common.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-grpc/js/toast.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-grpc/js/formatjson.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-grpc/js/doc-grpc-tree.js"></script>
|
||||
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
isCollapse: false,
|
||||
aboutDialogVisible: false,
|
||||
onlineDebugLoading: false,
|
||||
pathIndex: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
},
|
||||
// 展示的信息
|
||||
grpcInfo: {},
|
||||
grpcInfoExplainShow: true,
|
||||
docInfoExplainInput: "",
|
||||
grpcInfoResultShow: true,
|
||||
docInfoResultInput: "",
|
||||
// 请求的IP端口下拉选项
|
||||
requestResult: "",
|
||||
// 依据目录树存储的map全局对象
|
||||
treePathDataMap: new Map(),
|
||||
// dubbo列表
|
||||
grpcDocList: [],
|
||||
dubboDocMap: [],
|
||||
// 搜索的输入内容
|
||||
searchKeywords: "",
|
||||
docParamList: [],
|
||||
docParamRequestList: [],
|
||||
paramColumnRequest: "",
|
||||
// 参数类型选项
|
||||
paramTypeOptions: [{
|
||||
value: 'java.lang.String'
|
||||
}, {
|
||||
value: 'java.lang.Long'
|
||||
}, {
|
||||
value: 'java.lang.Integer'
|
||||
}],
|
||||
paramTypeValue: "java.lang.String",
|
||||
// 升级信息
|
||||
upgradeInfo: {},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
mounted: function () {
|
||||
// 无论发布在哪、如何修改源码,请勿删除本行原作者信息,感谢
|
||||
console.log("%c项目信息:\n项目地址:https://gitee.com/zyplayer/zyplayer-doc", "color:red");
|
||||
this.doGetServiceList();
|
||||
this.checkSystemUpgrade();
|
||||
},
|
||||
methods: {
|
||||
handleOpen(key, keyPath) {
|
||||
console.log(key, keyPath);
|
||||
},
|
||||
handleClose(key, keyPath) {
|
||||
console.log(key, keyPath);
|
||||
},
|
||||
handleNodeClick(data) {
|
||||
if (data.children == null) {
|
||||
console.log(data);
|
||||
var path = data.interface;
|
||||
this.createDocInfo(path, data.method);
|
||||
}
|
||||
},
|
||||
createDocInfo(path, method) {
|
||||
var grpcInfo = app.treePathDataMap.get(path);
|
||||
var paramColumn = app.columnMap[grpcInfo.paramType];
|
||||
var resultColumn = app.columnMap[grpcInfo.resultType];
|
||||
grpcInfo.method = method;
|
||||
grpcInfo.function = path;
|
||||
grpcInfo.docInfo = {};
|
||||
var paramColumnTemp = this.columnToJsonString(paramColumn || {});
|
||||
app.paramColumnRequest = JSON.stringify(paramColumnTemp, null, 4);
|
||||
grpcInfo.paramColumn = this.processObjectToHtmlPre(paramColumnTemp);
|
||||
var resultColumnTemp = this.columnToJsonString(resultColumn || {});
|
||||
grpcInfo.resultColumn = this.processObjectToHtmlPre(resultColumnTemp);
|
||||
// 清空再赋值才会重新渲染
|
||||
app.grpcInfo = {};
|
||||
app.grpcInfo = grpcInfo;
|
||||
// app.docInfoExplainInput = grpcInfo.docInfo.explain;
|
||||
app.docParamList = [];
|
||||
// app.docParamList = grpcInfo.docInfo.params || [];
|
||||
this.createDocParamRequestList();
|
||||
// 请求相关
|
||||
app.requestResult = "";
|
||||
},
|
||||
columnToJsonString(columns){
|
||||
var param = {};
|
||||
if(!!columns.param && columns.param.length > 0) {
|
||||
param = this.columnArrToJsonString(columns.param);
|
||||
}
|
||||
return param;
|
||||
},
|
||||
columnArrToJsonString(columns) {
|
||||
var param = {};
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
var item = columns[i];
|
||||
if (!!item.param && item.param.length > 0) {
|
||||
param[item.name] = this.columnArrToJsonString(item.param);
|
||||
} else {
|
||||
if (item.type == 'int') {
|
||||
param[item.name] = 0;
|
||||
} else {
|
||||
param[item.name] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return param;
|
||||
},
|
||||
reloadService(){
|
||||
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/reloadService", "post", "json", {}, function (json) {
|
||||
if (validateResult(json)) {
|
||||
app.$message({
|
||||
message: '加载成功!',
|
||||
type: 'success'
|
||||
});
|
||||
app.doGetServiceList();
|
||||
}
|
||||
});
|
||||
},
|
||||
searchByKeywords() {
|
||||
app.pathIndex = createTreeViewByTreeWithMerge(app.grpcDocList, app.searchKeywords);
|
||||
},
|
||||
doGetServiceList() {
|
||||
ajaxTemp("zyplayer-doc-grpc/service", "post", "json", {}, function (json) {
|
||||
if (validateResult(json)) {
|
||||
app.grpcDocList = json.data.serviceList || [];
|
||||
app.columnMap = json.data.columnMap || {};
|
||||
app.pathIndex = createTreeViewByTreeWithMerge(app.grpcDocList);
|
||||
}
|
||||
});
|
||||
},
|
||||
saveDocInfoExplain(){
|
||||
this.doSaveDocInfo(app.docInfoExplainInput, null, null, true);
|
||||
},
|
||||
saveDocInfoResult(){
|
||||
this.doSaveDocInfo(null, null, app.docInfoResultInput, true);
|
||||
},
|
||||
saveDocInfoParam() {
|
||||
var docParamList = [];
|
||||
for (var i = 0; i < app.docParamList.length; i++) {
|
||||
var item = app.docParamList[i];
|
||||
if (isNotEmpty(item.paramType)) {
|
||||
docParamList.push(item);
|
||||
}
|
||||
}
|
||||
var paramsJson = JSON.stringify(docParamList);
|
||||
this.doSaveDocInfo(null, paramsJson, null, true);
|
||||
},
|
||||
createDocParamRequestList() {
|
||||
var docParamList = [];
|
||||
for (var i = 0; i < app.docParamList.length; i++) {
|
||||
var item = app.docParamList[i];
|
||||
if (isNotEmpty(item.paramType) || isNotEmpty(item.paramDesc)) {
|
||||
docParamList.push(item);
|
||||
}
|
||||
}
|
||||
app.docParamRequestList = docParamList;
|
||||
},
|
||||
doSaveDocInfo(explain, params, result, showSuccess){
|
||||
var param = {
|
||||
service: app.grpcInfo.interface,
|
||||
method: app.grpcInfo.method,
|
||||
resultType: app.grpcInfo.resultType,
|
||||
paramValue: app.grpcInfo.paramValue,
|
||||
version: app.grpcInfo.docInfo.version || 0,
|
||||
explain: explain,
|
||||
result: result,
|
||||
paramsJson: params,
|
||||
};
|
||||
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/saveDoc", "post", "json", param, function (json) {
|
||||
if (validateResult(json)) {
|
||||
app.dubboDocMap[json.data.function] = json.data;
|
||||
app.grpcInfo.docInfo = json.data;
|
||||
app.grpcInfoExplainShow = true;
|
||||
app.grpcInfoResultShow = true;
|
||||
app.docParamList = json.data.params || [];
|
||||
app.createDocParamRequestList();
|
||||
if (showSuccess) {
|
||||
Toast.success("保存成功!");
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
addDocParam() {
|
||||
var leadAdd = app.docParamList.length <= 0;
|
||||
if (!leadAdd) {
|
||||
var last = app.docParamList[app.docParamList.length - 1];
|
||||
if (isNotEmpty(last.paramType) || isNotEmpty(last.paramDesc)) {
|
||||
leadAdd = true;
|
||||
}
|
||||
}
|
||||
if (leadAdd) {
|
||||
app.docParamList.push({
|
||||
paramName: '',
|
||||
paramType: '',
|
||||
paramDesc: '',
|
||||
paramValue: '',
|
||||
});
|
||||
}
|
||||
},
|
||||
requestExecute() {
|
||||
var fuc = app.grpcInfo.function;
|
||||
var docService = app.grpcInfo.docService;
|
||||
var service = fuc.substring(0, fuc.lastIndexOf("."));
|
||||
var method = fuc.substring(fuc.lastIndexOf(".") + 1, fuc.length);
|
||||
var paramColumnRequest = JSON.stringify(JSON.parse(app.paramColumnRequest));
|
||||
var param = {
|
||||
docService: docService,
|
||||
method: method,
|
||||
params: paramColumnRequest,//JSON.stringify(params),
|
||||
};
|
||||
app.requestResult = "";
|
||||
app.onlineDebugLoading = true;
|
||||
ajaxTemp("zyplayer-doc-grpc/execute", "post", "json", param, function (json) {
|
||||
app.onlineDebugLoading = false;
|
||||
if (json.errCode == 200) {
|
||||
app.requestResult = app.processObjectToHtmlPre(json.data);
|
||||
//var paramsJson = JSON.stringify(app.docParamRequestList);
|
||||
//app.doSaveDocInfo(null, paramsJson, null, false);
|
||||
} else {
|
||||
app.requestResult = json;
|
||||
}
|
||||
});
|
||||
},
|
||||
processObjectToHtmlPre(data){
|
||||
var requestResult = "";
|
||||
try {
|
||||
requestResult = Formatjson.processObjectToHtmlPre(JSON.parse(data), 0, false, false, false, false);
|
||||
} catch (e) {
|
||||
try {
|
||||
requestResult = Formatjson.processObjectToHtmlPre(data, 0, false, false, false, false);
|
||||
} catch (e) {
|
||||
requestResult = data;
|
||||
}
|
||||
}
|
||||
return requestResult;
|
||||
},
|
||||
checkSystemUpgrade() {
|
||||
ajaxTemp("system/info/upgrade", "post", "json", {}, function (json) {
|
||||
if (json.errCode == 200 && !!json.data) {
|
||||
app.upgradeInfo = json.data;
|
||||
console.log("zyplayer-doc发现新版本:"
|
||||
+ "\n升级地址:" + json.data.upgradeUrl
|
||||
+ "\n当前版本:" + json.data.nowVersion
|
||||
+ "\n最新版本:" + json.data.lastVersion
|
||||
+ "\n升级内容:" + json.data.upgradeContent
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
html,body,#app {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
pre{margin: 0;}
|
||||
.el-menu {
|
||||
box-sizing: border-box;
|
||||
border-right: 0;
|
||||
margin-right: 3px;
|
||||
}
|
||||
.el-tree{
|
||||
margin-right: 3px;
|
||||
}
|
||||
.el-tree-node__content{
|
||||
padding-right: 20px;
|
||||
}
|
||||
.el-tabs--border-card>.el-tabs__content{
|
||||
height: calc(100vh - 100px);overflow-y: auto;
|
||||
}
|
||||
.logo{
|
||||
background: url("webjars/doc-grpc/img/grpc-bg.png") no-repeat; cursor: pointer;
|
||||
width: 100%; height:60px;line-height:60px;font-size: 25px;color: #fff;text-align: center;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
/* S-JSON展示的样式 */
|
||||
pre.json {
|
||||
display: block;
|
||||
padding: 9.5px;
|
||||
margin: 0 0 0 10px;
|
||||
font-size: 12px;
|
||||
line-height: 1.38461538;
|
||||
color: #333;
|
||||
word-break: break-all;
|
||||
word-wrap: break-word;
|
||||
background-color: #f5f5f5;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
pre.json .canvas{font:10pt georgia;background-color:#ececec;color:#000000;border:1px solid #cecece;}
|
||||
pre.json .object-brace{color:#00aa00;font-weight:bold;}
|
||||
pre.json .array-brace{color:#0033ff;font-weight:bold;}
|
||||
pre.json .property-name{color:#cc0000;font-weight:bold;}
|
||||
pre.json .string{color:#007777;}
|
||||
pre.json .number{color:#aa00aa;}
|
||||
pre.json .boolean{color:#0000ff;}
|
||||
pre.json .function{color:#aa6633;text-decoration:italic;}
|
||||
pre.json .null{color:#0000ff;}
|
||||
pre.json .comma{color:#000000;font-weight:bold;}
|
||||
pre.json .annotation{color:#aaa;}
|
||||
pre img{cursor: pointer;}
|
||||
/* E-JSON展示的样式 */
|
||||
|
||||
|
Before Width: | Height: | Size: 340 B |
|
Before Width: | Height: | Size: 331 B |
|
Before Width: | Height: | Size: 371 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,318 +0,0 @@
|
||||
/**
|
||||
* 一些公用方法
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function deserialize(value) {
|
||||
if (typeof value !== 'string' || isEmpty(value)) {
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
try {
|
||||
return eval('(' + value + ')');// 处理变态的单双引号共存字符串
|
||||
} catch (e) {
|
||||
return value || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateResult(result) {
|
||||
if(result.errCode == 200) {
|
||||
return true;
|
||||
} else {
|
||||
Toast.error(result.errMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getNowDate() {
|
||||
var date = new Date();
|
||||
var month = date.getMonth() + 1;
|
||||
var strDate = date.getDate();
|
||||
if (month >= 1 && month <= 9) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (strDate >= 0 && strDate <= 9) {
|
||||
strDate = "0" + strDate;
|
||||
}
|
||||
var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
function getNowTime() {
|
||||
var date = new Date();
|
||||
var hours = date.getHours();
|
||||
var minutes = date.getMinutes();
|
||||
var seconds = date.getSeconds();
|
||||
if (hours >= 1 && hours <= 9) {
|
||||
hours = "0" + hours;
|
||||
}
|
||||
if (minutes >= 0 && minutes <= 9) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
if (seconds >= 0 && seconds <= 9) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
var currentdate = hours + ":" + minutes + ":" + seconds;
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
function getNowDateTime() {
|
||||
var currentdate = getNowDate() + " " + getNowTime();
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回不为空的字符串,为空返回def
|
||||
*/
|
||||
function getNotEmptyStr(str, def) {
|
||||
if (isEmpty(str)) {
|
||||
return isEmpty(def) ? "" : def;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空对象
|
||||
* @param obj
|
||||
* @returns
|
||||
*/
|
||||
function isEmptyObject(obj){
|
||||
return isEmpty(obj) || $.isEmptyObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isEmpty(str){
|
||||
return (str == "" || str == null || str == undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否不是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isNotEmpty(str){
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转字符串,使用空格分隔
|
||||
* @param array
|
||||
* @returns
|
||||
*/
|
||||
function arrToString(array){
|
||||
var temStr = "";
|
||||
if(isEmpty(array)){
|
||||
return temStr;
|
||||
}
|
||||
array.forEach(function(e){
|
||||
if(isNotEmpty(temStr)) {
|
||||
temStr += " ";
|
||||
}
|
||||
temStr += e;
|
||||
});
|
||||
return temStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组array中是否包含str字符串
|
||||
* @param array
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function haveString(array, str){
|
||||
if(isEmpty(array)) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if(array[i] == str) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回对象的第一个属性
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttribute(data) {
|
||||
for ( var key in data) {
|
||||
return data[key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果对象只有一个属性则返回第一个属性,否则返回null
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttributeIfOnly(data) {
|
||||
var len = 0, value = "";
|
||||
for ( var key in data) {
|
||||
if (++len > 1) {
|
||||
return null;
|
||||
}
|
||||
value = data[key];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax处理事件模板
|
||||
*
|
||||
* @url 后台处理的url,即action
|
||||
* @dataSentType 数据发送的方式,有post,get方式
|
||||
* @dataReceiveType 数据接收格式,有html json text等
|
||||
* @paramsStr 传入后台的参数
|
||||
* @successFunction ajax成功后执行的函数名 ajaxTemp("", "GET", "html", {}, function(){},
|
||||
* function(){}, "");
|
||||
*/
|
||||
function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||
$.ajax({
|
||||
url : url, // 后台处理程序
|
||||
sync : false,
|
||||
type : dataSentType, // 数据发送方式
|
||||
dataType : dataReceiveType, // 接受数据格式
|
||||
traditional: true,
|
||||
data : eval(paramsStr),
|
||||
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
success : function(msg) {
|
||||
if(typeof successFunction == "function") {
|
||||
successFunction(msg,id);
|
||||
}
|
||||
},
|
||||
beforeSend : function() {
|
||||
|
||||
},
|
||||
complete : function(msg) {
|
||||
if (msg.responseText.startWith("<!doctype html>")) {
|
||||
if (msg.responseText.indexOf("THIS_IS_LOGIN_PAGE_FLAG") > 0) {
|
||||
app.$confirm('操作失败,登录已失效,请登陆后重试', '提示', {
|
||||
confirmButtonText: '去登陆',
|
||||
cancelButtonText: '知道了',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
window.open("static/manage/login.html");
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(typeof completeFunction == "function") {
|
||||
completeFunction(msg,id);
|
||||
}
|
||||
},
|
||||
error : function(msg) {
|
||||
if(typeof errorFunction == "function") {
|
||||
errorFunction(msg,id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function postWithFile(url, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||
$.ajax({
|
||||
url: url, // 后台处理程序
|
||||
sync: false,
|
||||
type: "POST", // 数据发送方式
|
||||
dataType: "JSON", // 接受数据格式
|
||||
data: eval(paramsStr),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (msg) {
|
||||
if (typeof successFunction == "function") {
|
||||
successFunction(msg, id);
|
||||
}
|
||||
},
|
||||
beforeSend: function () {
|
||||
|
||||
},
|
||||
complete: function (msg) {
|
||||
if (typeof completeFunction == "function") {
|
||||
completeFunction(msg, id);
|
||||
}
|
||||
},
|
||||
error: function (msg) {
|
||||
if (typeof errorFunction == "function") {
|
||||
errorFunction(msg, id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cookie
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
function getCookie(name) {
|
||||
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||
if(arr=document.cookie.match(reg)){
|
||||
return unescape(arr[2]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串格式化
|
||||
*/
|
||||
String.prototype.format = function(args) {
|
||||
if (arguments.length > 0) {
|
||||
var result = this;
|
||||
if (arguments.length == 1 && typeof (args) == "object") {
|
||||
for ( var key in args) {
|
||||
var reg = new RegExp("({" + key + "})", "g");
|
||||
result = result.replace(reg, args[key]);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] == undefined) {
|
||||
return "";
|
||||
} else {
|
||||
var reg = new RegExp("({[" + i + "]})", "g");
|
||||
result = result.replace(reg, arguments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
String.prototype.endWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substring(this.length - str.length) == str);
|
||||
};
|
||||
|
||||
String.prototype.startWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substr(0, str.length) == str);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取父窗口的exports
|
||||
* @returns
|
||||
*/
|
||||
function getExport(){
|
||||
return window.parent.window.exports;
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
/**
|
||||
* 以树形方式生成并展示:
|
||||
* /api
|
||||
* /data
|
||||
* /getDateList
|
||||
* post
|
||||
* get
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年5月26日
|
||||
*/
|
||||
|
||||
/**
|
||||
* 把原始的json字符串转换成对象列表的方式,方便后续使用
|
||||
* @param json swagger的原始对象
|
||||
* @returns
|
||||
*/
|
||||
function createTreeViewByTree(json, keywords) {
|
||||
var pathIndex = [];
|
||||
if (isEmptyObject(json)) {
|
||||
return;
|
||||
}
|
||||
//console.log(paths);
|
||||
var lastId = "";
|
||||
for (var i = 0; i < json.length; i++) {
|
||||
var service = json[i].service;
|
||||
var method = json[i].method;
|
||||
//console.log(key, paths[key]);
|
||||
if (!findInPathsValue(json[i], keywords)) {
|
||||
continue;
|
||||
}
|
||||
var interfaceTemp = service + "." + method;
|
||||
var keyArr = interfaceTemp.split(".");
|
||||
var nowPathObj = null;
|
||||
keyArr.forEach(function(val, index) {
|
||||
//console.log(val, index);
|
||||
if(isEmpty(val) && index == 0) {
|
||||
return;
|
||||
}
|
||||
var nowPath = val;
|
||||
if (nowPathObj == null) {
|
||||
nowPathObj = findNode(pathIndex, nowPath);
|
||||
if (nowPathObj == null) {
|
||||
nowPathObj = {
|
||||
id: pathIndex.length,
|
||||
label: nowPath, children: []
|
||||
};
|
||||
pathIndex.push(nowPathObj);
|
||||
}
|
||||
lastId = nowPathObj.id;
|
||||
nowPathObj = nowPathObj.children;
|
||||
} else {
|
||||
var tempPathObj = findNode(nowPathObj, nowPath);
|
||||
if(tempPathObj == null) {
|
||||
tempPathObj = {
|
||||
id: lastId + "." + nowPathObj.length,
|
||||
label: nowPath, children: []
|
||||
};
|
||||
nowPathObj.push(tempPathObj);
|
||||
}
|
||||
lastId = tempPathObj.id;
|
||||
nowPathObj = tempPathObj.children;
|
||||
if (index == keyArr.length - 1) {
|
||||
var tempPath = interfaceTemp;
|
||||
tempPathObj.children = null;
|
||||
tempPathObj.method = method;
|
||||
tempPathObj.interface = tempPath;
|
||||
app.treePathDataMap.set(tempPath, json[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// console.log(pathIndex);
|
||||
return pathIndex;
|
||||
}
|
||||
|
||||
function createTreeViewByTreeWithMerge(json, keywords) {
|
||||
var pathIndex = createTreeViewByTree(json, keywords);
|
||||
mergeNode(pathIndex);
|
||||
return pathIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找node节点
|
||||
*/
|
||||
function findNode(arr, service){
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if(arr[i].label == service) {
|
||||
return arr[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多层级合并
|
||||
*/
|
||||
function mergeNode(node) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var tempNode = node[i];
|
||||
if (tempNode.children == null
|
||||
|| tempNode.children[0].children == null
|
||||
|| tempNode.children[0].children[0].children == null) {
|
||||
continue;
|
||||
}
|
||||
if (tempNode.children.length == 1) {
|
||||
tempNode.label = tempNode.label + "." + tempNode.children[0].label;
|
||||
tempNode.children = tempNode.children[0].children;
|
||||
i--;
|
||||
}
|
||||
mergeNode(tempNode.children);
|
||||
}
|
||||
}
|
||||
|
||||
function findInPathsValue(pathsValue, keywords) {
|
||||
if (isEmpty(keywords)) {
|
||||
return true;
|
||||
}
|
||||
keywords = keywords.toLowerCase();
|
||||
// 找路径和说明里面包含关键字的
|
||||
var service = pathsValue.service;
|
||||
if (isNotEmpty(service) && service.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
var paramType = pathsValue.paramType;
|
||||
if (getNotEmptyStr(paramType).toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
var resultType = pathsValue.resultType;
|
||||
if (getNotEmptyStr(resultType).toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
var method = pathsValue.method;
|
||||
if (getNotEmptyStr(method).toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||