Merge pull request #1 from raoxiaoyan/v2.0.0

V2.0.0
This commit is contained in:
raoxiaoyan 2020-11-10 15:26:03 +08:00 committed by GitHub
commit 5e83f71da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 1530 additions and 10729 deletions

View File

@ -1,13 +1,36 @@
# kongx
#### Description
kongx是网关kong的可视化界面管理平台(参考konga的部分界面布局方式),能够集中化管理应用不同环境的网关配置,提供同步各环境的网关配置功能,并且具备规范的权限管理、参数配置、环境管理及日志审计等特性。
基于Spring Boot和Spring Cloud开发打包后可以直接运行不需要额外安装Tomcat等应用容器
#### Screenshots
![](https://gitee.com/raoxy/kongx/blob/master/docs/screen.png)
#### Features
Kongx 使用指南请参考:[Wiki](https://www.kancloud.cn/raoxiaoyan/kongx/1984321)
平台快速部署请参见[Quick Start](https://www.kancloud.cn/raoxiaoyan/kongx/1984323)
系统环境默认用户admin/123456(部署登录后,请前往'个人设置'页面,及时修改密码)
## Screenshots
![](./docs/screen.png)
![](./docs/services.png)
![](./docs/service1.png)
![](./docs/kong%20shell.png)
![](./docs/user.png)
![](./docs/env.png)
![](./docs/params.png)
![](./docs/log.png)
![](./docs/synclog.png)
## Features
- Kong Manage:Upstream,Service,Route,Plugin,Consumer等
- 同步Kong配置:同步不同环境间的kong配置便于多环境同一项目配置管理
@ -15,15 +38,42 @@ kongx是网关kong的可视化界面管理平台(参考konga的部分界面布
- 参数管理:具有良好的扩展性,基于平台的参数管理可扩展多环境及服务管理;包括:环境管理、参数参数等
- 日志管理:平台具有完善的日志审计功能,包括:同步日志、操作日志;
#### Quick start
[快速安装](https://gitee.com/raoxy/kongx/wikis/pages?sort_id=2979225&doc_id=983590)
## Kong插件列表
- [官网插件](https://docs.konghq.com/hub/)
- [灰度插件canary](https://gitee.com/raoxy/kong-plugins-canary)
- [防攻击 kong_injection](https://github.com/ror6ax/kong_injection)
#### Kong网关插件列表
- [灰度插件Canary](https://gitee.com/raoxy/kong-plugins-canary)
- [...]
## kong最佳实践
#### kong网关最佳实践
- Kong与consul自主发现服务
- [Kong与consul自主发现服务](https://www.kancloud.cn/raoxiaoyan/kongx/1984357)
- 如何应用灰度插件(canary)及使用场景介绍
- kong插件开发实践
- 整理中...尽情期待
## kongx与kong版本关系
## RoadMap
1、初步计划kongx自适应kong后续所有版本;
2、增加shell界面和可视化管理界面
## 技术支持
![](./docs/Kongx技术支持1群聊二维码.png)
## 版本支持
| 序号 | kongx版本 | Kong版本 | 说明 |
| --- | --- | --- | --- |
| 1 | 1.2.x | 1.2.x | 1.2.x测试|
| 1 | 1.3.x | 1.2.x、1.3.x+ | 只做过1.2.x、1.3.x测试,对1.4.x以上版本与1.3.x对比差异原则上基础功能全部可用(参考差异对比)[https://www.kancloud.cn/raoxiaoyan/kongx/1991178]|
## 升级历史
- 1.3.x发布版本(2020/11/10)
> 1. 增加upstream被动健康检查的配置
> 2. 所有页面由弹窗改为面包屑导航
> 3. 增加版本自适应功能1.3.x可适配至kong所有版本1.3.x,1.4.x,1.5.x,2.0.x,2.1.x)
>
## 参考链接
- [Kong官网](https://docs.konghq.com/1.2.x/admin-api/)
- [OpenResty最佳实践](https://www.kancloud.cn/kancloud/openresty-best-practices/50428)

View File

@ -1,7 +1,7 @@
# kongx
kongx是网关kong的可视化界面管理平台(参考konga的部分界面布局方式),能够集中化管理应用不同环境的网关配置,提供同步各环境的网关配置功能,并且具备规范的权限管理、参数配置、环境管理及日志审计等特性。
kongx(最新版本2.0.0)是网关kong的可视化界面管理平台(参考konga的部分界面布局方式),能够集中化管理应用不同环境的网关配置,提供同步各环境的网关配置功能,并且具备规范的权限管理、参数配置、环境管理及日志审计等特性。
基于Spring Boot和Spring Cloud开发打包后可以直接运行不需要额外安装Tomcat等应用容器
@ -17,23 +17,18 @@ Kongx 使用指南请参考:[Wiki](https://www.kancloud.cn/raoxiaoyan/kongx/19
![](./docs/service1.png)
![](./docs/service2.png)
![](./docs/consumers.png)
![](./docs/certificate.png)
![](./docs/kong%20shell.png)
![](./docs/user.png)
![](./docs/env.png)
![](./docs/params.png)
![](./docs/log.png)
![](./docs/synclog.png)
## Features
- Kong Manage:Upstream,Service,Route,Plugin,Consumer等
- 同步Kong配置:同步不同环境间的kong配置便于多环境同一项目配置管理;
- Kong Manage:Upstream,Service,Route,Plugin,Consumer,Certificates及Ca Certificates等
- 同步Kong配置:不同环境间的kong配置进行同步便于多环境配置管理
- 系统管理:具有完善的权限管理系统,包括:用户管理、菜单管理、角色管理及用户组管理等功能;
- 参数管理:具有良好的扩展性,基于平台的参数管理可扩展多环境及服务管理;包括:环境管理、参数参数等
- 日志管理:平台具有完善的日志审计功能,包括:同步日志、操作日志;
@ -50,13 +45,38 @@ Kongx 使用指南请参考:[Wiki](https://www.kancloud.cn/raoxiaoyan/kongx/19
- kong插件开发实践
- 整理中...尽情期待
## RoadMap
1、初步计划kongx自适应kong后续所有版本;
1、初步计划kongx自适应kong后续所有版本;(已完成自动适配至2.1.x版本)
2、增加shell界面和可视化管理界面
## 技术支持
![](./docs/Kongx技术支持1群聊二维码.png)
<table>
<thead>
<th>Kongx技术支持1群<br />群号980245072(未满)</th>
<th>技术合作<br />请扫描微信二维码</th>
</thead>
<tbody>
<tr>
<td><img src="https://raw.githubusercontent.com/raoxiaoyan/kongx/master/docs/kongx_tech1.png" alt="tech-support-qq-1"></td>
<td><img src="https://raw.githubusercontent.com/raoxiaoyan/kongx/master/docs/cooperate.jpg" alt="cooperate" width="230px;"></td>
</tr>
</tbody>
</table>
## kongx与kong版本关系
| 序号 | kongx版本 | Kong版本 | 说明 |
| --- | --- | --- | --- |
| 1 | 1.2.x | 1.2.x | 1.2.x测试|
| 1 | 2.0.0 | 1.2.x、1.3.x、1.4.x、1.5.x、2.0.x | 目前仅针对kong版本1.2.x、1.3.x测试通过,对1.4.x以上版本与1.3.x对比差异原则上基础功能全部可用(参考差异对比)[https://www.kancloud.cn/raoxiaoyan/kongx/1991178]|
## Upgrade
[更新历史](docs/upgrade.md)
## 参考链接
- [Kong官网](https://docs.konghq.com/1.2.x/admin-api/)
- [OpenResty最佳实践](https://www.kancloud.cn/kancloud/openresty-best-practices/50428)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

BIN
docs/certificate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
docs/consumers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 48 KiB

BIN
docs/service2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 50 KiB

15
docs/upgrade.md Normal file
View File

@ -0,0 +1,15 @@
## 升级向导
- 2.0.0发布(2020/11/10)
> 1. 增加certificate及ca_certificate
> 2. 增加upstream被动健康检查的配置
> 3. 所有页面由弹窗改为面包屑导航
> 4. 增加版本自适应功能2.0.0可适配至kong所有版本1.2.x、1.3.x,1.4.x,1.5.x,2.0.x)
## 1. 升级到2.0.0
参考Kongx [Quick Start](https://www.kancloud.cn/raoxiaoyan/kongx/1984323)
## 2. 1.2.x升级到2.0.0
由1.2.x升级到2.0.0只需要两个步骤:
2.1、 下载2.0.0的kongx安装包具体安装步骤参考 [Quick Start](https://www.kancloud.cn/raoxiaoyan/kongx/1984323)
2.2、 下载数据库升级脚本,[1.2.x to 2.0.0.sql](upgrade/1.2.xto2.0.0log.md)在原1.2.x版本数据库基础上执行即可。

View File

@ -0,0 +1,33 @@
# 1.2.x 升级2.0.0 sql脚本
```sql
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('5', '', 'Snis', 'icon-sni', 'views/gateway/sni/index', 'snis', 'y', 'menu', 'kongx', '7');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('5', '', 'Certificates', 'icon-certificate', 'views/gateway/certificate/index', 'certificate', 'y', 'menu', 'kongx', '8');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('53', 'consumer_add', '新增consumer', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('53', 'consumer_update', '更新consumer', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('53', 'consumer_delete', '删除consumer', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('60', 'certificate_view', '查看certificate', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('60', 'certificate_add', '新增certificate', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('60', 'certificate_update', '修改certificate', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` (`parent_id`, `code`, `name`, `menu_icon`, `visit_view`, `visit_path`, `use_yn`, `menu_type`, `application_code`, `sort_order`) VALUES ('60', 'certificate_delete', '删除certificate', '', '', '', 'y', 'point', 'kongx', '999');
insert into kongx_system_role_function(role_id,half_checked,function_id)
select * from (
select '1' role_id,'n' half_checked,'-1' as function_id
union all
select '1' role_id,'n' half_checked,id as function_id from kongx_system_function
) a
where not EXISTS (select * from kongx_system_role_function b where a.function_id=b.function_id and b.role_id=a.role_id);
insert into kongx_system_role_function(role_id,half_checked,function_id)
select * from (
select '2' role_id,'y' half_checked,'-1' as function_id
union
select '2' role_id,'y' half_checked,id as function_id from kongx_system_function where name in ('Gateway','Upstreams','Services','Routes','Plugins','Kong Shell','Consumers','Certificates','日志管理')
union
select '2' role_id,'n' half_checked,id as function_id from kongx_system_function where code in ('service_view','upstream_view','route_view','plugin_view','consumer_view','certificate_view')
union
select '2' role_id,'n' half_checked,id as function_id from kongx_system_function where name='操作日志'
) a
where not EXISTS (select * from kongx_system_role_function b where a.function_id=b.function_id and b.role_id=a.role_id);
```

BIN
docs/wechat.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>kongx</artifactId>
<groupId>com.kongx</groupId>
<version>1.2.x</version>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -23,7 +23,7 @@ public class KongxBanner implements Banner {
@Override
public void printBanner(Environment environment, Class<?> sourceClass, PrintStream printStream) {
this.print(" :: Support kong :: ", "(v1.2.1)", printStream);
this.print(" :: Support kong :: ", "(v2.0.0)", printStream);
printStream.println(BANNER);
String copyright = " :: Copyright@2020 :: ";
String version = SpringBootVersion.getVersion();

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>kongx</artifactId>
<groupId>com.kongx</groupId>
<version>1.2.x</version>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -14,7 +14,7 @@
<dependency>
<groupId>com.kongx</groupId>
<artifactId>kongx-common</artifactId>
<version>1.2.x</version>
<version>2.0.0</version>
</dependency>
<dependency>

View File

@ -0,0 +1,128 @@
package com.kongx.serve.controller.gateway;
import com.kongx.common.core.entity.UserInfo;
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
import com.kongx.serve.controller.BaseController;
import com.kongx.serve.entity.gateway.CaCertificate;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.system.OperationLog;
import com.kongx.serve.service.gateway.CaCertificateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.net.URISyntaxException;
@RestController("CaCertificateController")
@RequestMapping("/kong/api/")
@Slf4j
public class CaCertificateController extends BaseController {
private static final String CERTIFICATES_URI = "/ca_certificates";
private static final String CERTIFICATES_URI_ID = "/ca_certificates/{id}";
@Autowired
private CaCertificateService caCertificateService;
/**
* 查询所有sni
*
* @return
*/
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.GET)
public JsonHeaderWrapper findAll(UserInfo userInfo) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
KongEntity<CaCertificate> upstreamKongEntity = caCertificateService.findAll(systemProfile(userInfo));
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 新增upstream
*
* @param sni
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.POST)
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody CaCertificate sni) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
CaCertificate results = this.caCertificateService.add(systemProfile(userInfo), sni.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.CaCertificate, sni);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 更新consumer
*
* @param id
* @param sni
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.POST)
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody CaCertificate sni) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
CaCertificate results = this.caCertificateService.update(systemProfile(userInfo), id, sni.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.CaCertificate, sni, sni.getId());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 删除sni
*
* @param id
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.DELETE)
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
CaCertificate sni = this.caCertificateService.findEntity(systemProfile(userInfo), id);
KongEntity<CaCertificate> upstreamKongEntity = this.caCertificateService.remove(systemProfile(userInfo), id);
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.CaCertificate, sni);
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 查询单个sni的信息
*
* @param id
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.GET)
public JsonHeaderWrapper findSni(UserInfo userInfo, @PathVariable String id) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
CaCertificate results = this.caCertificateService.findEntity(systemProfile(userInfo), id);
jsonHeaderWrapper.setData(results);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
}

View File

@ -0,0 +1,128 @@
package com.kongx.serve.controller.gateway;
import com.kongx.common.core.entity.UserInfo;
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
import com.kongx.serve.controller.BaseController;
import com.kongx.serve.entity.gateway.Certificate;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.system.OperationLog;
import com.kongx.serve.service.gateway.CertificateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.net.URISyntaxException;
@RestController("CertificateController")
@RequestMapping("/kong/api/")
@Slf4j
public class CertificateController extends BaseController {
private static final String CERTIFICATES_URI = "/certificates";
private static final String CERTIFICATES_URI_ID = "/certificates/{id}";
@Autowired
private CertificateService certificateService;
/**
* 查询所有sni
*
* @return
*/
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.GET)
public JsonHeaderWrapper findAll(UserInfo userInfo) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
KongEntity<Certificate> upstreamKongEntity = certificateService.findAll(systemProfile(userInfo));
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 新增upstream
*
* @param sni
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.POST)
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Certificate sni) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Certificate results = this.certificateService.add(systemProfile(userInfo), sni.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.Certificate, sni);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 更新consumer
*
* @param id
* @param sni
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.POST)
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Certificate sni) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Certificate results = this.certificateService.update(systemProfile(userInfo), id, sni.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.Certificate, sni, sni.getKey());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 删除sni
*
* @param id
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.DELETE)
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Certificate sni = this.certificateService.findEntity(systemProfile(userInfo), id);
KongEntity<Certificate> upstreamKongEntity = this.certificateService.remove(systemProfile(userInfo), id);
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.Certificate, sni);
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 查询单个sni的信息
*
* @param id
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.GET)
public JsonHeaderWrapper findSni(UserInfo userInfo, @PathVariable String id) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Certificate results = this.certificateService.findEntity(systemProfile(userInfo), id);
jsonHeaderWrapper.setData(results);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
}

View File

@ -5,13 +5,17 @@ import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
import com.kongx.serve.controller.BaseController;
import com.kongx.serve.entity.gateway.Consumer;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.gateway.PluginVO;
import com.kongx.serve.entity.system.OperationLog;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.service.gateway.ConsumerService;
import com.kongx.serve.service.gateway.PluginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.net.URISyntaxException;
import java.util.Map;
@RestController("consumerController")
@RequestMapping("/kong/api/")
@ -19,10 +23,16 @@ import java.net.URISyntaxException;
public class ConsumerController extends BaseController {
private static final String CONSUMER_URI = "/consumers";
private static final String CONSUMER_URI_ID = "/consumers/{id}";
private static final String CONSUMER_URI_plugins = "/consumers/{customerId}/plugins";
private static final String CREDENTIALS_URI = "/consumers/{customerId}/{entityName}";
private static final String CREDENTIALS_URI_ID = "/consumers/{customerId}/{entityName}/{entityId}";
@Autowired
private ConsumerService consumerService;
@Autowired
private PluginService pluginService;
/**
* 查询所有upstream
*
@ -41,6 +51,48 @@ public class ConsumerController extends BaseController {
return jsonHeaderWrapper;
}
@RequestMapping(value = CONSUMER_URI_plugins, method = {RequestMethod.POST})
public JsonHeaderWrapper findAllPlugin(UserInfo userInfo, @PathVariable String customerId, @RequestBody SystemProfile systemProfile) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
SystemProfile activeClient = this.systemProfile(userInfo);
KongEntity<PluginVO> pluginVOKongEntity = pluginService.findAllByConsumer(systemProfile.IS_NULL() ? activeClient : systemProfile, customerId);
jsonHeaderWrapper.setData(pluginVOKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
@RequestMapping(value = CREDENTIALS_URI, method = RequestMethod.GET)
public JsonHeaderWrapper findAllCredentials(UserInfo userInfo, @PathVariable String customerId, @PathVariable String entityName) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
KongEntity<Map> upstreamKongEntity = consumerService.findAllCredentials(systemProfile(userInfo), customerId, entityName);
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
@RequestMapping(value = CREDENTIALS_URI, method = RequestMethod.POST)
public JsonHeaderWrapper addCredentials(UserInfo userInfo, @RequestBody Map map, @PathVariable String customerId, @PathVariable String entityName) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Map results = this.consumerService.addCredentials(systemProfile(userInfo), map, customerId, entityName);
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.CONSUMERS, map);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 新增upstream
*
@ -49,12 +101,12 @@ public class ConsumerController extends BaseController {
* @throws URISyntaxException
*/
@RequestMapping(value = CONSUMER_URI, method = RequestMethod.POST)
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Consumer consumer) {
public JsonHeaderWrapper add(UserInfo userInfo, @RequestBody Consumer consumer) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Consumer results = this.consumerService.add(systemProfile(userInfo), consumer.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.UPSTREAM, consumer.getUsername());
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.CONSUMERS, consumer.getUsername());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
@ -76,7 +128,7 @@ public class ConsumerController extends BaseController {
try {
Consumer results = this.consumerService.update(systemProfile(userInfo), id, consumer.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.UPSTREAM, consumer, consumer.getUsername());
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.CONSUMERS, consumer, consumer.getUsername());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
@ -85,19 +137,34 @@ public class ConsumerController extends BaseController {
}
/**
* 删除consumer
* 删除credential
*
* @param id
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = CREDENTIALS_URI_ID, method = RequestMethod.DELETE)
public JsonHeaderWrapper removeCredential(UserInfo userInfo, @PathVariable String customerId, @PathVariable String entityName,
@PathVariable String entityId) throws Exception {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
KongEntity<Map> upstreamKongEntity =
this.consumerService.removeCredentials(systemProfile(userInfo), customerId, entityName, entityId);
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.CONSUMERS, entityId);
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
@RequestMapping(value = CONSUMER_URI_ID, method = RequestMethod.DELETE)
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Consumer consumer = this.consumerService.findConsumer(systemProfile(userInfo), id);
KongEntity<Consumer> upstreamKongEntity = this.consumerService.remove(systemProfile(userInfo), id);
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.UPSTREAM, consumer);
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.CONSUMERS, consumer);
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());

View File

@ -54,7 +54,6 @@ public class ServiceController extends BaseController {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
SystemProfile activeClient = this.systemProfile(userInfo);
Service service = this.kongFeignService.find(this.systemProfile(userInfo), serviceId);
KongEntity<PluginVO> pluginVOKongEntity = pluginService.findAllPluginByService(systemProfile.IS_NULL() ? activeClient : systemProfile, serviceId);
jsonHeaderWrapper.setData(pluginVOKongEntity.getData());
} catch (Exception e) {
@ -75,7 +74,7 @@ public class ServiceController extends BaseController {
public JsonHeaderWrapper add(UserInfo userInfo, @RequestBody Service service) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Service results = this.kongFeignService.add(systemProfile(userInfo), service);
Service results = this.kongFeignService.add(systemProfile(userInfo), service.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.SERVICE, results, results.getName());
} catch (Exception e) {
@ -97,7 +96,7 @@ public class ServiceController extends BaseController {
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Service service) throws URISyntaxException {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Service results = this.kongFeignService.update(systemProfile(userInfo), id, service);
Service results = this.kongFeignService.update(systemProfile(userInfo), id, service.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.SERVICE, results, results.getName());
} catch (Exception e) {

View File

@ -0,0 +1,128 @@
package com.kongx.serve.controller.gateway;
import com.kongx.common.core.entity.UserInfo;
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
import com.kongx.serve.controller.BaseController;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.gateway.Sni;
import com.kongx.serve.entity.system.OperationLog;
import com.kongx.serve.service.gateway.SniService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.net.URISyntaxException;
@RestController("sniController")
@RequestMapping("/kong/api/")
@Slf4j
public class SniController extends BaseController {
private static final String SNIS_URI = "/snis";
private static final String SNIS_URI_ID = "/snis/{id}";
@Autowired
private SniService sniService;
/**
* 查询所有sni
*
* @return
*/
@RequestMapping(value = SNIS_URI, method = RequestMethod.GET)
public JsonHeaderWrapper findAll(UserInfo userInfo) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
KongEntity<Sni> upstreamKongEntity = sniService.findAll(systemProfile(userInfo));
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 新增upstream
*
* @param sni
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = SNIS_URI, method = RequestMethod.POST)
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Sni sni) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Sni results = this.sniService.add(systemProfile(userInfo), sni.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.SNI, sni);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 更新consumer
*
* @param id
* @param sni
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = SNIS_URI_ID, method = RequestMethod.POST)
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Sni sni) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Sni results = this.sniService.update(systemProfile(userInfo), id, sni.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.SNI, sni, sni.getName());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 删除sni
*
* @param id
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = SNIS_URI_ID, method = RequestMethod.DELETE)
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Sni sni = this.sniService.findEntity(systemProfile(userInfo), id);
KongEntity<Sni> upstreamKongEntity = this.sniService.remove(systemProfile(userInfo), id);
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.SNI, sni);
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
/**
* 查询单个sni的信息
*
* @param id
* @return
* @throws URISyntaxException
*/
@RequestMapping(value = SNIS_URI_ID, method = RequestMethod.GET)
public JsonHeaderWrapper findSni(UserInfo userInfo, @PathVariable String id) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Sni results = this.sniService.findEntity(systemProfile(userInfo), id);
jsonHeaderWrapper.setData(results);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
}

View File

@ -54,11 +54,10 @@ public class UpstreamController extends BaseController {
* @throws URISyntaxException
*/
@RequestMapping(value = UPSTREAM_URI, method = RequestMethod.POST)
@PreAuthorize("upstream_add")
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Upstream upstream) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Upstream results = this.upstreamService.add(systemProfile(userInfo), upstream.clear());
Upstream results = this.upstreamService.add(systemProfile(userInfo), upstream.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.UPSTREAM, upstream, upstream.getName());
} catch (Exception e) {
@ -80,7 +79,7 @@ public class UpstreamController extends BaseController {
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Upstream upstream) {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
Upstream results = this.upstreamService.update(systemProfile(userInfo), id, upstream.clear());
Upstream results = this.upstreamService.update(systemProfile(userInfo), id, upstream.trim());
jsonHeaderWrapper.setData(results);
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.UPSTREAM, upstream, upstream.getName());
} catch (Exception e) {

View File

@ -70,7 +70,7 @@ public class ServerConfigController extends BaseController {
JsonHeaderWrapper jsonHeaderWrapper = this.init();
try {
ServerConfig serverConfig = this.serverConfigService.findByKey(key);
jsonHeaderWrapper.setData(Jackson2Helper.parsonObject(serverConfig.getConfigValue(), new TypeReference<Object>() {
jsonHeaderWrapper.setData(Jackson2Helper.parsonObject(serverConfig.getConfigValue().toString(), new TypeReference<Object>() {
}));
} catch (Exception e) {
jsonHeaderWrapper.setErrmsg(e.getMessage());

View File

@ -0,0 +1,34 @@
package com.kongx.serve.entity.gateway;
import lombok.Data;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Data
/**
* @since 1.3.x
*/
public class CaCertificate implements Comparable {
private Timestamp created_at;
private String cert;
private String id;
private List<String> tags = new ArrayList<>();
@Override
public int compareTo(Object o) {
if (o == null) {
return 1;
}
CaCertificate sni = null;
if (o instanceof CaCertificate) {
sni = (CaCertificate) o;
}
return sni.created_at.compareTo(this.created_at);
}
public CaCertificate trim() {
return this;
}
}

View File

@ -0,0 +1,33 @@
package com.kongx.serve.entity.gateway;
import lombok.Data;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Data
public class Certificate implements Comparable {
private Timestamp created_at;
private String cert;
private String key;
private String id;
private List<String> tags = new ArrayList<>();
private List<String> snis = new ArrayList<>();
@Override
public int compareTo(Object o) {
if (o == null) {
return 1;
}
Certificate sni = null;
if (o instanceof Certificate) {
sni = (Certificate) o;
}
return sni.created_at.compareTo(this.created_at);
}
public Certificate trim() {
return this;
}
}

View File

@ -12,11 +12,12 @@ package com.kongx.serve.entity.gateway;
public class EntityId {
private String id;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
}

View File

@ -28,7 +28,7 @@ public class Plugin implements Comparable {
private List<String> protocols;
private boolean enabled;
private String run_on;
private String consumer;
private EntityId consumer;
private EntityId route;
private String tags;

View File

@ -27,7 +27,7 @@ public class PluginVO extends Plugin {
private List<String> protocols;
private boolean enabled;
private String run_on;
private String consumer;
private EntityId consumer;
private EntityId route;
private String tags;
private String scope = "global";

View File

@ -19,7 +19,7 @@ import java.util.List;
public class Route implements Comparable {
private String id;
private String tags;
private List<String> tags = new ArrayList<>();
private List<String> paths = new ArrayList<>();
private String destinations;
private List<String> protocols;
@ -31,6 +31,7 @@ public class Route implements Comparable {
private int regex_priority;
private boolean strip_path;
private String sources;
private String path_handling;
private Timestamp updated_at;
private int https_redirect_status_code = 426;
private EntityId service;

View File

@ -29,6 +29,10 @@ public class Service implements Comparable {
private long updated_at;
private int retries;
private int write_timeout;
/**
* @since 1.3.x
*/
private EntityId client_certificate;
private List<String> tags;
@Override
@ -44,8 +48,11 @@ public class Service implements Comparable {
}
public Service clear() {
public Service trim() {
this.protocol = set(this.protocol);
if (this.client_certificate != null && this.client_certificate.getId() == null) {
this.client_certificate = null;
}
return this;
}

View File

@ -0,0 +1,32 @@
package com.kongx.serve.entity.gateway;
import lombok.Data;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Data
public class Sni implements Comparable {
private Timestamp created_at;
private String name;
private String id;
private List<String> tags = new ArrayList<>();
private EntityId certificate;
@Override
public int compareTo(Object o) {
if (o == null) {
return 1;
}
Sni sni = null;
if (o instanceof Sni) {
sni = (Sni) o;
}
return sni.created_at.compareTo(this.created_at);
}
public Sni trim() {
return this;
}
}

View File

@ -7,13 +7,18 @@ import com.kongx.serve.entity.gateway.upstream.Healthchecks;
import lombok.Data;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Data
public class Upstream implements Comparable {
private Timestamp created_at;
private String id;
private String tags;
/**
* @since 1.3.x
*/
private String algorithm;
private List<String> tags = new ArrayList<>();
private String hash_on;
private String hash_fallback_header;
private String hash_on_header;
@ -36,7 +41,7 @@ public class Upstream implements Comparable {
return upstream.created_at.compareTo(this.created_at);
}
public Upstream clear() {
public Upstream trim() {
this.hash_fallback = set(this.hash_fallback);
this.hash_on = set(this.hash_on);
this.hash_fallback_header = set(this.hash_fallback_header);
@ -44,6 +49,7 @@ public class Upstream implements Comparable {
this.hash_on_cookie = set(this.hash_on_cookie);
this.hash_on_cookie_path = set(this.hash_on_cookie_path);
this.hash_fallback = set(this.hash_fallback);
this.algorithm = set(this.algorithm);
if (this.healthchecks != null)
this.healthchecks.getActive().setHttps_sni(set(this.healthchecks.getActive().getHttps_sni()));
return this;

View File

@ -81,6 +81,10 @@ public class OperationLog {
ROUTE("route", "路由"),
SERVICE("service", "服务"),
UPSTREAM("upstream", "上游服务"),
SNI("sni", "sni"),
CONSUMERS("consumers", "消费者"),
CaCertificate("ca_certificate", "CA认证"),
Certificate("certificate", "认证"),
TARGETS("targets", "上游代理"),
SYSTEM("system", "系统"),
SYSTEM_ROLE("system_role", "系统角色"),

View File

@ -0,0 +1,8 @@
package com.kongx.serve.feign;
import com.kongx.serve.entity.gateway.CaCertificate;
import org.springframework.cloud.openfeign.FeignClient;
@FeignClient(name = "caCertificateFeignService")
public interface CaCertificateFeignService extends KongFeignService<CaCertificate> {
}

View File

@ -0,0 +1,8 @@
package com.kongx.serve.feign;
import com.kongx.serve.entity.gateway.Certificate;
import org.springframework.cloud.openfeign.FeignClient;
@FeignClient(name = "certificateFeignService")
public interface CertificateFeignService extends KongFeignService<Certificate> {
}

View File

@ -0,0 +1,9 @@
package com.kongx.serve.feign;
import org.springframework.cloud.openfeign.FeignClient;
import java.util.Map;
@FeignClient(name = "credentialsFeignService")
public interface CredentialsFeignService extends KongFeignService<Map> {
}

View File

@ -0,0 +1,8 @@
package com.kongx.serve.feign;
import com.kongx.serve.entity.gateway.Sni;
import org.springframework.cloud.openfeign.FeignClient;
@FeignClient(name = "sniFeignService")
public interface SniFeignService extends KongFeignService<Sni> {
}

View File

@ -0,0 +1,9 @@
package com.kongx.serve.feign;
import org.springframework.cloud.openfeign.FeignClient;
import java.util.Map;
@FeignClient(name = "upstreamMapFeignService")
public interface UpstreamMapFeignService extends KongFeignService<Map> {
}

View File

@ -15,7 +15,7 @@ import java.net.URISyntaxException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
public abstract class AbstractService<T> {
public abstract class AbstractCacheService<T> {
@Autowired
protected ServerConfigService serverConfigService;

View File

@ -0,0 +1,78 @@
package com.kongx.serve.service;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.feign.KongFeignService;
import java.net.URISyntaxException;
public abstract class GatewayService<T> extends AbstractCacheService<KongEntity<T>> {
protected KongFeignService<T> kongFeignService;
protected String CACHE_KEY;
protected String ENTITY_URI = "";
protected String ENTITY_URI_ID = "";
/**
* 查询所有upstream
*
* @return
*/
public KongEntity<T> findAll(SystemProfile systemProfile) {
return this.get(systemProfile, CACHE_KEY).getData();
}
/**
* 新增upstream
*
* @param entity
* @return
* @throws URISyntaxException
*/
public T add(SystemProfile systemProfile, T entity) throws Exception {
T results = this.kongFeignService.add(uri(systemProfile, ENTITY_URI), entity);
refresh(systemProfile, CACHE_KEY);
return results;
}
/**
* 更新sni
*
* @param id
* @param entity
* @return
* @throws URISyntaxException
*/
public T update(SystemProfile systemProfile, String id, T entity) throws Exception {
T results = this.kongFeignService.update(uri(systemProfile, String.format(ENTITY_URI_ID, id)), entity);
refresh(systemProfile, CACHE_KEY);
return results;
}
/**
* 删除sni
*
* @param id
* @return
* @throws URISyntaxException
*/
public KongEntity<T> remove(SystemProfile systemProfile, String id) throws Exception {
this.kongFeignService.remove(uri(systemProfile, String.format(ENTITY_URI_ID, id)));
return refresh(systemProfile, CACHE_KEY).getData();
}
/**
* 查询单个sni的信息
*
* @param id
* @return
* @throws URISyntaxException
*/
public T findEntity(SystemProfile systemProfile, String id) throws URISyntaxException {
return this.kongFeignService.findById(uri(systemProfile, String.format(ENTITY_URI_ID, id)));
}
}

View File

@ -0,0 +1,47 @@
package com.kongx.serve.service.gateway;
import com.kongx.common.cache.CacheResults;
import com.kongx.serve.entity.gateway.CaCertificate;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.feign.CaCertificateFeignService;
import com.kongx.serve.service.GatewayService;
import feign.Feign;
import feign.RequestInterceptor;
import feign.Target;
import feign.codec.Decoder;
import feign.codec.Encoder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import java.net.URISyntaxException;
import java.util.Collections;
@Service("caCertificateService")
@Import(FeignClientsConfiguration.class)
@Slf4j
public class CaCertificateService extends GatewayService<CaCertificate> {
@Autowired
public CaCertificateService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(CaCertificateFeignService.class));
ENTITY_URI = "/ca_certificates";
ENTITY_URI_ID = "/ca_certificates/%s";
CACHE_KEY = "LISTS";
}
@Override
protected String prefix() {
return "CaCertificates";
}
@Override
protected CacheResults<KongEntity<CaCertificate>> loadFromClient(KongCacheKey key) throws URISyntaxException {
log.info("Loading Services {} from kong client!", key);
KongEntity<CaCertificate> kongEntity = this.kongFeignService.findAll(uri(key.getSystemProfile(), ENTITY_URI));
Collections.sort(kongEntity.getData());
return new CacheResults<>(kongEntity);
}
}

View File

@ -0,0 +1,47 @@
package com.kongx.serve.service.gateway;
import com.kongx.common.cache.CacheResults;
import com.kongx.serve.entity.gateway.Certificate;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.feign.CertificateFeignService;
import com.kongx.serve.service.GatewayService;
import feign.Feign;
import feign.RequestInterceptor;
import feign.Target;
import feign.codec.Decoder;
import feign.codec.Encoder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import java.net.URISyntaxException;
import java.util.Collections;
@Service("certificateService")
@Import(FeignClientsConfiguration.class)
@Slf4j
public class CertificateService extends GatewayService<Certificate> {
@Autowired
public CertificateService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(CertificateFeignService.class));
ENTITY_URI = "/certificates";
ENTITY_URI_ID = "/certificates/%s";
CACHE_KEY = "LISTS";
}
@Override
protected String prefix() {
return "Certificates";
}
@Override
protected CacheResults<KongEntity<Certificate>> loadFromClient(KongCacheKey key) throws URISyntaxException {
log.info("Loading Services {} from kong client!", key);
KongEntity<Certificate> kongEntity = this.kongFeignService.findAll(uri(key.getSystemProfile(), ENTITY_URI));
Collections.sort(kongEntity.getData());
return new CacheResults<>(kongEntity);
}
}

View File

@ -1,12 +1,14 @@
package com.kongx.serve.service.gateway;
import com.github.pagehelper.util.StringUtil;
import com.kongx.common.cache.CacheResults;
import com.kongx.serve.entity.gateway.Consumer;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.feign.ConsumerFeignService;
import com.kongx.serve.feign.CredentialsFeignService;
import com.kongx.serve.feign.KongFeignService;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import feign.Feign;
import feign.RequestInterceptor;
import feign.Target;
@ -20,23 +22,29 @@ import org.springframework.stereotype.Service;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@Service("ConsumerService")
@Import(FeignClientsConfiguration.class)
@Slf4j
public class ConsumerService extends AbstractService<KongEntity<Consumer>> {
public class ConsumerService extends AbstractCacheService<KongEntity<Consumer>> {
private static final String CONSUMER_URI = "/consumers";
private static final String CONSUMER_URI_ID = "/consumers/%s";
private static final String CREDENTIALS_URI = "/consumers/%s/%s";
private static final String CREDENTIALS_URI_ID = "/consumers/%s/%s/%s";
private static final String CACHE_CONSUMERS_KEY = "LISTS";
private KongFeignService<Consumer> kongFeignService;
private KongFeignService<Map> credentialsFeignService;
@Autowired
public ConsumerService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(ConsumerFeignService.class))
;
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(ConsumerFeignService.class));
credentialsFeignService = Feign.builder().encoder(encoder).decoder(decoder)
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(CredentialsFeignService.class));
}
/**
@ -48,6 +56,31 @@ public class ConsumerService extends AbstractService<KongEntity<Consumer>> {
return this.get(systemProfile, CACHE_CONSUMERS_KEY).getData();
}
public KongEntity<Map> findAllCredentials(SystemProfile systemProfile, String customerId, String credentials) throws URISyntaxException {
return this.credentialsFeignService.findAll(uri(systemProfile, String.format(CREDENTIALS_URI, customerId, credentials)));
}
public Map addCredentials(SystemProfile systemProfile, Map map, String customerId, String credentials) throws URISyntaxException {
return this.credentialsFeignService.add(uri(systemProfile, String.format(CREDENTIALS_URI, customerId, credentials)), trim(map));
}
private Map trim(Map map) {
Map results = new HashMap();
map.keySet().stream().forEach((key) -> {
Object value = map.get(key);
if (value != null && !StringUtil.isEmpty(value.toString())) {
results.put(key, value);
}
});
return results;
}
public KongEntity<Map> removeCredentials(SystemProfile systemProfile, String customerId, String credentials, String id) throws Exception {
this.credentialsFeignService.remove(uri(systemProfile, String.format(CREDENTIALS_URI_ID, customerId, credentials, id)));
return this.findAllCredentials(systemProfile, customerId, credentials);
}
/**
* 新增upstream
*

View File

@ -2,7 +2,7 @@ package com.kongx.serve.service.gateway;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.feign.KongInfoFeignService;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import feign.Feign;
import feign.Target;
import feign.codec.Decoder;
@ -19,7 +19,7 @@ import java.util.Map;
@Slf4j
@Service("kongInfoService")
@Import(FeignClientsConfiguration.class)
public class KongInfoService extends AbstractService {
public class KongInfoService extends AbstractCacheService {
private static final String INFO_URI = "/";
private static final String STATUS_URI = "/status";

View File

@ -4,7 +4,7 @@ import com.kongx.serve.entity.gateway.*;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.feign.PluginFeignService;
import com.kongx.serve.feign.PluginVOFeignService;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import feign.Feign;
import feign.Target;
import feign.codec.Decoder;
@ -23,10 +23,11 @@ import java.util.Map;
@Slf4j
@Component("pluginService")
@Import(FeignClientsConfiguration.class)
public class PluginService extends AbstractService {
public class PluginService extends AbstractCacheService {
private static final String PLUGIN_URI = "/plugins";
private static final String PLUGIN_ROUTE_URI = "/routes/%s/plugins";
private static final String PLUGIN_SERVICE_URI = "/services/%s/plugins";
private static final String PLUGIN_CONSUMER_URI = "/consumers/%s/plugins";
private static final String PLUGIN_URI_ID = "/plugins/%s";
private static final String PLUGIN_URI_SCHEMA_NAME = "/plugins/schema/%s";
@ -101,6 +102,12 @@ public class PluginService extends AbstractService {
return routeKongEntity;
}
public KongEntity<PluginVO> findAllByConsumer(SystemProfile systemProfile, String serviceId) throws URISyntaxException {
KongEntity<PluginVO> routeKongEntity = this.pluginVOFeignService.findAll(uri(systemProfile, String.format(PLUGIN_CONSUMER_URI, serviceId)));
Collections.sort(routeKongEntity.getData());
return routeKongEntity;
}
public Plugin add(SystemProfile systemProfile, Plugin plugin) throws URISyntaxException {
return this.kongFeignService.add(uri(systemProfile, PLUGIN_URI), plugin);
}
@ -113,6 +120,10 @@ public class PluginService extends AbstractService {
return this.kongFeignService.add(uri(systemProfile, String.format(PLUGIN_SERVICE_URI, serviceId)), plugin);
}
public Plugin addByConsumer(SystemProfile systemProfile, String consumerId, Plugin plugin) throws URISyntaxException {
return this.kongFeignService.add(uri(systemProfile, String.format(PLUGIN_CONSUMER_URI, consumerId)), plugin);
}
public Plugin update(SystemProfile systemProfile, String id, Plugin plugin) throws URISyntaxException {
//先删除再更新
try {

View File

@ -7,7 +7,7 @@ import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.gateway.Route;
import com.kongx.serve.feign.KongFeignService;
import com.kongx.serve.feign.RouteFeignService;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import feign.Feign;
import feign.Target;
import feign.codec.Decoder;
@ -24,7 +24,7 @@ import java.util.Collections;
@Slf4j
@Component("routeService")
@Import(FeignClientsConfiguration.class)
public class RouteService extends AbstractService<KongEntity<Route>> {
public class RouteService extends AbstractCacheService<KongEntity<Route>> {
private static final String CACHE_ROUTES_KEY = "LISTS";
private static final String ROUTE_URI = "/routes";
private static final String ROUTE_URI_ID = "/routes/%s";

View File

@ -6,7 +6,7 @@ import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.gateway.Service;
import com.kongx.serve.feign.KongFeignService;
import com.kongx.serve.feign.ServiceFeignService;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import feign.Feign;
import feign.Target;
import feign.codec.Decoder;
@ -22,7 +22,7 @@ import java.util.Collections;
@Slf4j
@org.springframework.stereotype.Service("serviceService")
@Import(FeignClientsConfiguration.class)
public class ServiceService extends AbstractService<KongEntity<Service>> {
public class ServiceService extends AbstractCacheService<KongEntity<Service>> {
private static final String CACHE_SERVICES_KEY = "LISTS";
private static final String SERVICE_URI = "/services";
private static final String SERVICE_URI_ID = "/services/%s";

View File

@ -0,0 +1,47 @@
package com.kongx.serve.service.gateway;
import com.kongx.common.cache.CacheResults;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.gateway.Sni;
import com.kongx.serve.feign.SniFeignService;
import com.kongx.serve.service.GatewayService;
import feign.Feign;
import feign.RequestInterceptor;
import feign.Target;
import feign.codec.Decoder;
import feign.codec.Encoder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import java.net.URISyntaxException;
import java.util.Collections;
@Service("sniService")
@Import(FeignClientsConfiguration.class)
@Slf4j
public class SniService extends GatewayService<Sni> {
@Autowired
public SniService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(SniFeignService.class));
ENTITY_URI = "/snis";
ENTITY_URI_ID = "/snis/%s";
CACHE_KEY = "LISTS";
}
@Override
protected String prefix() {
return "SNIS";
}
@Override
protected CacheResults<KongEntity<Sni>> loadFromClient(KongCacheKey key) throws URISyntaxException {
log.info("Loading Services {} from kong client!", key);
KongEntity<Sni> kongEntity = this.kongFeignService.findAll(uri(key.getSystemProfile(), ENTITY_URI));
Collections.sort(kongEntity.getData());
return new CacheResults<>(kongEntity);
}
}

View File

@ -7,7 +7,7 @@ import com.kongx.serve.entity.gateway.TargetHealth;
import com.kongx.serve.feign.KongFeignService;
import com.kongx.serve.feign.TargetFeignService;
import com.kongx.serve.feign.TargetHealthFeignService;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import feign.Feign;
import feign.codec.Decoder;
import feign.codec.Encoder;
@ -22,7 +22,7 @@ import java.net.URISyntaxException;
@Service("targetService")
@Import(FeignClientsConfiguration.class)
@Slf4j
public class TargetService extends AbstractService {
public class TargetService extends AbstractCacheService {
private static final String TARGET_URI = "/upstreams/%s/targets";
private static final String TARGET_URI_HEALTH = "/upstreams/%s/health/";
private static final String TARGET_URI_ID = "/upstreams/%s/targets/%s";

View File

@ -2,11 +2,11 @@ package com.kongx.serve.service.gateway;
import com.kongx.common.cache.CacheResults;
import com.kongx.serve.entity.gateway.KongEntity;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.entity.gateway.Upstream;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.feign.KongFeignService;
import com.kongx.serve.feign.UpstreamFeignService;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import feign.Feign;
import feign.RequestInterceptor;
import feign.Target;
@ -24,7 +24,7 @@ import java.util.Collections;
@Service("upstreamService")
@Import(FeignClientsConfiguration.class)
@Slf4j
public class UpstreamService extends AbstractService<KongEntity<Upstream>> {
public class UpstreamService extends AbstractCacheService<KongEntity<Upstream>> {
private static final String UPSTREAM_URI = "/upstreams";
private static final String UPSTREAM_URI_ID = "/upstreams/%s";

View File

@ -38,11 +38,35 @@ public abstract class AbstractSyncHandler implements ISyncHandler {
@Autowired
protected SyncLogService syncLogService;
@Autowired
protected SniService sniService;
@Autowired
protected ConsumerService consumerService;
@Autowired
protected CertificateService certificateService;
@Autowired
protected CaCertificateService caCertificateService;
protected SyncLog syncLog(SyncConfig syncConfig, Object content, SystemProfile src, SystemProfile dest, String comment) {
SyncLog syncLog = new SyncLog();
syncLog.setContent(content);
syncLog.setSyncNo(syncConfig.getSyncNo());
syncLog.setSrc_client(src.getUrl());
syncLog.setDest_client(dest.getUrl());
syncLog.setComment(comment);
return syncLog;
}
protected SyncLog syncLog(SyncConfig syncConfig, Object content, Service service, SystemProfile src, SystemProfile dest) {
SyncLog syncLog = new SyncLog();
syncLog.setContent(content);
if (service != null) {
syncLog.setService(service.getName());
}
syncLog.setSyncNo(syncConfig.getSyncNo());
syncLog.setSrc_client(src.getUrl());
syncLog.setDest_client(dest.getUrl());

View File

@ -1,10 +1,12 @@
package com.kongx.serve.service.gateway.handler;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.entity.gateway.Service;
import com.kongx.serve.entity.gateway.SyncConfig;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.service.gateway.ISyncHandler;
import org.springframework.stereotype.Component;
@Component("defaultSyncHandler")
public class DefaultSyncHandler extends AbstractSyncHandler {
@Override
public ISyncHandler handler(SystemProfile srcClient, SystemProfile destClient, Service service, SyncConfig syncConfig, Object... values) throws Exception {

View File

@ -0,0 +1,46 @@
package com.kongx.serve.service.gateway.handler;
import com.kongx.serve.entity.gateway.*;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.service.gateway.ISyncHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Component("syncConsumersHandler")
public class SyncConsumersHandler extends SyncPluginsHandler {
@Override
public ISyncHandler handler(SystemProfile srcClient, SystemProfile destClient, Service service, SyncConfig syncConfig, Object... values) throws Exception {
KongEntity<Consumer> consumerKongEntity = this.consumerService.findAll(srcClient);
consumerKongEntity.getData().forEach((consumer -> {
try {
this.syncEntity(syncConfig, consumer, srcClient, destClient);
} catch (Exception e) {
e.printStackTrace();
}
}));
return null;
}
private void syncEntity(SyncConfig syncConfig, Consumer consumer, SystemProfile srcClient, SystemProfile destClient) throws Exception {
KongEntity<PluginVO> plugins = pluginService.findAllByConsumer(srcClient, consumer.getId());
this.consumerService.update(destClient, consumer.getId(), consumer);
for (PluginVO plugin : plugins.getData()) {
EntityId entityId = new EntityId();
entityId.setId(consumer.getId());
plugin.setService(entityId);
if (consumer != null) {
plugin.setScope("global");
Map map = new HashMap();
map.put("name", consumer.getId());
plugin.setApplyObject(map);
}
this.syncPlugin(syncConfig, plugin, null, srcClient, destClient);
}
}
}

View File

@ -4,7 +4,7 @@ import com.kongx.common.cache.CacheResults;
import com.kongx.serve.entity.system.ServerConfig;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.mapper.ServerConfigMapper;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -15,7 +15,7 @@ import java.util.List;
@Slf4j
@Service("ServerConfigService")
public class ServerConfigService extends AbstractService<List<ServerConfig>> {
public class ServerConfigService extends AbstractCacheService<List<ServerConfig>> {
private static final String SERVERS_CONFIGS_KEY = "LISTS";
@Autowired
private ServerConfigMapper serverConfigMapper;
@ -48,7 +48,7 @@ public class ServerConfigService extends AbstractService<List<ServerConfig>> {
public URI findUriByCode(SystemProfile systemProfile, String code) throws Exception {
ServerConfig serverConfig = serverConfigService.findByKey(code);
SystemProfile.System system = systemProfile.to(serverConfig.getConfigValue());
SystemProfile.System system = systemProfile.to(serverConfig.getConfigValue().toString());
if (system == null) throw new Exception("Please set Hot config url");
String url = system.getUrl();
if (url.endsWith("/")) {

View File

@ -4,7 +4,7 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.kongx.serve.entity.system.SystemProfile;
import com.kongx.serve.mapper.SystemProfileMapper;
import com.kongx.serve.service.AbstractService;
import com.kongx.serve.service.AbstractCacheService;
import com.kongx.serve.service.gateway.KongInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -15,7 +15,7 @@ import java.util.List;
import java.util.Map;
@Service("SystemProfileService")
public class SystemProfileService extends AbstractService {
public class SystemProfileService extends AbstractCacheService {
@Autowired
private SystemProfileMapper systemProfileMapper;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -51,4 +51,4 @@
.avue-home__sub-title {
color: #ABABAB;
font-size: 12px;
}</style><link href=css/chunk-36d68c6a.889d7b72.css rel=prefetch><link href=css/chunk-a26cd308.ed24a4f2.css rel=prefetch><link href=css/chunk-a425ea88.97c43d12.css rel=prefetch><link href=css/page.42bd69f9.css rel=prefetch><link href=js/chunk-2d0e4caf.fea686c4.js rel=prefetch><link href=js/chunk-36d68c6a.ef28f5a0.js rel=prefetch><link href=js/chunk-a26cd308.1c730ecc.js rel=prefetch><link href=js/chunk-a425ea88.3cdf3785.js rel=prefetch><link href=js/page.b7e3b812.js rel=prefetch><link href=js/views.6a5b74bc.js rel=prefetch><link href=css/app.8ddb58ee.css rel=preload as=style><link href=css/chunk-vendors.b4484bc4.css rel=preload as=style><link href=js/app.eca48846.js rel=preload as=script><link href=js/chunk-vendors.d6b083d4.js rel=preload as=script><link href=css/chunk-vendors.b4484bc4.css rel=stylesheet><link href=css/app.8ddb58ee.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有 JavaScript 支持Avue-cli 将不能正常工作。请启用浏览器的 JavaScript 然后继续。</strong></noscript><div id=app><div class=avue-home><div class=avue-home__main><img class=avue-home__loading src=./svg/loading-spin.svg alt=loading><div class=avue-home__title>正在加载资源</div><div class=avue-home__sub-title>初次加载资源可能需要较多时间 请耐心等待</div></div><div class=avue-home__footer><a href=https://gitee.com/raoxy/kongx target=_blank>https://gitee.com/raoxy/kongx</a></div></div></div><script src=util/aes.js charset=utf-8></script><script src=cdn/vue/2.6.10/vue.min.js charset=utf-8></script><script src=cdn/vuex/3.0.1/vuex.min.js charset=utf-8></script><script src=cdn/vue-router/3.0.1/vue-router.min.js charset=utf-8></script><script src=cdn/axios/1.0.0/axios.min.js charset=utf-8></script><script src=cdn/element-ui/2.13.0/index.js charset=utf-8></script><script src=cdn/xlsx/0.14.1/xlsx.full.min.js charset=utf-8></script><script src=cdn/fileSaver/1.3.8/FileSaver.min.js charset=utf-8></script><script src=cdn/lodash/4.13.1/lodash.min.js charset=utf-8></script><script src=js/chunk-vendors.d6b083d4.js></script><script src=js/app.eca48846.js></script></body></html>
}</style><link href=css/chunk-285ecc27.f26f6cd9.css rel=prefetch><link href=css/chunk-36d68c6a.889d7b72.css rel=prefetch><link href=css/chunk-a425ea88.97c43d12.css rel=prefetch><link href=css/page.3f55036c.css rel=prefetch><link href=js/chunk-285ecc27.fcffaa89.js rel=prefetch><link href=js/chunk-2d0e4caf.fea686c4.js rel=prefetch><link href=js/chunk-36d68c6a.bf68084c.js rel=prefetch><link href=js/chunk-a425ea88.9930a7b1.js rel=prefetch><link href=js/page.a3466907.js rel=prefetch><link href=js/views.428c18a1.js rel=prefetch><link href=css/app.741d39f8.css rel=preload as=style><link href=css/chunk-vendors.cb6420de.css rel=preload as=style><link href=js/app.080bdca3.js rel=preload as=script><link href=js/chunk-vendors.4ee75067.js rel=preload as=script><link href=css/chunk-vendors.cb6420de.css rel=stylesheet><link href=css/app.741d39f8.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有 JavaScript 支持Avue-cli 将不能正常工作。请启用浏览器的 JavaScript 然后继续。</strong></noscript><div id=app><div class=avue-home><div class=avue-home__main><img class=avue-home__loading src=./svg/loading-spin.svg alt=loading><div class=avue-home__title>正在加载资源</div><div class=avue-home__sub-title>初次加载资源可能需要较多时间 请耐心等待</div></div><div class=avue-home__footer><a href=https://gitee.com/raoxy/kongx target=_blank>https://gitee.com/raoxy/kongx</a></div></div></div><script src=util/aes.js charset=utf-8></script><script src=cdn/vue/2.6.10/vue.min.js charset=utf-8></script><script src=cdn/vuex/3.0.1/vuex.min.js charset=utf-8></script><script src=cdn/vue-router/3.0.1/vue-router.min.js charset=utf-8></script><script src=cdn/axios/1.0.0/axios.min.js charset=utf-8></script><script src=cdn/element-ui/2.13.0/index.js charset=utf-8></script><script src=cdn/xlsx/0.14.1/xlsx.full.min.js charset=utf-8></script><script src=cdn/fileSaver/1.3.8/FileSaver.min.js charset=utf-8></script><script src=cdn/lodash/4.13.1/lodash.min.js charset=utf-8></script><script src=js/chunk-vendors.4ee75067.js></script><script src=js/app.080bdca3.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
<svg height="39" viewBox="0 0 120 39" width="120" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="m110.095922 26.2962963h5.619555v-8.6419753h-5.619555zm5.588508-12.037037h4.31557v16.0493827c0 2.654321-.279425 3.1172839-.993513 3.8271605-.55885.5864197-1.459221.8641975-3.011584.8641975h-6.302595l-1.955978-2.1604938v-.8950618h7.9481v-2.191358h-5.433272c-1.645505 0-2.483781-.308642-3.166821-.9876543-.90037-.9259259-1.272938-2.9320988-1.272938-6.7283951s.434662-5.8950617 1.36608-6.8518518c.714087-.6790124 1.583411-.9567901 3.135774-.9567901l3.228916.0308642 2.142261 1.9444444zm-50.9175162-4.2592593h5.0917516l-7.3271547 9.2592593 7.6376274 10.4629629h-5.4022243l-5.8058387-8.2098765h-1.3660797v8.2098765h-4.5949954v-19.7222222h4.5949954v7.654321h1.3660797zm33.5310473 9.1358025v-1.4197531h-1.5523633c-.0310473 0-.0310473 0-.0620946 0h-1.2108433c-.0310473 0-.0310473 0-.0620946 0h-2.3906394v1.4197531 10.5246913h-4.2845227v-15.4012345h2.8253012 1.4592215v.2777777 1.6666667l2.1422613-1.9444444h1.2418906c.1862836-.0308642.4036145-.0308642.6209454-.0308642h1.8628359c1.3039849 0 2.1422609.2777777 2.7321599.8641975.651992.6172839.90037 1.4197531.90037 3.7037037v10.8641975h-4.2845225v-10.3395061c.0620946-.0617284.0620946-.1234568.0620946-.1851852zm-22.5713624 7.1296296h5.6195551v-8.6419753h-5.6195551zm.1862836 3.3950617c-1.5523633 0-2.3906395-.2469136-3.0426321-.9567901-.9935125-1.0185185-1.3971269-2.4074074-1.3971269-6.7592593 0-4.382716.4036144-5.7407407 1.3971269-6.7901234.6519926-.6790124 1.4902688-.9259259 3.0426321-.9259259h5.2159407c1.5523633 0 2.3906395.2469135 3.0426321.9259259.9935125 1.0493827 1.3971269 2.4074074 1.3971269 6.7901234 0 4.3827161-.4036144 5.7407408-1.3971269 6.7592593-.6830399.7098765-1.4902688.9567901-3.0426321.9567901z" fill="#043558"/><path d="m14 33.3688889 1.0606061-1.3688889h7.8484848l4.0909091 5.2266667-.7272727 1.7733333h-10.1212121l.2424242-1.7733333z" fill="#169fcc"/><path d="m16.4 15.5471311 3.7897092-6.5471311h4.4161074l19.7941834 22.9918033-1.5346756 7.0081967h-8.4876958l.5324385-1.9672131z" fill="#14b59a"/><path d="m21 7.75605214 1.8146067-3.3556797 5.4438203-4.40037244 9.3277153 7.31284916-1.2097378 1.23463687 1.6235955 2.24767227v2.405959l-4.6479401 3.7988827-7.7996254-9.24394786z" fill="#1bc263"/><path d="m6.58517555 22.3777778h2.46553966l6.42912879-5.3777778 8.520156 9.9-2.4031209 3.6055556h-7.8647595l-5.43042909 6.9055555-1.24837452 1.5888889h-7.05331599v-8.4638889z" fill="#16bdcc"/></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -13,7 +13,7 @@
<groupId>com.kongx</groupId>
<artifactId>kongx</artifactId>
<packaging>pom</packaging>
<version>1.2.x</version>
<version>2.0.0</version>
<modules>
<module>kongx-serve</module>
<module>kongx-common</module>

View File

@ -14,6 +14,6 @@ cd ..
# package kongx-serve
echo "==== starting to build kongx ===="
mvn clean package -DskipTests -pl kongx-serve -am -Dspring_datasource_url=%kongx_serve_db_url% -Dspring_datasource_username=%kongx_serve_db_username% -Dspring_datasource_password=%kongx_serve_db_password%
mvn clean package -DskipTests -pl kongx-serve -am -Dspring_datasource_url=$kongx_serve_db_url -Dspring_datasource_username=$kongx_serve_db_username -Dspring_datasource_password=$kongx_serve_db_password
echo "==== building kongx finished ===="

View File

@ -254,82 +254,6 @@ CREATE TABLE `kongx_system_role_function` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=351 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='系统角色与菜单关系表';
-- ----------------------------
-- Records of kongx_system_role_function
-- ----------------------------
INSERT INTO `kongx_system_role_function` VALUES ('277', '1', 'n', '-1');
INSERT INTO `kongx_system_role_function` VALUES ('278', '1', 'n', '1');
INSERT INTO `kongx_system_role_function` VALUES ('280', '1', 'n', '5');
INSERT INTO `kongx_system_role_function` VALUES ('281', '1', 'n', '6');
INSERT INTO `kongx_system_role_function` VALUES ('282', '1', 'n', '20');
INSERT INTO `kongx_system_role_function` VALUES ('283', '1', 'n', '21');
INSERT INTO `kongx_system_role_function` VALUES ('284', '1', 'n', '22');
INSERT INTO `kongx_system_role_function` VALUES ('285', '1', 'n', '40');
INSERT INTO `kongx_system_role_function` VALUES ('286', '1', 'n', '7');
INSERT INTO `kongx_system_role_function` VALUES ('287', '1', 'n', '23');
INSERT INTO `kongx_system_role_function` VALUES ('288', '1', 'n', '24');
INSERT INTO `kongx_system_role_function` VALUES ('289', '1', 'n', '26');
INSERT INTO `kongx_system_role_function` VALUES ('290', '1', 'n', '25');
INSERT INTO `kongx_system_role_function` VALUES ('291', '1', 'n', '39');
INSERT INTO `kongx_system_role_function` VALUES ('292', '1', 'n', '8');
INSERT INTO `kongx_system_role_function` VALUES ('293', '1', 'n', '27');
INSERT INTO `kongx_system_role_function` VALUES ('294', '1', 'n', '28');
INSERT INTO `kongx_system_role_function` VALUES ('295', '1', 'n', '41');
INSERT INTO `kongx_system_role_function` VALUES ('296', '1', 'n', '9');
INSERT INTO `kongx_system_role_function` VALUES ('297', '1', 'n', '31');
INSERT INTO `kongx_system_role_function` VALUES ('298', '1', 'n', '42');
INSERT INTO `kongx_system_role_function` VALUES ('299', '1', 'n', '29');
INSERT INTO `kongx_system_role_function` VALUES ('300', '1', 'n', '30');
INSERT INTO `kongx_system_role_function` VALUES ('301', '1', 'n', '53');
INSERT INTO `kongx_system_role_function` VALUES ('302', '1', 'n', '54');
INSERT INTO `kongx_system_role_function` VALUES ('303', '1', 'n', '4');
INSERT INTO `kongx_system_role_function` VALUES ('304', '1', 'n', '10');
INSERT INTO `kongx_system_role_function` VALUES ('305', '1', 'n', '11');
INSERT INTO `kongx_system_role_function` VALUES ('306', '1', 'n', '32');
INSERT INTO `kongx_system_role_function` VALUES ('307', '1', 'n', '43');
INSERT INTO `kongx_system_role_function` VALUES ('308', '1', 'n', '12');
INSERT INTO `kongx_system_role_function` VALUES ('309', '1', 'n', '36');
INSERT INTO `kongx_system_role_function` VALUES ('310', '1', 'n', '37');
INSERT INTO `kongx_system_role_function` VALUES ('311', '1', 'n', '38');
INSERT INTO `kongx_system_role_function` VALUES ('312', '1', 'n', '45');
INSERT INTO `kongx_system_role_function` VALUES ('313', '1', 'n', '47');
INSERT INTO `kongx_system_role_function` VALUES ('314', '1', 'n', '51');
INSERT INTO `kongx_system_role_function` VALUES ('315', '1', 'n', '48');
INSERT INTO `kongx_system_role_function` VALUES ('316', '1', 'n', '49');
INSERT INTO `kongx_system_role_function` VALUES ('317', '1', 'n', '50');
INSERT INTO `kongx_system_role_function` VALUES ('318', '1', 'n', '52');
INSERT INTO `kongx_system_role_function` VALUES ('319', '1', 'n', '13');
INSERT INTO `kongx_system_role_function` VALUES ('320', '1', 'n', '33');
INSERT INTO `kongx_system_role_function` VALUES ('321', '1', 'n', '34');
INSERT INTO `kongx_system_role_function` VALUES ('322', '1', 'n', '35');
INSERT INTO `kongx_system_role_function` VALUES ('323', '1', 'n', '44');
INSERT INTO `kongx_system_role_function` VALUES ('324', '1', 'n', '14');
INSERT INTO `kongx_system_role_function` VALUES ('325', '1', 'n', '15');
INSERT INTO `kongx_system_role_function` VALUES ('326', '1', 'n', '58');
INSERT INTO `kongx_system_role_function` VALUES ('327', '1', 'n', '16');
INSERT INTO `kongx_system_role_function` VALUES ('328', '1', 'n', '46');
INSERT INTO `kongx_system_role_function` VALUES ('329', '1', 'n', '55');
INSERT INTO `kongx_system_role_function` VALUES ('330', '1', 'n', '56');
INSERT INTO `kongx_system_role_function` VALUES ('331', '1', 'n', '17');
INSERT INTO `kongx_system_role_function` VALUES ('332', '1', 'n', '19');
INSERT INTO `kongx_system_role_function` VALUES ('333', '1', 'n', '18');
INSERT INTO `kongx_system_role_function` VALUES ('335', '2', 'n', '1');
INSERT INTO `kongx_system_role_function` VALUES ('336', '2', 'n', '40');
INSERT INTO `kongx_system_role_function` VALUES ('337', '2', 'n', '39');
INSERT INTO `kongx_system_role_function` VALUES ('338', '2', 'n', '41');
INSERT INTO `kongx_system_role_function` VALUES ('339', '2', 'n', '42');
INSERT INTO `kongx_system_role_function` VALUES ('340', '2', 'n', '53');
INSERT INTO `kongx_system_role_function` VALUES ('341', '2', 'n', '54');
INSERT INTO `kongx_system_role_function` VALUES ('342', '2', 'n', '17');
INSERT INTO `kongx_system_role_function` VALUES ('343', '2', 'n', '19');
INSERT INTO `kongx_system_role_function` VALUES ('344', '2', 'n', '18');
INSERT INTO `kongx_system_role_function` VALUES ('345', '2', 'y', '-1');
INSERT INTO `kongx_system_role_function` VALUES ('346', '2', 'y', '5');
INSERT INTO `kongx_system_role_function` VALUES ('347', '2', 'y', '6');
INSERT INTO `kongx_system_role_function` VALUES ('348', '2', 'y', '7');
INSERT INTO `kongx_system_role_function` VALUES ('349', '2', 'y', '8');
INSERT INTO `kongx_system_role_function` VALUES ('350', '2', 'y', '9');
-- ----------------------------
-- Table structure for kongx_system_user_role
-- ----------------------------
@ -417,3 +341,23 @@ CREATE TABLE `kongx_user_info` (
-- Records of kongx_user_info
-- ----------------------------
INSERT INTO `kongx_user_info` VALUES ('admin', 'admin', '', '', '60029c3f5fdb5f1291362f52f7251702507ebc5b', 'activate', 'admin', '2020-09-10 18:21:38');
-- ----------------------------
-- Records of kongx_system_role_function super_admin的权限信息
-- ----------------------------
insert into kongx_system_role_function(role_id,half_checked,function_id)
select '1' role_id,'n' half_checked,'-1' as function_id
union all
select '1' role_id,'n' half_checked,id as function_id from kongx_system_function;
-- ----------------------------
-- Records of kongx_system_role_function 初始化domestic_consumer权限信息
-- ----------------------------
insert into kongx_system_role_function(role_id,half_checked,function_id)
select '2' role_id,'y' half_checked,'-1' as function_id
union
select '2' role_id,'y' half_checked,id as function_id from kongx_system_function where name in ('Gateway','Upstreams','Services','Routes','Plugins','Kong Shell','Consumers','Certificates','日志管理')
union
select '2' role_id,'n' half_checked,id as function_id from kongx_system_function where code in ('service_view','upstream_view','route_view','plugin_view','consumer_view','certificate_view')
union
select '2' role_id,'n' half_checked,id as function_id from kongx_system_function where name='操作日志'

View File

@ -0,0 +1,346 @@
/*
Navicat MySQL Data Transfer
Source Server : 192.168.66.1
Source Server Version : 50725
Source Host : 192.168.66.1:3306
Source Database : kongx_serve
Target Server Type : MYSQL
Target Server Version : 50725
File Encoding : 65001
Date: 2020-11-02 14:12:14
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for kongx_operation_log
-- ----------------------------
DROP TABLE IF EXISTS `kongx_operation_log`;
CREATE TABLE `kongx_operation_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userId` varchar(64) DEFAULT NULL,
`profile` varchar(32) DEFAULT NULL,
`creator` varchar(255) DEFAULT NULL,
`operation_type` varchar(255) DEFAULT NULL,
`content` json DEFAULT NULL,
`target` varchar(255) DEFAULT NULL,
`create_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`remark` varchar(2048) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_target_hash` (`target`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=335 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of kongx_operation_log
-- ----------------------------
-- ----------------------------
-- Table structure for kongx_server_config
-- ----------------------------
DROP TABLE IF EXISTS `kongx_server_config`;
CREATE TABLE `kongx_server_config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`config_key` varchar(255) DEFAULT NULL,
`config_value` text,
`config_type` varchar(255) DEFAULT NULL COMMENT '参数类型',
`comment` varchar(2048) DEFAULT NULL,
`create_at` timestamp NULL DEFAULT NULL,
`creator` varchar(255) DEFAULT NULL,
`modifier` varchar(255) DEFAULT NULL,
`modify_at` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_config_key` (`config_key`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of kongx_server_config
-- ----------------------------
INSERT INTO `kongx_server_config` VALUES ('1', 'super_admin', 'admin,zhangshan', 'system', '超级管理员', '2019-12-12 16:34:07', 'admin', null, '2019-12-12 16:33:58.156');
INSERT INTO `kongx_server_config` VALUES ('6', 'envs', '[\n {\n \"name\": \"开发环境\",\n \"code\": \"dev\",\n \"deployType\": \"beta\",\n \"profiles\": [\n {\n \"profile\":\"f\",\n \"code\":\"betaf\"\n }\n ]\n },\n {\n \"name\": \"测试环境\",\n \"code\": \"beta\",\n \"deployType\": \"beta\",\n \"profiles\": [\n {\n \"profile\":\"a\",\n \"code\":\"betaa\"\n }]\n }]\n', 'system', '环境列表,默认支持', '2019-12-16 17:06:27', null, null, '2019-12-16 16:37:53.122');
INSERT INTO `kongx_server_config` VALUES ('7', 'envs_extension', '[]', 'extension', '环境列表的扩展配置', '2019-12-16 16:09:21', null, null, '2019-12-16 16:08:59.814');
INSERT INTO `kongx_server_config` VALUES ('13', 'default_domains', '[\"examples.com\",\"a.examples.com\"]', null, '默认的网关域名列表', '2020-01-19 11:43:34', null, null, '2020-01-19 11:43:45.75');
INSERT INTO `kongx_server_config` VALUES ('20', 'config_type', '[{\"label\":\"内置参数\",\"value\":\"system\"},{\"label\":\"扩展参数\",\"value\":\"extension\"}]', 'system', '系统内置参数', '2020-04-09 16:36:52', null, null, '2020-04-09 19:19:56.202');
INSERT INTO `kongx_server_config` VALUES ('21', 'config_type_extension', '[]', 'extension', '扩展参数类型', '2020-04-09 19:31:05', null, null, '2020-04-09 19:31:05.433');
-- ----------------------------
-- Table structure for kongx_sync_config
-- ----------------------------
DROP TABLE IF EXISTS `kongx_sync_config`;
CREATE TABLE `kongx_sync_config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sync_no` varchar(255) DEFAULT NULL,
`services` json DEFAULT NULL,
`dest_clients` json DEFAULT NULL,
`comment` varchar(4000) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`creator` varchar(255) DEFAULT NULL,
`create_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`data_type` varchar(255) DEFAULT NULL,
`policy` varchar(255) DEFAULT NULL,
`src_client` json DEFAULT NULL,
`log_type` int(11) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of kongx_sync_config
-- ----------------------------
-- ----------------------------
-- Table structure for kongx_sync_log
-- ----------------------------
DROP TABLE IF EXISTS `kongx_sync_log`;
CREATE TABLE `kongx_sync_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sync_no` varchar(255) DEFAULT NULL,
`service` varchar(255) DEFAULT NULL,
`src_client` varchar(255) DEFAULT NULL,
`dest_client` varchar(255) DEFAULT NULL,
`creator` varchar(255) DEFAULT NULL,
`create_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`status` varchar(255) DEFAULT NULL,
`content` json DEFAULT NULL,
`comment` varchar(2048) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of kongx_sync_log
-- ----------------------------
-- ----------------------------
-- Table structure for kongx_system_function
-- ----------------------------
DROP TABLE IF EXISTS `kongx_system_function`;
CREATE TABLE `kongx_system_function` (
`id` int(64) NOT NULL AUTO_INCREMENT,
`parent_id` bigint(20) DEFAULT NULL COMMENT '父ID',
`code` varchar(64) DEFAULT NULL COMMENT '编码',
`name` varchar(64) NOT NULL COMMENT '菜单名称',
`menu_icon` varchar(512) DEFAULT NULL COMMENT '图标icon',
`visit_view` varchar(2048) DEFAULT NULL COMMENT '访问视图',
`visit_path` varchar(1024) DEFAULT NULL COMMENT '访问路径',
`use_yn` varchar(6) NOT NULL DEFAULT 'y' COMMENT '是否可用n-不可用y-可用',
`menu_type` varchar(20) NOT NULL DEFAULT 'menu' COMMENT '菜单类型(menu=菜单,point=功能点)',
`application_code` varchar(64) NOT NULL DEFAULT 'kongx' COMMENT '所属系统code',
`sort_order` int(11) DEFAULT '0' COMMENT '排序,小的在前面',
PRIMARY KEY (`id`),
KEY `nh_parentid` (`parent_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8mb4 COMMENT='系统菜单表';
-- ----------------------------
-- Records of kongx_system_function
-- ----------------------------
INSERT INTO `kongx_system_function` VALUES ('1', '-1', '', '首页', 'icon-shouye', 'page/wel', '/home', 'y', 'menu', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('4', '5', '', 'Kong Shell', 'icon-shell', 'views/gateway/shell/index', 'shell', 'y', 'menu', 'kongx', '9');
INSERT INTO `kongx_system_function` VALUES ('5', '-1', null, 'Gateway', 'icon-gateway', '', '/gateway', 'y', 'menu', 'kongx', '4');
INSERT INTO `kongx_system_function` VALUES ('6', '5', '', 'Upstreams', 'icon-gateway', 'views/gateway/upstream/index', 'upstream', 'y', 'menu', 'kongx', '2');
INSERT INTO `kongx_system_function` VALUES ('7', '5', null, 'Services', 'icon-services', 'views/gateway/service/index', 'service', 'y', 'menu', 'kongx', '3');
INSERT INTO `kongx_system_function` VALUES ('8', '5', '', 'Routes', 'icon-route', 'views/gateway/routing/index', 'routing', 'y', 'menu', 'kongx', '4');
INSERT INTO `kongx_system_function` VALUES ('9', '5', '', 'Plugins', 'icon-plugin', 'views/gateway/plugin/index', 'plugin', 'y', 'menu', 'kongx', '5');
INSERT INTO `kongx_system_function` VALUES ('10', '-1', '', '系统管理', 'icon-system', '', '/system', 'y', 'menu', 'kongx', '6');
INSERT INTO `kongx_system_function` VALUES ('11', '10', null, '用户管理', 'icon-yonghuguanli', 'views/admin/user/index', 'user', 'y', 'menu', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('12', '10', null, '角色管理', 'icon-quanxianguanli', 'views/admin/role/index', 'role', 'y', 'menu', 'kongx', '2');
INSERT INTO `kongx_system_function` VALUES ('13', '10', null, '菜单管理', 'icon-caidanguanli', 'views/admin/menu/index', 'menu', 'y', 'menu', 'kongx', '4');
INSERT INTO `kongx_system_function` VALUES ('14', '-1', null, '参数管理', 'icon-canshuguanli', '', '/operating', 'y', 'menu', 'kongx', '7');
INSERT INTO `kongx_system_function` VALUES ('15', '14', null, '环境管理', 'icon-huanjingguanli', 'views/operating/env/index', 'envs', 'y', 'menu', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('16', '14', null, '系统参数', 'icon-xitongcanshu', 'views/operating/params/index', 'params', 'y', 'menu', 'kongx', '2');
INSERT INTO `kongx_system_function` VALUES ('17', '-1', null, '日志管理', 'icon-rizhiguanli1', '', '/audit', 'y', 'menu', 'kongx', '8');
INSERT INTO `kongx_system_function` VALUES ('18', '17', '', '同步日志', 'icon-sync', 'views/operating/synclog/index', 'synclog', 'y', 'menu', 'kongx', '3');
INSERT INTO `kongx_system_function` VALUES ('19', '17', null, '操作日志', 'icon-log', 'views/operating/log/index', 'operationlog', 'y', 'menu', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('20', '6', 'upstream_add', '新增上游代理', '', '', '', 'y', 'point', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('21', '6', 'upstream_update', '修改上游代理', '', '', '', 'y', 'point', 'kongx', '2');
INSERT INTO `kongx_system_function` VALUES ('22', '6', 'upstream_delete', '删除上游代理', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('23', '7', 'service_add', '新增服务', '', '', '', 'y', 'point', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('24', '7', 'service_update', '修改服务', '', '', '', 'y', 'point', 'kongx', '2');
INSERT INTO `kongx_system_function` VALUES ('25', '7', 'service_delete', '删除服务', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('26', '7', 'service_sync', '同步服务', '', '', '', 'y', 'point', 'kongx', '4');
INSERT INTO `kongx_system_function` VALUES ('27', '8', 'route_update', '更新路由', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('28', '8', 'route_delete', '删除路由', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('29', '9', 'plugin_update', '更新插件', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('30', '9', 'plugin_delete', '删除插件', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('31', '9', 'plugin_add', '新增插件', '', '', '', 'y', 'point', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('32', '11', 'user_authority', '用户授权', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('33', '13', 'menu_add', '新建菜单', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('34', '13', 'menu_delete', '删除菜单', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('35', '13', 'menu_update', '修改菜单', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('36', '12', 'role_add', '新建角色', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('37', '12', 'role_update', '修改角色', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('38', '12', 'role_config', '配置权限', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('39', '7', 'service_view', '查看服务', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('40', '6', 'upstream_view', '查看上游代理', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('41', '8', 'route_view', '查看路由', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('42', '9', 'plugin_view', '查看插件', '', '', '', 'y', 'point', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('43', '11', 'user_view', '查看用户列表', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('44', '13', 'menu_view', '查看菜单', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('45', '12', 'role_view', '查看角色', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('46', '16', 'params_view', '查看系统参数', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('47', '10', null, '用户组管理', 'icon-yonghuzuguanli', 'views/admin/usergroup/index', 'group', 'y', 'menu', 'kongx', '3');
INSERT INTO `kongx_system_function` VALUES ('48', '47', 'usergroup_add', '新增用户组', '', '', '', 'y', 'point', 'kongx', '2');
INSERT INTO `kongx_system_function` VALUES ('49', '47', 'usergroup_update', '修改用户组', '', '', '', 'y', 'point', 'kongx', '2');
INSERT INTO `kongx_system_function` VALUES ('50', '47', 'usergroup_delete', '删除用户组', '', '', '', 'y', 'point', 'kongx', '3');
INSERT INTO `kongx_system_function` VALUES ('51', '47', 'usergroup_view', '查看用户组', '', '', '', 'y', 'point', 'kongx', '1');
INSERT INTO `kongx_system_function` VALUES ('52', '47', 'usergroup_config', '用户组配置', '', '', '', 'y', 'point', 'kongx', '4');
INSERT INTO `kongx_system_function` VALUES ('53', '5', '', 'Consumers', 'icon-consumer', 'views/gateway/consumer/index', '', 'y', 'menu', 'kongx', '6');
INSERT INTO `kongx_system_function` VALUES ('54', '53', 'consumer_view', '查看consumer', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('55', '16', 'params_add', '新增参数', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('56', '16', 'params_update', '修改参数', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('58', '15', 'manage_env', '环境维护', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('59', '5', '', 'Snis', 'icon-sni', 'views/gateway/sni/index', 'snis', 'y', 'menu', 'kongx', '7');
INSERT INTO `kongx_system_function` VALUES ('60', '5', '', 'Certificates', 'icon-certificate', 'views/gateway/certificate/index', 'certificate', 'y', 'menu', 'kongx', '8');
INSERT INTO `kongx_system_function` VALUES ('61', '53', 'consumer_add', '新增consumer', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('62', '53', 'consumer_update', '更新consumer', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('63', '53', 'consumer_delete', '删除consumer', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('64', '60', 'certificate_view', '查看certificate', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('65', '60', 'certificate_add', '新增certificate', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('66', '60', 'certificate_update', '修改certificate', '', '', '', 'y', 'point', 'kongx', '999');
INSERT INTO `kongx_system_function` VALUES ('67', '60', 'certificate_delete', '删除certificate', '', '', '', 'y', 'point', 'kongx', '999');
-- ----------------------------
-- Table structure for kongx_system_profile
-- ----------------------------
DROP TABLE IF EXISTS `kongx_system_profile`;
CREATE TABLE `kongx_system_profile` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`profile_code` varchar(255) DEFAULT NULL COMMENT '环境编码',
`name` varchar(255) DEFAULT NULL,
`env` varchar(255) DEFAULT NULL COMMENT '所属环境',
`deploy_type` varchar(255) DEFAULT NULL COMMENT '部署类型',
`ab` varchar(255) DEFAULT NULL COMMENT '简称',
`version` varchar(255) DEFAULT '' COMMENT 'kong版本号',
`url` varchar(255) DEFAULT NULL,
`extensions` varchar(4000) DEFAULT NULL,
`create_at` timestamp NULL DEFAULT NULL,
`profile` varchar(255) DEFAULT NULL,
`creator` varchar(255) DEFAULT NULL,
`remark` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uh_profile_code` (`profile_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for kongx_system_role
-- ----------------------------
DROP TABLE IF EXISTS `kongx_system_role`;
CREATE TABLE `kongx_system_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(64) DEFAULT NULL COMMENT '角色编码',
`name` varchar(64) DEFAULT NULL COMMENT '角色名称',
`role_type` varchar(32) DEFAULT NULL COMMENT '角色类型: roleType 菜单角色,数据权限角色',
`sort_order` bigint(20) DEFAULT NULL COMMENT '排序',
`use_yn` varchar(6) DEFAULT NULL COMMENT '是否可用n-不可用y-可用',
`remark` varchar(1024) DEFAULT NULL COMMENT '备注',
`create_at` timestamp NULL DEFAULT NULL,
`creator` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`modifier` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '修改人',
`modify_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='系统角色表';
-- ----------------------------
-- Records of kongx_system_role
-- ----------------------------
INSERT INTO `kongx_system_role` VALUES ('1', 'super_admin', '超级管理员', 'menu', null, 'y', null, '2020-05-11 16:00:00', 'admin', 'admin', '2020-09-28 15:05:49');
INSERT INTO `kongx_system_role` VALUES ('2', 'domestic_consumer', '普通用户', 'menu', null, 'y', null, '2020-05-09 16:42:53', 'admin', 'admin', '2020-09-28 15:05:51');
-- ----------------------------
-- Table structure for kongx_system_role_function
-- ----------------------------
DROP TABLE IF EXISTS `kongx_system_role_function`;
CREATE TABLE `kongx_system_role_function` (
`id` int(64) NOT NULL AUTO_INCREMENT,
`role_id` bigint(20) DEFAULT NULL COMMENT '角色Id',
`half_checked` varchar(11) DEFAULT 'y' COMMENT '是否半选中',
`function_id` bigint(20) DEFAULT NULL COMMENT '菜单id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=854 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='系统角色与菜单关系表';
-- ----------------------------
-- Table structure for kongx_system_user_role
-- ----------------------------
DROP TABLE IF EXISTS `kongx_system_user_role`;
CREATE TABLE `kongx_system_user_role` (
`id` int(64) NOT NULL AUTO_INCREMENT,
`user_id` varchar(64) DEFAULT NULL COMMENT '用户Id',
`role_id` bigint(20) DEFAULT NULL COMMENT '角色id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户与角色关系表';
-- ----------------------------
-- Records of kongx_system_user_role
-- ----------------------------
-- ----------------------------
-- Table structure for kongx_user_group
-- ----------------------------
DROP TABLE IF EXISTS `kongx_user_group`;
CREATE TABLE `kongx_user_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(1024) DEFAULT NULL COMMENT '用户组名称',
`use_yn` varchar(255) DEFAULT NULL COMMENT '是否可用',
`create_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`creator` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建人',
`modifier` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '修改人',
`modify_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户组';
-- ----------------------------
-- Records of kongx_user_group
-- ----------------------------
-- ----------------------------
-- Table structure for kongx_user_group_role
-- ----------------------------
DROP TABLE IF EXISTS `kongx_user_group_role`;
CREATE TABLE `kongx_user_group_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL COMMENT '用户组ID',
`role_id` int(11) NOT NULL COMMENT '角色ID',
`profile` varchar(255) NOT NULL COMMENT '所属环境',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户组与角色关系表';
-- ----------------------------
-- Records of kongx_user_group_role
-- ----------------------------
-- ----------------------------
-- Table structure for kongx_user_group_user
-- ----------------------------
DROP TABLE IF EXISTS `kongx_user_group_user`;
CREATE TABLE `kongx_user_group_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL COMMENT '用户组ID',
`user_id` varchar(255) NOT NULL COMMENT '用户ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户组与用户的关系表';
-- ----------------------------
-- Records of kongx_user_group_user
-- ----------------------------
-- ----------------------------
-- Table structure for kongx_user_info
-- ----------------------------
DROP TABLE IF EXISTS `kongx_user_info`;
CREATE TABLE `kongx_user_info` (
`user_id` varchar(50) NOT NULL COMMENT '用户Id',
`name` varchar(50) NOT NULL COMMENT '用户名',
`email` varchar(50) DEFAULT '' COMMENT '邮箱',
`mobile` varchar(50) DEFAULT NULL COMMENT '手机号',
`password` varchar(255) NOT NULL,
`status` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '状态',
`creator` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建人',
`create_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`user_id`),
KEY `mobile` (`mobile`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
-- ----------------------------
-- Records of kongx_user_info
-- ----------------------------
INSERT INTO `kongx_user_info` VALUES ('admin', 'admin', '', '', '60029c3f5fdb5f1291362f52f7251702507ebc5b', 'activate', 'admin', '2020-09-10 18:21:38');