23 | );
24 | }
25 |
--------------------------------------------------------------------------------
/qing-gateway-front/src/pages/menuConfig.tsx:
--------------------------------------------------------------------------------
1 | import {
2 | SmileOutlined,
3 | LineChartOutlined, SettingOutlined,
4 | FileSearchOutlined, ControlOutlined,
5 | GatewayOutlined, GroupOutlined,
6 | InteractionOutlined, WifiOutlined
7 | } from '@ant-design/icons';
8 | import type { MenuDataItem } from '@ant-design/pro-layout';
9 |
10 | const asideMenuConfig: MenuDataItem[] = [
11 | {
12 | name: '主页',
13 | path: '/',
14 | icon: ,
15 | },
16 | {
17 | name: '监控',
18 | path: '/monitor',
19 | icon: ,
20 | },
21 | {
22 | name: '路由配置',
23 | icon: ,
24 | path: '/route',
25 | },
26 | {
27 | name: '网关节点',
28 | path: '/gatewayNode',
29 | icon: ,
30 | },
31 | {
32 | name: '服务实例',
33 | path: '/serviceAndInstance',
34 | icon: ,
35 | },
36 | {
37 | name: '限流规则',
38 | path: '/limit',
39 | icon: ,
40 | },
41 | {
42 | name: '负载均衡',
43 | path: '/loadBalance',
44 | icon: ,
45 | },
46 | {
47 | name: '调用行为日志',
48 | path: '/logPage',
49 | icon: ,
50 | },
51 | {
52 | name: '系统初始化',
53 | path: '/config',
54 | icon: ,
55 | },
56 | ];
57 |
58 | export { asideMenuConfig };
59 |
--------------------------------------------------------------------------------
/qing-gateway-front/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/qing-gateway-front/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "./",
4 | "module": "ESNext",
5 | "target": "ESNext",
6 | "lib": ["DOM", "ESNext", "DOM.Iterable"],
7 | "jsx": "react-jsx",
8 | "moduleResolution": "node",
9 | "allowSyntheticDefaultImports": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "noImplicitReturns": true,
12 | "noImplicitThis": true,
13 | "noImplicitAny": false,
14 | "importHelpers": true,
15 | "strictNullChecks": true,
16 | "suppressImplicitAnyIndexErrors": true,
17 | "skipLibCheck": true,
18 | "paths": {
19 | "@/*": ["./src/*"],
20 | "ice": [".ice"]
21 | }
22 | },
23 | "include": ["src", ".ice"],
24 | "exclude": ["build"]
25 | }
26 |
--------------------------------------------------------------------------------
/qing-gateway/.gitignore:
--------------------------------------------------------------------------------
1 | # maven ignore
2 | target/
3 | *.class
4 | *.jar
5 | *.war
6 | *.zip
7 | *.tar
8 | *.tar.gz
9 | dependency-reduced-pom.xml
10 |
11 | # maven plugin ignore
12 | release.properties
13 | cobertura.ser
14 | *.gpg
15 |
16 | # eclipse ignore
17 | .settings/
18 | .project
19 | .classpath
20 |
21 | # idea ignore
22 | .idea/
23 | *.ipr
24 | *.iml
25 | *.iws
26 |
27 | # temp ignore
28 | logs/
29 | *.log
30 | *.doc
31 | *.cache
32 | *.diff
33 | *.patch
34 | *.tmp
35 |
36 | # system ignore
37 | .DS_Store
38 | Thumbs.db
39 |
40 | # agent build ignore
41 | /agent/
--------------------------------------------------------------------------------
/qing-gateway/README.md:
--------------------------------------------------------------------------------
1 | # qing-gateway
2 |
3 | - 基于Webflux的网关服务,非阻塞IO
4 |
5 | - 微服务注册中心选用nacos
6 |
7 | - 基于责任链模式+插件化思想,网关处理逻辑抽象成插件链
8 |
9 | - 支持http、https协议
10 |
11 | - 支持自定义路由规则
12 |
13 | - 支持跨域
14 |
15 | 
16 |
17 |
18 | ## 后台模块介绍
19 |
20 | - qing-server: 网关节点server
21 | - qing-admin:网关admin管理台,可配置路由、限流、负载均衡规则、实时监控网关节点等
22 | - qing-common:项目的公共包
23 | - client-example-medical:微服务案例1
24 | - client-example-traffic:微服务案例2
25 |
26 |
27 |
28 | ## 压测资源分配
29 |
30 | | ip | | |
31 | | --------------- | ------------- | :----- |
32 | | 124.222.60.243 | 网关1、nacos配置中心 | 少煜服务器 |
33 | | 101.201.143.127 | admin、redis | 阿里云服务器 |
34 | | 124.222.224.173 | 网关2 | 栋的服务器 |
35 | | 150.158.97.5 | mysql8 | 青训营服务器 |
36 | | localhost | nginx | |
37 | | 101.42.243.67 | 网关3 | 帅的服务器 |
38 |
39 |
40 |
41 | | 服务名 | 实例 | url |
42 | | ------- | --------- | -------------------- |
43 | | traffic | example1 | 124.222.224.173:8900 |
44 | | traffic | example12 | 124.222.224.173:8901 |
45 | | medical | example2 | 124.222.224.173:8500 |
46 | | traffic | example13 | 101.42.243.67:8900 |
47 | | | | |
48 |
49 |
50 |
51 | | 网关节点 | | |
52 | | -------------------- | ---- | ---- |
53 | | 124.222.60.243:8080 | | |
54 | | 124.222.224.173:8080 | | |
55 | | 101.42.243.67:8080 | | |
56 |
57 | netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t",state[key]}'
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/qing-gateway/qing-admin/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/admin_dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jre-alpine
2 | MAINTAINER conghuhu
3 | ADD ./qing_admin.jar /qing_admin.jar
4 | CMD java -jar /qing_admin.jar --spring.profiles.active=prod
5 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/http/网关客户端测试.http:
--------------------------------------------------------------------------------
1 | ### 网关集群测试接口1Get——对应转发至traffic服务(限流 每分钟2次)
2 | GET http://localhost:8080/example1/traffic/getTraffic
3 |
4 | ### 网关集群测试接口1Post——对应转发至traffic服务
5 | POST http://localhost:8080/example1/traffic/setTraffic
6 |
7 | ### 网关集群测试接口1Post——对应转发至traffic服务 带body
8 | POST http://localhost:8080/example1/traffic/getTrafficByPage
9 | Content-Type: application/json
10 |
11 | {
12 | "pageNum": 1,
13 | "pageSize": 10,
14 | "content": "分页效果不错"
15 | }
16 |
17 | ### 网关集群测试接口2——对应转发至medical服务 Get
18 | GET http://localhost:8080/example2/medical/getMedical
19 |
20 | ### 网关集群测试接口2——对应转发至medical服务 Post
21 | POST http://localhost:8080/example2/medical/setMedical
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/QingAdminApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin;
17 |
18 | import lombok.extern.slf4j.Slf4j;
19 | import org.springframework.boot.SpringApplication;
20 | import org.springframework.boot.autoconfigure.SpringBootApplication;
21 | import org.springframework.transaction.annotation.EnableTransactionManagement;
22 | import springfox.documentation.oas.annotations.EnableOpenApi;
23 |
24 | import javax.annotation.PostConstruct;
25 | import java.util.TimeZone;
26 |
27 | @Slf4j
28 | @SpringBootApplication
29 | @EnableOpenApi
30 | @EnableTransactionManagement
31 | public class QingAdminApplication {
32 |
33 | @PostConstruct
34 | void setDefaultTimezone() {
35 | TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
36 | }
37 |
38 | public static void main(String[] args) throws Exception {
39 | SpringApplication.run(QingAdminApplication.class, args);
40 | log.info("QingAdminApplication start success");
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/cache/LoadBalanceCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.cache;
17 |
18 | import java.util.List;
19 | import java.util.concurrent.CopyOnWriteArrayList;
20 | import java.util.stream.Collectors;
21 |
22 | /**
23 | * @author conghuhu
24 | * @create 2022-04-12 10:13
25 | */
26 | public class LoadBalanceCache {
27 |
28 | private static final List loadBalanceList = new CopyOnWriteArrayList<>();
29 |
30 | private static String currentLoadBalance;
31 |
32 | public static void addAll(List list) {
33 | loadBalanceList.addAll(list);
34 | List distinctList = loadBalanceList.stream().distinct().collect(Collectors.toList());
35 | loadBalanceList.clear();
36 | loadBalanceList.addAll(distinctList);
37 | }
38 |
39 | public static List getAll() {
40 | return loadBalanceList;
41 | }
42 |
43 | public static String getCurrentLoadBalance() {
44 | return currentLoadBalance;
45 | }
46 |
47 | public static void setCurrentLoadBalance(String currentLoadBalance) {
48 | LoadBalanceCache.currentLoadBalance = currentLoadBalance;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/config/MybatisPlusConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.config;
17 |
18 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
19 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
20 | import org.springframework.context.annotation.Bean;
21 | import org.springframework.context.annotation.Configuration;
22 |
23 | @Configuration
24 | public class MybatisPlusConfig {
25 | @Bean
26 | public MybatisPlusInterceptor paginationInterceptor() {
27 | MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
28 | // 分页拦截器
29 | PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
30 | paginationInnerInterceptor.setOverflow(false);
31 | paginationInnerInterceptor.setMaxLimit(500L);
32 | mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
33 | return mybatisPlusInterceptor;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/config/ScheduledConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.config;
17 |
18 | import cn.qing.common.concurrent.QingThreadFactory;
19 | import org.springframework.context.annotation.Bean;
20 | import org.springframework.context.annotation.Configuration;
21 |
22 | import java.util.concurrent.ScheduledThreadPoolExecutor;
23 |
24 | @Configuration
25 | public class ScheduledConfig {
26 |
27 | @Bean
28 | public ScheduledThreadPoolExecutor scheduledThreadPoolExecutor() {
29 | return new ScheduledThreadPoolExecutor(5,
30 | QingThreadFactory.create("guard",true));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/config/properties/WebsocketSyncProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.config.properties;
17 |
18 | import lombok.Data;
19 | import org.springframework.boot.context.properties.ConfigurationProperties;
20 | import org.springframework.context.annotation.Configuration;
21 |
22 | /**
23 | * the websocket sync strategy properties.
24 | *
25 | * @author conghuhu
26 | * @create 2022/12/28 9:03
27 | */
28 | @Data
29 | @ConfigurationProperties(prefix = "qing.sync.websocket")
30 | @Configuration
31 | public class WebsocketSyncProperties {
32 |
33 | /**
34 | * default: true.
35 | */
36 | private boolean enabled = true;
37 |
38 | /**
39 | * default: 9099
40 | */
41 | private int port = 9099;
42 |
43 | /**
44 | * default is 8192.
45 | */
46 | private int messageMaxSize;
47 |
48 | /**
49 | * allowOrigins.
50 | */
51 | private String allowOrigins;
52 | }
53 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/controller/PluginController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.controller;
17 |
18 |
19 | import cn.qing.admin.entity.QPlugin;
20 | import cn.qing.admin.service.QPluginService;
21 | import cn.qing.admin.pojo.vo.Result;
22 | import io.swagger.annotations.Api;
23 | import io.swagger.annotations.ApiOperation;
24 | import org.springframework.beans.factory.annotation.Autowired;
25 | import org.springframework.web.bind.annotation.GetMapping;
26 | import org.springframework.web.bind.annotation.RequestMapping;
27 |
28 | import org.springframework.web.bind.annotation.RestController;
29 |
30 | import java.util.List;
31 |
32 | /**
33 | * 插件控制器
34 | *
35 | * @author conghuhu
36 | * @since 2022-04-08
37 | */
38 | @Api(tags = "插件相关接口")
39 | @RestController
40 | @RequestMapping("/plugin")
41 | public class PluginController {
42 |
43 | @Autowired
44 | private QPluginService pluginService;
45 |
46 | @ApiOperation(value = "获取插件列表", notes = "获取插件列表")
47 | @GetMapping("/getPluginList")
48 | public Result> getPluginList() {
49 | List pluginList = pluginService.getPluginList();
50 | return Result.OK(pluginList);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/controller/WebsocketInfoController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.controller;
17 |
18 | import cn.qing.admin.entity.QWebsocketInfo;
19 | import cn.qing.admin.pojo.params.WebsocketParam;
20 | import cn.qing.admin.service.CoreService;
21 | import cn.qing.admin.service.QWebsocketInfoService;
22 | import cn.qing.admin.pojo.vo.Result;
23 | import io.swagger.annotations.Api;
24 | import io.swagger.annotations.ApiOperation;
25 | import org.springframework.web.bind.annotation.*;
26 |
27 | import java.util.List;
28 |
29 | /**
30 | * websocket-info控制器
31 | *
32 | * @author conghuhu
33 | * @since 2022-04-08
34 | */
35 | @Api(tags = "websocket及其服务相关接口")
36 | @RestController
37 | @RequestMapping("/websocket-info")
38 | public class WebsocketInfoController {
39 |
40 | private final QWebsocketInfoService websocketInfoService;
41 |
42 | public WebsocketInfoController(QWebsocketInfoService websocketInfoService) {
43 | this.websocketInfoService = websocketInfoService;
44 | }
45 |
46 | @ApiOperation(value = "获取网关websocket服务实例列表", notes = "获取网关websocket服务实例列表")
47 | @GetMapping("/getWebsocketInfo")
48 | public Result> getWebsocketInfo() {
49 | List websocketInfoList = websocketInfoService.getWebsocketInfo();
50 | return Result.OK(websocketInfoList);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/entity/QLimitRule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.entity;
17 |
18 | import com.baomidou.mybatisplus.annotation.IdType;
19 | import com.baomidou.mybatisplus.annotation.TableField;
20 |
21 | import java.io.Serializable;
22 |
23 | import com.baomidou.mybatisplus.annotation.TableId;
24 | import io.swagger.annotations.ApiModel;
25 | import io.swagger.annotations.ApiModelProperty;
26 | import lombok.Data;
27 | import lombok.EqualsAndHashCode;
28 |
29 | /**
30 | *
31 | *
32 | *
33 | *
34 | * @author conghuhu
35 | * @since 2022-04-15
36 | */
37 | @Data
38 | @EqualsAndHashCode(callSuper = false)
39 | @ApiModel(value = "QLimitRule对象", description = "")
40 | public class QLimitRule implements Serializable {
41 |
42 | private static final long serialVersionUID = 1L;
43 |
44 | @TableId(value = "id", type = IdType.AUTO)
45 | private Long id;
46 |
47 | @ApiModelProperty(value = "限流key,ip或接口名")
48 | @TableField("limitKey")
49 | private String limitKey;
50 |
51 | @ApiModelProperty(value = "限流规则类型,ip还是接口")
52 | private String type;
53 |
54 | @ApiModelProperty(value = "限流单位,秒或分钟")
55 | @TableField("timeUnit")
56 | private String timeunit;
57 |
58 | @TableField("QPS")
59 | private Integer qps;
60 |
61 | @TableField("QPM")
62 | private Integer qpm;
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/entity/QNacosInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.entity;
17 |
18 | import com.baomidou.mybatisplus.annotation.IdType;
19 | import com.baomidou.mybatisplus.annotation.TableId;
20 |
21 | import java.time.LocalDateTime;
22 | import java.io.Serializable;
23 |
24 | import com.baomidou.mybatisplus.annotation.TableName;
25 | import io.swagger.annotations.ApiModel;
26 | import io.swagger.annotations.ApiModelProperty;
27 | import lombok.*;
28 |
29 | /**
30 | *
31 | *
32 | *
33 | *
34 | * @author conghuhu
35 | * @since 2022-04-08
36 | */
37 | @Builder
38 | @NoArgsConstructor
39 | @AllArgsConstructor
40 | @Data
41 | @EqualsAndHashCode(callSuper = false)
42 | @ApiModel(value = "QNacosInfo对象", description = "")
43 | public class QNacosInfo implements Serializable {
44 |
45 | private static final long serialVersionUID = 1L;
46 |
47 | @TableId(value = "id", type = IdType.AUTO)
48 | private Long id;
49 |
50 | @ApiModelProperty(value = "nacos地址")
51 | private String address;
52 |
53 | @ApiModelProperty(value = "描述")
54 | private String description;
55 |
56 | @ApiModelProperty(value = "是否开启,1开启0未开启")
57 | private Boolean enabled;
58 |
59 | @ApiModelProperty(value = "创建时间")
60 | private LocalDateTime createdTime;
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/entity/QPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.entity;
17 |
18 | import com.baomidou.mybatisplus.annotation.IdType;
19 | import com.baomidou.mybatisplus.annotation.TableId;
20 | import java.time.LocalDateTime;
21 | import java.io.Serializable;
22 | import io.swagger.annotations.ApiModel;
23 | import io.swagger.annotations.ApiModelProperty;
24 | import lombok.Data;
25 | import lombok.EqualsAndHashCode;
26 |
27 | /**
28 | *
29 | *
30 | *
31 | *
32 | * @author conghuhu
33 | * @since 2022-04-08
34 | */
35 | @Data
36 | @EqualsAndHashCode(callSuper = false)
37 | @ApiModel(value="QPlugin对象", description="")
38 | public class QPlugin implements Serializable {
39 |
40 | private static final long serialVersionUID = 1L;
41 |
42 | @TableId(value = "id", type = IdType.AUTO)
43 | private Long id;
44 |
45 | @ApiModelProperty(value = "插件名称 eg:DynamicRoute,类的名称")
46 | private String name;
47 |
48 | @ApiModelProperty(value = "描述,如鉴权")
49 | private String description;
50 |
51 | @ApiModelProperty(value = "顺序")
52 | private Integer order;
53 |
54 | @ApiModelProperty(value = "0为false,1为true")
55 | private Boolean skip;
56 |
57 | @ApiModelProperty(value = "创建时间")
58 | private LocalDateTime createdTime;
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/entity/QService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.entity;
17 |
18 | import com.baomidou.mybatisplus.annotation.IdType;
19 | import com.baomidou.mybatisplus.annotation.TableId;
20 | import java.time.LocalDateTime;
21 | import java.io.Serializable;
22 | import io.swagger.annotations.ApiModel;
23 | import io.swagger.annotations.ApiModelProperty;
24 | import lombok.Data;
25 | import lombok.EqualsAndHashCode;
26 |
27 | /**
28 | *
29 | *
30 | *
31 | *
32 | * @author conghuhu
33 | * @since 2022-04-08
34 | */
35 | @Data
36 | @EqualsAndHashCode(callSuper = false)
37 | @ApiModel(value="QService对象", description="")
38 | public class QService implements Serializable {
39 |
40 | private static final long serialVersionUID = 1L;
41 |
42 | @TableId(value = "id", type = IdType.AUTO)
43 | private Long id;
44 |
45 | @ApiModelProperty(value = "应用名称")
46 | private String serviceName;
47 |
48 | @ApiModelProperty(value = "描述")
49 | private String description;
50 |
51 | @ApiModelProperty(value = "路径上下文")
52 | private String contextPath;
53 |
54 | @ApiModelProperty(value = "是否开启,1开启0未开启")
55 | private Boolean enabled;
56 |
57 | @ApiModelProperty(value = "创建时间")
58 | private LocalDateTime createdTime;
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/entity/QUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.entity;
17 |
18 | import com.baomidou.mybatisplus.annotation.IdType;
19 | import com.baomidou.mybatisplus.annotation.TableId;
20 |
21 | import java.time.LocalDateTime;
22 | import java.io.Serializable;
23 |
24 | import io.swagger.annotations.ApiModel;
25 | import io.swagger.annotations.ApiModelProperty;
26 | import lombok.Data;
27 | import lombok.EqualsAndHashCode;
28 |
29 | /**
30 | *
31 | *
32 | *
33 | *
34 | * @author conghuhu
35 | * @since 2022-04-24
36 | */
37 | @Data
38 | @EqualsAndHashCode(callSuper = false)
39 | @ApiModel(value = "QUser对象", description = "")
40 | public class QUser implements Serializable {
41 |
42 | private static final long serialVersionUID = 1L;
43 |
44 | @TableId(value = "id", type = IdType.AUTO)
45 | private Long id;
46 |
47 | private String username;
48 |
49 | private String password;
50 |
51 | private LocalDateTime createdTime;
52 |
53 | private LocalDateTime lastLoginTime;
54 |
55 | private String salt;
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/limitEvent/LimitRuleAddEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.limitEvent;
17 |
18 | import cn.qing.common.dto.LimitRuleDTO;
19 | import org.springframework.context.ApplicationEvent;
20 |
21 | import java.util.Map;
22 |
23 | /**
24 | * @author conghuhu
25 | * @create 2022-04-15 13:39
26 | */
27 | public class LimitRuleAddEvent extends ApplicationEvent {
28 |
29 | private Map limitRuleMap;
30 |
31 | public LimitRuleAddEvent(Object source, Map limitRuleMap) {
32 | super(source);
33 | this.limitRuleMap = limitRuleMap;
34 | }
35 |
36 | public Map getLimitRuleMap() {
37 | return limitRuleMap;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/limitEvent/LimitRuleDeleteEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.limitEvent;
17 |
18 | import org.springframework.context.ApplicationEvent;
19 |
20 | /**
21 | * @author conghuhu
22 | * @create 2022-04-15 13:40
23 | */
24 | public class LimitRuleDeleteEvent extends ApplicationEvent {
25 |
26 | private String key;
27 |
28 | public LimitRuleDeleteEvent(Object source, String key) {
29 | super(source);
30 | this.key = key;
31 | }
32 |
33 | public String getKey() {
34 | return key;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/limitEvent/LimitRuleUpdateEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.limitEvent;
17 |
18 | import cn.qing.common.dto.LimitRuleDTO;
19 | import org.springframework.context.ApplicationEvent;
20 |
21 | import java.util.Map;
22 |
23 | /**
24 | * @author conghuhu
25 | * @create 2022-04-15 13:39
26 | */
27 | public class LimitRuleUpdateEvent extends ApplicationEvent {
28 |
29 | private Map limitRuleMap;
30 |
31 | public LimitRuleUpdateEvent(Object source, Map limitRuleMap) {
32 | super(source);
33 | this.limitRuleMap = limitRuleMap;
34 | }
35 |
36 | public Map getLimitRuleMap() {
37 | return limitRuleMap;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/ruleEvent/RuleAddEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.ruleEvent;
17 |
18 | import cn.qing.common.dto.ServiceRuleDTO;
19 | import org.springframework.context.ApplicationEvent;
20 |
21 | import java.util.Map;
22 |
23 | /**
24 | * @author conghuhu
25 | * @create 2022-04-08 9:17
26 | */
27 | public class RuleAddEvent extends ApplicationEvent {
28 |
29 | private Map serviceRuleMap;
30 |
31 | public RuleAddEvent(Object source, Map serviceRuleMap) {
32 | super(source);
33 | this.serviceRuleMap = serviceRuleMap;
34 | }
35 |
36 | public Map getServiceRuleMap() {
37 | return serviceRuleMap;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/ruleEvent/RuleDeleteEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.ruleEvent;
17 |
18 | import org.springframework.context.ApplicationEvent;
19 |
20 | /**
21 | * @author conghuhu
22 | * @create 2022-04-08 15:59
23 | */
24 | public class RuleDeleteEvent extends ApplicationEvent {
25 |
26 | private String routeName;
27 |
28 | public RuleDeleteEvent(Object source, String routeName) {
29 | super(source);
30 | this.routeName = routeName;
31 | }
32 |
33 | public String getRouteName() {
34 | return routeName;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/ruleEvent/RuleUpdateEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.ruleEvent;
17 |
18 | import cn.qing.common.dto.ServiceRuleDTO;
19 | import org.springframework.context.ApplicationEvent;
20 |
21 | import java.util.Map;
22 |
23 | /**
24 | * @author conghuhu
25 | * @create 2022-04-11 21:05
26 | */
27 | public class RuleUpdateEvent extends ApplicationEvent {
28 |
29 | private Map serviceRuleMap;
30 |
31 | public RuleUpdateEvent(Object source, Map serviceRuleMap) {
32 | super(source);
33 | this.serviceRuleMap = serviceRuleMap;
34 | }
35 |
36 | public Map getServiceRuleMap() {
37 | return serviceRuleMap;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/serviceEvent/ServiceAddEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.serviceEvent;
17 |
18 | import cn.qing.common.dto.ServiceInstance;
19 | import org.springframework.context.ApplicationEvent;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | /**
25 | * @author conghuhu
26 | * @create 2022-04-08 16:13
27 | */
28 | public class ServiceAddEvent extends ApplicationEvent {
29 |
30 | private Map> serviceMap;
31 |
32 | public ServiceAddEvent(Object source, Map> serviceMap) {
33 | super(source);
34 | this.serviceMap = serviceMap;
35 | }
36 |
37 | public Map> getServiceMap() {
38 | return serviceMap;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/serviceEvent/ServiceClearEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.serviceEvent;
17 |
18 | import org.springframework.context.ApplicationEvent;
19 |
20 | /**
21 | * @author conghuhu
22 | * @create 2022-04-13 21:49
23 | */
24 | public class ServiceClearEvent extends ApplicationEvent {
25 |
26 | private static final long serialVersionUID = -8586914174899662649L;
27 |
28 | public ServiceClearEvent(Object source) {
29 | super(source);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/serviceEvent/ServiceRemoveEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.serviceEvent;
17 |
18 | import org.springframework.context.ApplicationEvent;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * @author conghuhu
24 | * @create 2022-04-09 12:39
25 | */
26 | public class ServiceRemoveEvent extends ApplicationEvent {
27 | private List onlineServices;
28 |
29 | public ServiceRemoveEvent(Object source, List onlineServices) {
30 | super(source);
31 | this.onlineServices = onlineServices;
32 | }
33 |
34 | public List getOnlineServices() {
35 | return onlineServices;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/event/serviceEvent/ServiceUpdateEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.event.serviceEvent;
17 |
18 | import cn.qing.common.dto.ServiceInstance;
19 | import org.springframework.context.ApplicationEvent;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | /**
25 | * @author conghuhu
26 | * @create 2022-04-08 18:13
27 | */
28 | public class ServiceUpdateEvent extends ApplicationEvent {
29 |
30 | private Map> serviceMap;
31 |
32 | public ServiceUpdateEvent(Object source, Map> serviceMap) {
33 | super(source);
34 | this.serviceMap = serviceMap;
35 | }
36 |
37 | public Map> getServiceMap() {
38 | return serviceMap;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QLimitRuleMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QLimitRule;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.springframework.stereotype.Repository;
22 |
23 | /**
24 | *
25 | * Mapper 接口
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-15
30 | */
31 | @Repository
32 | @Mapper
33 | public interface QLimitRuleMapper extends BaseMapper {
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QLogMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QLog;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.springframework.stereotype.Repository;
22 |
23 | /**
24 | *
25 | * Mapper 接口
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-18
30 | */
31 | @Mapper
32 | @Repository
33 | public interface QLogMapper extends BaseMapper {
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QNacosInfoMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QNacosInfo;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.apache.ibatis.annotations.Param;
22 | import org.apache.ibatis.annotations.Update;
23 | import org.springframework.stereotype.Repository;
24 |
25 | /**
26 | *
27 | * Mapper 接口
28 | *
29 | *
30 | * @author conghuhu
31 | * @since 2022-04-08
32 | */
33 | @Mapper
34 | @Repository
35 | public interface QNacosInfoMapper extends BaseMapper {
36 |
37 | void insertByReplace(@Param("nacosInfo") QNacosInfo nacosInfo);
38 |
39 | @Update("truncate table q_nacos_info")
40 | void clean();
41 | }
42 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QPluginMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QPlugin;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.springframework.stereotype.Repository;
22 |
23 | /**
24 | *
25 | * Mapper 接口
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-08
30 | */
31 | @Mapper
32 | @Repository
33 | public interface QPluginMapper extends BaseMapper {
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QRouteRuleMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QRouteRule;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.springframework.stereotype.Repository;
22 |
23 | /**
24 | *
25 | * Mapper 接口
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-08
30 | */
31 | @Mapper
32 | @Repository
33 | public interface QRouteRuleMapper extends BaseMapper {
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QServiceInstanceMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QServiceInstance;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.apache.ibatis.annotations.Param;
22 | import org.apache.ibatis.annotations.Update;
23 | import org.springframework.stereotype.Repository;
24 |
25 | /**
26 | *
27 | * Mapper 接口
28 | *
29 | *
30 | * @author conghuhu
31 | * @since 2022-04-08
32 | */
33 | @Mapper
34 | @Repository
35 | public interface QServiceInstanceMapper extends BaseMapper {
36 |
37 | void insertByReplace(@Param("serviceInstance") QServiceInstance serviceInstance);
38 |
39 | /**
40 | * 清空表
41 | */
42 | @Update("truncate table q_service_instance")
43 | void clean();
44 | }
45 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QServiceMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QService;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.apache.ibatis.annotations.Param;
22 | import org.apache.ibatis.annotations.Update;
23 | import org.springframework.stereotype.Repository;
24 |
25 | /**
26 | *
27 | * Mapper 接口
28 | *
29 | *
30 | * @author conghuhu
31 | * @since 2022-04-08
32 | */
33 | @Mapper
34 | @Repository
35 | public interface QServiceMapper extends BaseMapper {
36 |
37 | /**
38 | * 插入数据
39 | *
40 | * @param service
41 | */
42 | void insertByReplace(@Param("service") QService service);
43 |
44 | /**
45 | * 清空表
46 | */
47 | @Update("truncate table q_service")
48 | void clean();
49 | }
50 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QUserMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QUser;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.springframework.stereotype.Repository;
22 |
23 | /**
24 | *
25 | * Mapper 接口
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-24
30 | */
31 | @Repository
32 | @Mapper
33 | public interface QUserMapper extends BaseMapper {
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/mapper/QWebsocketInfoMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.mapper;
17 |
18 | import cn.qing.admin.entity.QWebsocketInfo;
19 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.apache.ibatis.annotations.Param;
22 | import org.apache.ibatis.annotations.Update;
23 | import org.springframework.stereotype.Repository;
24 |
25 | /**
26 | *
27 | * Mapper 接口
28 | *
29 | *
30 | * @author conghuhu
31 | * @since 2022-04-08
32 | */
33 | @Mapper
34 | @Repository
35 | public interface QWebsocketInfoMapper extends BaseMapper {
36 |
37 | /**
38 | * replace into插入数据
39 | *
40 | * @param websocketInfo
41 | */
42 | void insertByReplace(@Param("websocketInfo") QWebsocketInfo websocketInfo);
43 |
44 | /**
45 | * 清空表
46 | */
47 | @Update("truncate table q_websocket_info")
48 | void clean();
49 | }
50 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/params/InitParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.params;
17 |
18 | import lombok.Data;
19 |
20 | import javax.validation.constraints.NotBlank;
21 | import java.util.List;
22 |
23 | /**
24 | * @author conghuhu
25 | * @create 2022-04-07 20:48
26 | */
27 | @Data
28 | public class InitParam {
29 |
30 | /**
31 | * nacos配置中心地址
32 | */
33 | @NotBlank
34 | private String nacosServerAddr;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/params/InstanceUpdateParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.params;
17 |
18 | import lombok.Data;
19 |
20 | @Data
21 | public class InstanceUpdateParam {
22 |
23 | private String serviceName;
24 |
25 | private String ip;
26 |
27 | private String port;
28 |
29 | private String version;
30 |
31 | private Integer weight;
32 |
33 | private String clusterName;
34 |
35 | private String protocol;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/params/PageParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.params;
17 |
18 | import lombok.Data;
19 |
20 | import javax.validation.constraints.Min;
21 |
22 | @Data
23 | public class PageParam {
24 |
25 | @Min(value = 1, message = "最小页数为1")
26 | private Integer pageNum;
27 |
28 | @Min(value = 1, message = "每页最少展示1条")
29 | private Integer pageSize;
30 |
31 | private String content;
32 | }
33 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/params/RegisterParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.params;
17 |
18 | import lombok.Data;
19 |
20 | import javax.validation.constraints.Email;
21 | import javax.validation.constraints.NotBlank;
22 |
23 | @Data
24 | public class RegisterParam {
25 |
26 | @NotBlank
27 | @Email(message = "账号应为邮箱格式")
28 | private String username;
29 |
30 | @NotBlank
31 | private String password;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/params/RouteRuleParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.params;
17 |
18 | import lombok.Data;
19 |
20 | import javax.validation.constraints.NotBlank;
21 | import javax.validation.constraints.NotNull;
22 |
23 | /**
24 | * @author conghuhu
25 | * @create 2022-04-10 16:46
26 | */
27 | @Data
28 | public class RouteRuleParam {
29 |
30 | private Long id;
31 |
32 | @NotBlank
33 | private String serviceName;
34 |
35 | @NotBlank
36 | private String predicates;
37 |
38 | @NotNull
39 | private Integer priority;
40 |
41 | private Boolean enabled;
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/params/WebsocketParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.params;
17 |
18 | import lombok.Data;
19 |
20 | @Data
21 | public class WebsocketParam {
22 | private String uri;
23 | }
24 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/vo/ConfigInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.vo;
17 |
18 | import cn.qing.admin.entity.QNacosInfo;
19 | import cn.qing.admin.entity.QWebsocketInfo;
20 | import lombok.Data;
21 |
22 | import java.util.List;
23 |
24 | @Data
25 | public class ConfigInfo {
26 |
27 | private QNacosInfo nacosInfo;
28 |
29 | private List websocketInfoList;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/vo/MonitorInfoVo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.vo;
17 |
18 | import cn.qing.common.dto.CpuInfoDTO;
19 | import cn.qing.common.dto.JvmInfoDTO;
20 | import cn.qing.common.dto.MemInfoDTO;
21 | import cn.qing.common.dto.QpsDTO;
22 | import cn.qing.common.dto.ThreadInfoDTO;
23 | import lombok.Data;
24 |
25 | import java.util.List;
26 |
27 | /**
28 | * @author qing
29 | */
30 | @Data
31 | public class MonitorInfoVo {
32 |
33 | private String gatewayId;
34 |
35 | private List qpsDTOList;
36 |
37 | private List cpuInfoList;
38 |
39 | private List memInfoList;
40 |
41 | private List jvmInfoList;
42 |
43 | private List threadInfoList;
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/vo/PageResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.vo;
17 |
18 | import lombok.AllArgsConstructor;
19 | import lombok.Builder;
20 | import lombok.Data;
21 | import lombok.NoArgsConstructor;
22 |
23 | /**
24 | * @author qing
25 | */
26 | @Data
27 | @Builder
28 | @NoArgsConstructor
29 | @AllArgsConstructor
30 | public class PageResult {
31 |
32 | private Long current;
33 |
34 | private Long pageSize;
35 |
36 | private Long total;
37 |
38 | private T data;
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/vo/RouteRuleVo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.vo;
17 |
18 | import cn.qing.admin.entity.QService;
19 | import com.fasterxml.jackson.annotation.JsonFormat;
20 | import lombok.Data;
21 |
22 | import java.io.Serializable;
23 | import java.time.LocalDateTime;
24 |
25 | /**
26 | * @author conghuhu
27 | * @create 2022-04-09 14:34
28 | */
29 | @Data
30 | public class RouteRuleVo implements Serializable {
31 |
32 | private static final long serialVersionUID = 1L;
33 |
34 | private Long id;
35 |
36 | private QService service;
37 |
38 | private String predicates;
39 |
40 | private Integer priority;
41 |
42 | private Boolean enabled;
43 |
44 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
45 | private LocalDateTime createdTime;
46 | }
47 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/vo/ServiceInfoVo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.vo;
17 |
18 | import cn.qing.admin.entity.QServiceInstance;
19 | import com.fasterxml.jackson.annotation.JsonFormat;
20 | import io.swagger.annotations.ApiModelProperty;
21 | import lombok.AllArgsConstructor;
22 | import lombok.Builder;
23 | import lombok.Data;
24 | import lombok.NoArgsConstructor;
25 |
26 | import java.io.Serializable;
27 | import java.time.LocalDateTime;
28 | import java.util.List;
29 |
30 | /**
31 | * @author conghuhu
32 | * @create 2022-04-09 14:57
33 | */
34 | @Data
35 | @Builder
36 | @NoArgsConstructor
37 | @AllArgsConstructor
38 | public class ServiceInfoVo implements Serializable {
39 |
40 | private static final long serialVersionUID = -81880795944227537L;
41 |
42 | private Long id;
43 |
44 | private String serviceName;
45 |
46 | private String contextPath;
47 |
48 | private String description;
49 |
50 | private Boolean enabled;
51 |
52 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
53 | private LocalDateTime createdTime;
54 |
55 | private List serviceInstanceList;
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/pojo/vo/UserInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.pojo.vo;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 |
22 | @Data
23 | public class UserInfo implements Serializable {
24 |
25 | private static final long serialVersionUID = 1L;
26 |
27 | private Long id;
28 |
29 | private String username;
30 | }
31 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QLimitRuleService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QLimitRule;
19 | import com.baomidou.mybatisplus.extension.service.IService;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | *
25 | * 服务类
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-15
30 | */
31 | public interface QLimitRuleService extends IService {
32 |
33 | /**
34 | * 查询所有限制规则
35 | * @return
36 | */
37 | List getLimitRuleList();
38 |
39 | /**
40 | * 添加限制规则
41 | * @param limitRule
42 | * @return
43 | */
44 | QLimitRule addLimitRule(QLimitRule limitRule);
45 |
46 | /**
47 | * 修改限制规则
48 | * @param limitRule
49 | */
50 | void updateLimitRule(QLimitRule limitRule);
51 |
52 | /**
53 | * 删除限制规则
54 | * @param id
55 | */
56 | void deleteLimitRule(Long id);
57 | }
58 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QLogService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QLog;
19 | import cn.qing.admin.pojo.params.PageParam;
20 | import cn.qing.admin.pojo.vo.PageResult;
21 | import com.baomidou.mybatisplus.extension.service.IService;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | *
27 | * 服务类
28 | *
29 | *
30 | * @author conghuhu
31 | * @since 2022-04-18
32 | */
33 | public interface QLogService extends IService {
34 |
35 | /**
36 | * 查询所有日志
37 | * @return
38 | */
39 | PageResult> getInvokeLogs(PageParam pageParam);
40 | }
41 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QNacosInfoService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QNacosInfo;
19 | import com.baomidou.mybatisplus.extension.service.IService;
20 |
21 | /**
22 | *
23 | * 服务类
24 | *
25 | *
26 | * @author conghuhu
27 | * @since 2022-04-08
28 | */
29 | public interface QNacosInfoService extends IService {
30 |
31 | /**
32 | * 插入nacos服务信息
33 | *
34 | * @param nacosInfo
35 | */
36 | void insert(QNacosInfo nacosInfo);
37 |
38 | /**
39 | * 清空表
40 | */
41 | void clean();
42 | }
43 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QPluginService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QPlugin;
19 | import com.baomidou.mybatisplus.extension.service.IService;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | *
25 | * 服务类
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-08
30 | */
31 | public interface QPluginService extends IService {
32 |
33 | /**
34 | * 查询所有插件
35 | * @return
36 | */
37 | List getPluginList();
38 | }
39 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QRouteRuleService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QRouteRule;
19 | import cn.qing.admin.pojo.vo.RouteRuleVo;
20 | import cn.qing.admin.pojo.params.RouteRuleParam;
21 | import com.baomidou.mybatisplus.extension.service.IService;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | *
27 | * 服务类
28 | *
29 | *
30 | * @author conghuhu
31 | * @since 2022-04-08
32 | */
33 | public interface QRouteRuleService extends IService {
34 |
35 | /**
36 | * 获取路由规则列表
37 | *
38 | * @return
39 | */
40 | List getRouteRuleList();
41 |
42 | /**
43 | * 新增路由规则
44 | *
45 | * @param routeRuleParam
46 | */
47 | QRouteRule addRouteRule(RouteRuleParam routeRuleParam);
48 |
49 | /**
50 | * 更新路由规则
51 | *
52 | * @param routeRuleParam
53 | */
54 | void updateRouteRule(RouteRuleParam routeRuleParam);
55 |
56 | /**
57 | * 删除路由规则
58 | * @param id
59 | */
60 | void deleteRouteRule(Long id);
61 | }
62 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QServiceInstanceService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QServiceInstance;
19 | import com.baomidou.mybatisplus.extension.service.IService;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | *
25 | * 服务类
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-08
30 | */
31 | public interface QServiceInstanceService extends IService {
32 |
33 | /**
34 | * 查询某个服务下的所有实例
35 | *
36 | * @param id
37 | * @return
38 | */
39 | List getServiceInstanceListByServiceId(Long id);
40 |
41 | /**
42 | * 插入实例数据,若存在则更新
43 | *
44 | * @param qServiceInstance
45 | */
46 | void insert(QServiceInstance qServiceInstance);
47 |
48 | /**
49 | * 清空数据
50 | */
51 | void clean();
52 | }
53 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QServiceService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QService;
19 | import cn.qing.admin.pojo.vo.ServiceInfoVo;
20 | import com.baomidou.mybatisplus.extension.service.IService;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | *
26 | * 服务类
27 | *
28 | *
29 | * @author conghuhu
30 | * @since 2022-04-08
31 | */
32 | public interface QServiceService extends IService {
33 |
34 | /**
35 | * 获取服务及其实例信息
36 | *
37 | * @return
38 | */
39 | List getServiceList();
40 |
41 | /**
42 | * 插入service数据,若service已存在则更新
43 | *
44 | * @param qService
45 | */
46 | void insert(QService qService);
47 |
48 | /**
49 | * 清空表
50 | */
51 | void clean();
52 | }
53 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QUserService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QUser;
19 | import cn.qing.admin.pojo.params.RegisterParam;
20 | import com.baomidou.mybatisplus.extension.service.IService;
21 |
22 | /**
23 | *
24 | * 服务类
25 | *
26 | *
27 | * @author conghuhu
28 | * @since 2022-04-24
29 | */
30 | public interface QUserService extends IService {
31 |
32 | String register(RegisterParam registerParam);
33 |
34 | String login(RegisterParam registerParam);
35 |
36 | Boolean checkToken(String token);
37 | }
38 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/QWebsocketInfoService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service;
17 |
18 | import cn.qing.admin.entity.QWebsocketInfo;
19 | import com.baomidou.mybatisplus.extension.service.IService;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | *
25 | * 服务类
26 | *
27 | *
28 | * @author conghuhu
29 | * @since 2022-04-08
30 | */
31 | public interface QWebsocketInfoService extends IService {
32 |
33 | /**
34 | * 插入websocket信息
35 | * @param websocketInfo
36 | */
37 | void insert(QWebsocketInfo websocketInfo);
38 |
39 | /**
40 | * 查询所有websocket信息
41 | * @return
42 | */
43 | List getWebsocketInfo();
44 |
45 | /**
46 | * 清空表
47 | */
48 | void clean();
49 |
50 | Boolean changeWebsocketStatus(String clientId, Boolean status);
51 |
52 | List getAll();
53 | }
54 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/impl/QNacosInfoServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service.impl;
17 |
18 | import cn.qing.admin.entity.QNacosInfo;
19 | import cn.qing.admin.mapper.QNacosInfoMapper;
20 | import cn.qing.admin.service.QNacosInfoService;
21 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
22 | import org.apache.ibatis.annotations.Update;
23 | import org.springframework.beans.factory.annotation.Autowired;
24 | import org.springframework.stereotype.Service;
25 |
26 | /**
27 | *
28 | * 服务实现类
29 | *
30 | *
31 | * @author conghuhu
32 | * @since 2022-04-08
33 | */
34 | @Service
35 | public class QNacosInfoServiceImpl extends ServiceImpl implements QNacosInfoService {
36 |
37 | private final QNacosInfoMapper nacosInfoMapper;
38 |
39 | public QNacosInfoServiceImpl(QNacosInfoMapper qNacosInfoMapper) {
40 | this.nacosInfoMapper = qNacosInfoMapper;
41 | }
42 |
43 | /**
44 | * 插入nacos服务信息
45 | *
46 | * @param nacosInfo
47 | */
48 | @Override
49 | public void insert(QNacosInfo nacosInfo) {
50 | nacosInfoMapper.insertByReplace(nacosInfo);
51 | }
52 |
53 | /**
54 | * 清空表
55 | */
56 | @Override
57 | public void clean() {
58 | nacosInfoMapper.clean();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/service/impl/QPluginServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.service.impl;
17 |
18 | import cn.qing.admin.entity.QPlugin;
19 | import cn.qing.admin.mapper.QPluginMapper;
20 | import cn.qing.admin.service.QPluginService;
21 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
22 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
23 | import org.springframework.beans.factory.annotation.Autowired;
24 | import org.springframework.stereotype.Service;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | *
30 | * 服务实现类
31 | *
32 | *
33 | * @author conghuhu
34 | * @since 2022-04-08
35 | */
36 | @Service
37 | public class QPluginServiceImpl extends ServiceImpl implements QPluginService {
38 |
39 | private final QPluginMapper pluginMapper;
40 |
41 | public QPluginServiceImpl(QPluginMapper pluginMapper) {
42 | this.pluginMapper = pluginMapper;
43 | }
44 |
45 | /**
46 | * 查询所有插件
47 | *
48 | * @return
49 | */
50 | @Override
51 | public List getPluginList() {
52 | List pluginList = pluginMapper.selectList(new LambdaQueryWrapper<>());
53 | return pluginList;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/spring/QingApplicationContextAware.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.spring;
17 |
18 | import cn.qing.admin.starter.SystemInitStarter;
19 | import cn.qing.admin.util.SpringContextUtil;
20 | import lombok.extern.slf4j.Slf4j;
21 | import org.springframework.beans.BeansException;
22 | import org.springframework.context.ApplicationContext;
23 | import org.springframework.context.ApplicationContextAware;
24 | import org.springframework.stereotype.Component;
25 |
26 | /**
27 | * @author conghuhu
28 | * @create 2022/12/26 16:34
29 | */
30 | @Slf4j
31 | @Component
32 | public class QingApplicationContextAware implements ApplicationContextAware {
33 |
34 | @Override
35 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
36 | SpringContextUtil.getInstance().setApplicationContext(applicationContext);
37 | SystemInitStarter systemInitStarter = SpringContextUtil.getInstance().getBean(SystemInitStarter.class);
38 | try {
39 | systemInitStarter.run();
40 | } catch (Exception e) {
41 | e.printStackTrace();
42 | log.error("系统初始化失败,请检查");
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/sync/RedisReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.sync;
17 |
18 | import lombok.extern.slf4j.Slf4j;
19 |
20 | /**
21 | * @author qing
22 | */
23 | @Slf4j
24 | public class RedisReceiver {
25 |
26 | public void receiveMessage(String message) {
27 | log.info("Received <" + message + ">");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/transfer/LogTransfer.java:
--------------------------------------------------------------------------------
1 | package cn.qing.admin.transfer;
2 |
3 | import cn.qing.admin.entity.QLog;
4 | import cn.qing.common.dto.LogDTO;
5 |
6 | /**
7 | * @author conghuhu
8 | * @create 2023/1/4 9:27
9 | */
10 | public class LogTransfer {
11 |
12 | public static QLog transferToLog(LogDTO logDTO) {
13 | QLog log = new QLog();
14 | log.setOriginIP(logDTO.getOriginIP());
15 | log.setOriginuri(logDTO.getOriginURI());
16 | log.setProxyuri(logDTO.getProxyURI());
17 | log.setRouteName(logDTO.getRouteName());
18 | log.setServiceInstance(logDTO.getServiceInstance().getIp() + ":" + logDTO.getServiceInstance().getPort());
19 | log.setTargetService(logDTO.getTargetService());
20 | log.setCreatedTime(logDTO.getCreatedTime());
21 | log.setTraceId(logDTO.getTraceId());
22 | return log;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/transfer/RouteRuleTransfer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.transfer;
17 |
18 | import cn.qing.admin.entity.QRouteRule;
19 | import cn.qing.admin.entity.QService;
20 | import cn.qing.admin.pojo.vo.RouteRuleVo;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * @author conghuhu
26 | * @create 2022-04-09 14:38
27 | */
28 | public class RouteRuleTransfer {
29 | public static RouteRuleVo getRouteRuleVoList(QRouteRule routeRule, QService service) {
30 | RouteRuleVo routeRuleVo = new RouteRuleVo();
31 | routeRuleVo.setId(routeRule.getId());
32 | routeRuleVo.setPredicates(routeRule.getPredicates());
33 | routeRuleVo.setCreatedTime(routeRule.getCreatedTime());
34 | routeRuleVo.setPriority(routeRule.getPriority());
35 | routeRuleVo.setEnabled(routeRule.getEnabled());
36 | routeRuleVo.setService(service);
37 | return routeRuleVo;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/java/cn/qing/admin/util/MD5UUIDSaltUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.admin.util;
17 |
18 | import org.apache.commons.codec.digest.DigestUtils;
19 |
20 | import java.util.UUID;
21 |
22 | public class MD5UUIDSaltUtil {
23 |
24 | private static String uuid = UUID.randomUUID().toString().replace("-", "");
25 |
26 | public static String createMd5Code(String code) {
27 | return DigestUtils.md5Hex(code);
28 | }
29 |
30 | public static boolean checkPassword(String userCode, String dbCode) {
31 | if (dbCode.equals(createMd5Code(userCode))) {
32 | return true;
33 | } else {
34 | return false;
35 | }
36 | }
37 |
38 | public static String getUuid() {
39 | return uuid;
40 | }
41 |
42 | public static String getSalt() {
43 | String salt = uuid.substring(0, 5);
44 | return salt;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8081
3 | compression:
4 | enabled: true
5 | mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/javascript
6 | min-response-size: 1024
7 |
8 | spring:
9 | mvc:
10 | pathmatch:
11 | matching-strategy: ant_path_matcher
12 | datasource:
13 | driver-class-name: com.mysql.cj.jdbc.Driver
14 | url: jdbc:mysql://rm-bp16zo6wbvx2741gv6o.mysql.rds.aliyuncs.com:3306/qing_test?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC&rewriteBatchedStatements=true
15 | username: root
16 | password: '@Cong0917'
17 | hikari:
18 | minimum-idle: 10
19 | maximum-pool-size: 20
20 | connection-timeout: 60000
21 | idle-timeout: 60000
22 | redis:
23 | host: 47.113.189.237
24 | port: 6379
25 | password: cong0917
26 | timeout: 5000
27 | connect-timeout: 5000
28 |
29 | mybatis-plus:
30 | mapper-locations: classpath*:/mapper/*.xml
31 | configuration:
32 | map-underscore-to-camel-case: true
33 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
34 |
35 | qing:
36 | sync:
37 | websocket:
38 | enabled: true
39 | port: 9099
40 | messageMaxSize: 8192
41 |
42 | # Prometheus springboot监控配置
43 | management:
44 | endpoints:
45 | web:
46 | exposure:
47 | include: '*'
48 | metrics:
49 | export:
50 | prometheus:
51 | enabled: true
52 | tags:
53 | application: ${spring.application.name}
54 |
55 | # http://localhost:8081/swagger-ui/index.html
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/application-prod.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8081
3 | compression:
4 | enabled: true
5 | mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/javascript
6 | min-response-size: 1024
7 |
8 | spring:
9 | mvc:
10 | pathmatch:
11 | matching-strategy: ant_path_matcher
12 | datasource:
13 | driver-class-name: com.mysql.cj.jdbc.Driver
14 | url: jdbc:mysql://rm-bp16zo6wbvx2741gv6o.mysql.rds.aliyuncs.com:3306/qing_test?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC&rewriteBatchedStatements=true
15 | username: root
16 | password: '@Cong0917'
17 | hikari:
18 | minimum-idle: 10
19 | maximum-pool-size: 20
20 | connection-timeout: 60000
21 | idle-timeout: 60000
22 | redis:
23 | host: 47.113.189.237
24 | port: 6379
25 | password: cong0917
26 | timeout: 5000
27 | connect-timeout: 5000
28 |
29 |
30 | mybatis-plus:
31 | mapper-locations: classpath*:/mapper/*.xml
32 | configuration:
33 | map-underscore-to-camel-case: true
34 |
35 | qing:
36 | sync:
37 | websocket:
38 | enabled: true
39 | port: 9099
40 | messageMaxSize: 8192
41 |
42 | # Prometheus springboot监控配置
43 | management:
44 | endpoints:
45 | web:
46 | exposure:
47 | include: '*'
48 | metrics:
49 | export:
50 | prometheus:
51 | enabled: true
52 | tags:
53 | application: ${spring.application.name}
54 |
55 |
56 | # http://101.201.143.127:8081/swagger-ui/index.html#/
57 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: qing-admin
4 | profiles:
5 | active: dev
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QLimitRuleMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QLogMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QNacosInfoMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | insert
7 | ignore
8 | into `q_nacos_info` (`address`,`description`,`enabled`,`created_time`)
9 | values (
10 | #{nacosInfo.address},
11 | #{nacosInfo.description},
12 | #{nacosInfo.enabled},
13 | #{nacosInfo.createdTime}
14 | )
15 |
16 |
17 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QPluginMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QRouteRuleMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QServiceInstanceMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | replace
7 | into q_service_instance
8 | (`service_id`,`version`,`ip`,`port`,`weight`,`clusterName`,`protocol`,`created_time`)
9 | values
10 | (
11 | #{serviceInstance.serviceId},
12 | #{serviceInstance.version},
13 | #{serviceInstance.ip},
14 | #{serviceInstance.port},
15 | #{serviceInstance.weight},
16 | #{serviceInstance.clustername},
17 | #{serviceInstance.protocol},
18 | #{serviceInstance.createdTime}
19 | )
20 |
21 |
22 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QServiceMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | insert
7 | ignore
8 | into q_service (`service_name`,`description`,`enabled`,`created_time`)
9 | values (
10 | #{service.serviceName},
11 | #{service.description},
12 | #{service.enabled},
13 | #{service.createdTime}
14 | )
15 |
16 |
17 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QUserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/main/resources/mapper/QWebsocketInfoMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | insert
7 | ignore
8 | into `q_websocket_info` (`enabled`, `created_time`, `ip`, `client_id`, `status`)
9 | values (#{websocketInfo.enabled},
10 | #{websocketInfo.createdTime},
11 | #{websocketInfo.ip},
12 | #{websocketInfo.clientId},
13 | #{websocketInfo.status})
14 |
15 |
16 |
--------------------------------------------------------------------------------
/qing-gateway/qing-admin/src/test/java/cn/qing/admin/QingAdminApplicationTests.java:
--------------------------------------------------------------------------------
1 | package cn.qing.admin;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class QingAdminApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/qing-gateway/qing-common/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/qing-gateway/qing-common/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/constants/LoadBalanceConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.constants;
17 |
18 | import lombok.Data;
19 |
20 | /**
21 | * 负载均衡常量
22 | *
23 | * @author conghuhu
24 | * @create 2022-04-03 21:45
25 | */
26 | public final class LoadBalanceConstants {
27 | /**
28 | * 轮询
29 | */
30 | public static final String LOAD_BALANCE_ROUND_ROBIN = "round_robin";
31 | /**
32 | * 加权轮询
33 | */
34 | public static final String WEIGHT_ROUND = "weightRound";
35 | /**
36 | * 随机
37 | */
38 | public static final String RANDOM = "random";
39 | /**
40 | * 平滑加权轮询
41 | */
42 | public static final String SMOOTH_WEIGHT_ROUND = "smoothWeightRound";
43 | }
44 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/constants/NacosConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.constants;
17 |
18 | /**
19 | * @author conghuhu
20 | * @create 2022-04-07 8:49
21 | */
22 | public final class NacosConstants {
23 |
24 | public static final String APP_GROUP_NAME = "QING_GROUP";
25 |
26 | /**
27 | * 修改实例
28 | */
29 | public static final String INSTANCE_UPDATE_PATH = "/nacos/v1/ns/instance";
30 | }
31 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/constants/ProtocolConstantMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.constants;
17 |
18 | import java.util.HashSet;
19 | import java.util.Set;
20 |
21 | /**
22 | * @author conghuhu
23 | * @create 2022-04-12 18:49
24 | */
25 | public class ProtocolConstantMap {
26 | public static final Set PROTOCOL_SET = new HashSet(16) {
27 | {
28 | add("http");
29 | add("https");
30 | add("ftp");
31 | add("ftps");
32 | add("file");
33 | add("ws");
34 | add("wss");
35 | add("rpc");
36 | }
37 | };
38 | }
39 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/constants/PublicConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.constants;
17 |
18 |
19 | public final class PublicConstant {
20 |
21 | private static final String AK = "bYm9BydW7zrgrdhKD4uMTZLHX2IaujHx";
22 |
23 | /**
24 | * 获取百度IP查询url
25 | *
26 | * @param ip
27 | * @return
28 | */
29 | public static String getBaiDuIpUrl(String ip) {
30 | return "https://api.map.baidu.com/location/ip?ak=" + AK + "&ip=" + ip + "&coor=bd09ll";
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/constants/RedisChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.constants;
17 |
18 |
19 | public final class RedisChannel {
20 |
21 | /**
22 | * 监控信息频道
23 | */
24 | public static final String MONITOR_CHANNEL = "user_login";
25 | }
26 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/CpuInfoDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 | import java.time.LocalDateTime;
22 |
23 | /**
24 | * CPU信息类
25 | *
26 | * @author qing
27 | */
28 | @Data
29 | public class CpuInfoDTO implements Serializable {
30 |
31 | private static final long serialVersionUID = 1L;
32 |
33 | /**
34 | * CPU核心数
35 | */
36 | private Integer cpuCoreCount;
37 |
38 | /**
39 | * CPU系统的使用率
40 | */
41 | private Double cpuSysUsage;
42 |
43 | /**
44 | * CPU用户的使用率
45 | */
46 | private Double cpuUserUsage;
47 |
48 | /**
49 | * CPU当前空闲率
50 | */
51 | private Double cpuIdleUsage;
52 |
53 | /**
54 | * CPU当前等待率
55 | */
56 | private Double cpuWaitUsage;
57 |
58 | /**
59 | * CPU当前总使用率
60 | */
61 | private Double cpuCombinedUsage;
62 |
63 | /**
64 | * 采集时间
65 | */
66 | private Long collectTime;
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/JvmInfoDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 | import java.time.LocalDateTime;
22 |
23 | @Data
24 | public class JvmInfoDTO implements Serializable {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | /**
29 | * JVM 内存总量 单位B
30 | */
31 | private Long jvmTotalMemoryByte;
32 |
33 | /**
34 | * JVM 当前可用内存
35 | */
36 | private Long jvmFreeMemoryByte;
37 |
38 | /**
39 | * JVM 最大可申请内存
40 | */
41 | private Long jvmMaxMemoryByte;
42 |
43 | /**
44 | * JDK版本
45 | */
46 | private String jdkVersion;
47 |
48 | /**
49 | * jvm内存使用率
50 | */
51 | private Double jvmMemoryUsedRate;
52 |
53 | private Long collectTime;
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/LZ4CompressData.java:
--------------------------------------------------------------------------------
1 | package cn.qing.common.dto;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @author conghuhu
7 | * @create 2023/1/8 18:54
8 | */
9 | @Data
10 | public class LZ4CompressData {
11 | private int length;
12 |
13 | private byte[] compressedData;
14 |
15 | public LZ4CompressData(final int length, final byte[] compressedData) {
16 | this.length = length;
17 | this.compressedData = compressedData;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/LimitRuleDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 |
22 | /**
23 | * 限流规则DTO
24 | *
25 | * @author conghuhu
26 | * @create 2022-04-14 20:50
27 | */
28 | @Data
29 | public class LimitRuleDTO implements Serializable {
30 |
31 | private static final long serialVersionUID = -81259258818147060L;
32 |
33 | /**
34 | * 限流key,ip或接口名
35 | */
36 | private String limitKey;
37 |
38 | /**
39 | * 限流规则类型,ip还是接口
40 | */
41 | private String type;
42 |
43 | /**
44 | * 限流单位,秒或分钟
45 | */
46 | private String timeunit;
47 |
48 | /**
49 | * 每秒可以访问的次数
50 | */
51 | private Integer qps;
52 |
53 | /**
54 | * 每分钟可以访问的次数
55 | */
56 | private Integer qpm;
57 | }
58 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/MemInfoDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 | import java.time.LocalDateTime;
22 | import java.util.List;
23 |
24 | @Data
25 | public class MemInfoDTO implements Serializable {
26 |
27 | private static final long serialVersionUID = 1L;
28 |
29 | /**
30 | * 总内存 单位B
31 | */
32 | private Long totalMem;
33 |
34 | /**
35 | * 已用内存
36 | */
37 | private Long usedMem;
38 |
39 | /**
40 | * 剩余内存
41 | */
42 | private Long freeMem;
43 |
44 | /**
45 | * 已用内存百分比
46 | */
47 | private Double usedRate;
48 |
49 | /**
50 | * 统计时间
51 | */
52 | private Long collectTime;
53 | }
54 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/QpsDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 |
22 | @Data
23 | public class QpsDTO implements Serializable {
24 |
25 | private static final long serialVersionUID = -8572612362424098981L;
26 |
27 | private Integer QPS;
28 |
29 | private Long collectTime;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/ServiceRuleDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.AllArgsConstructor;
19 | import lombok.Builder;
20 | import lombok.Data;
21 | import lombok.NoArgsConstructor;
22 |
23 | import java.io.Serializable;
24 |
25 | /**
26 | * @author conghuhu
27 | * @create 2022-04-07 10:21
28 | */
29 | @Data
30 | @Builder
31 | @NoArgsConstructor
32 | @AllArgsConstructor
33 | public class ServiceRuleDTO implements Serializable {
34 |
35 | private static final long serialVersionUID = -66469240129393501L;
36 |
37 | /**
38 | * 路由名字,对应predicates
39 | */
40 | private String routeName;
41 |
42 | /**
43 | * 路由对应转发的服务名
44 | */
45 | private String serviceName;
46 |
47 |
48 | /**
49 | * 优先级,值越大优先级越高
50 | */
51 | private Integer priority;
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/SysInfoDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 | import java.time.LocalDateTime;
22 |
23 | @Data
24 | public class SysInfoDTO implements Serializable {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | private String osName;
29 |
30 | private String osArch;
31 |
32 | private String osVersion;
33 |
34 | private Long collectTime;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/ThreadInfoDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 | import java.util.List;
22 |
23 | @Data
24 | public class ThreadInfoDTO implements Serializable {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | private Integer count;
29 |
30 | private List threadInfoItemDTOList;
31 |
32 | private Long collectTime;
33 |
34 | public ThreadInfoDTO(List threadInfoItemDTOList) {
35 | this.threadInfoItemDTOList = threadInfoItemDTOList;
36 | this.count = threadInfoItemDTOList.size();
37 | this.collectTime = System.currentTimeMillis();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/ThreadInfoItemDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.Data;
19 |
20 | import java.io.Serializable;
21 | import java.time.LocalDateTime;
22 |
23 | /**
24 | * @author qing
25 | */
26 | @Data
27 | public class ThreadInfoItemDTO implements Serializable {
28 |
29 | private static final long serialVersionUID = 1L;
30 |
31 | /**
32 | * 线程Id
33 | */
34 | private Long threadId;
35 |
36 | /**
37 | * 线程名称
38 | */
39 | private String threadName;
40 |
41 | /**
42 | * 线程状态
43 | */
44 | private String threadState;
45 |
46 | /**
47 | * 线程优先级
48 | */
49 | private Integer threadPriority;
50 |
51 | /**
52 | * 线程组名称
53 | */
54 | private String threadGroupName;
55 |
56 | /**
57 | * 线程组活跃线程数
58 | */
59 | private Integer threadGroupActiveCount;
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/dto/WebsocketMessageDTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.dto;
17 |
18 | import lombok.AllArgsConstructor;
19 | import lombok.Builder;
20 | import lombok.Data;
21 | import lombok.NoArgsConstructor;
22 |
23 | import java.io.Serializable;
24 | import java.util.List;
25 | import java.util.Map;
26 |
27 | /**
28 | * @author conghuhu
29 | * @create 2022-04-07 20:14
30 | */
31 | @Data
32 | @Builder
33 | @NoArgsConstructor
34 | @AllArgsConstructor
35 | public class WebsocketMessageDTO implements Serializable {
36 |
37 | private static final long serialVersionUID = 1L;
38 |
39 | private String eventType;
40 |
41 | private String actionType;
42 |
43 | /**
44 | * 普通 消息体
45 | */
46 | private String detail;
47 |
48 | /**
49 | * 服务及实例map
50 | */
51 | private Map> serviceMap;
52 |
53 | /**
54 | * 路由规则map
55 | */
56 | private Map routeRuleMap;
57 |
58 | /**
59 | * 在线的服务
60 | */
61 | private List onlineServices;
62 |
63 | /**
64 | * 负载均衡策略
65 | */
66 | private List loadBalanceList;
67 |
68 | /**
69 | * 限流策略map
70 | */
71 | private Map limitRuleMap;
72 |
73 | /**
74 | * 日志记录
75 | */
76 | private List logDTOList;
77 | }
78 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/enums/ActionTypeEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.enums;
17 |
18 | /**
19 | * @author conghuhu
20 | * @create 2022-04-07 20:45
21 | */
22 | public enum ActionTypeEnum {
23 |
24 | ADD("add", "新增"),
25 |
26 | REMOVE("remove", "删除"),
27 |
28 | UPDATE("update", "修改"),
29 |
30 | QUERY("query", "查询"),
31 | ;
32 |
33 | private String code;
34 | private String desc;
35 |
36 | ActionTypeEnum(String code, String desc) {
37 | this.code = code;
38 | this.desc = desc;
39 | }
40 |
41 | public String getCode() {
42 | return code;
43 | }
44 |
45 | public String getDesc() {
46 | return desc;
47 | }
48 |
49 | public void setCode(String code) {
50 | this.code = code;
51 | }
52 |
53 | public void setDesc(String desc) {
54 | this.desc = desc;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/enums/EventTypeEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.enums;
17 |
18 | /**
19 | * @author conghuhu
20 | * @create 2022-04-07 20:36
21 | */
22 | public enum EventTypeEnum {
23 |
24 | /**
25 | * 服务相关
26 | */
27 | SERVICE("service"),
28 |
29 | /**
30 | * 路由规则相关
31 | */
32 | RULE("rule"),
33 |
34 | /**
35 | * 插件相关
36 | */
37 | PLUGIN("plugin"),
38 |
39 | /**
40 | * 握手相关
41 | */
42 | HAND_SHAKE("handshake"),
43 |
44 | /**
45 | * 负载均衡相关
46 | */
47 | LOAD_BALANCE("loadBalance"),
48 |
49 | /**
50 | * 限流规则相关
51 | */
52 | LIMIT_RULE("limitRule"),
53 |
54 | /**
55 | * 日志相关
56 | */
57 | LOG("log"),
58 | ;
59 |
60 | private String name;
61 |
62 |
63 | EventTypeEnum(String name) {
64 | this.name = name;
65 | }
66 |
67 | public String getName() {
68 | return name;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/enums/QingExceptionEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.enums;
17 |
18 | import lombok.Getter;
19 |
20 | /**
21 | * @author conghuhu
22 | * @create 2022-04-03 19:09
23 | */
24 | @Getter
25 | public enum QingExceptionEnum {
26 | /**
27 | * 解析错误
28 | */
29 | PARAM_ERROR(1000, "param error"),
30 | /**
31 | * 服务未找到
32 | */
33 | SERVICE_NOT_FIND(1001, "service not find,maybe not register"),
34 | /**
35 | * 无效的配置
36 | */
37 | CONFIG_ERROR(1002, "invalid config"),
38 | /**
39 | * 用户名或密码错误
40 | */
41 | LOGIN_ERROR(1003, "userName or password error"),
42 | /**
43 | * 未登录
44 | */
45 | NOT_LOGIN(1004, "not login"),
46 | /**
47 | * token错误
48 | */
49 | TOKEN_ERROR(1005, "token error");
50 |
51 | private Integer code;
52 |
53 | private String message;
54 |
55 | QingExceptionEnum(Integer code, String message) {
56 | this.code = code;
57 | this.message = message;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/enums/ResultEnum.java:
--------------------------------------------------------------------------------
1 | package cn.qing.common.enums;
2 |
3 | /**
4 | * ResultEnum.
5 | *
6 | * @author conghuhu
7 | * @create 2022/12/28 18:26
8 | */
9 | public enum ResultEnum {
10 |
11 | /**
12 | * Success result enum.
13 | */
14 | SUCCESS("success"),
15 |
16 | /**
17 | * Time out result enum.
18 | */
19 | TIME_OUT("timeOut"),
20 |
21 | /**
22 | * Error result enum.
23 | */
24 | ERROR("error");
25 |
26 | private final String name;
27 |
28 | /**
29 | * all args constructor.
30 | *
31 | * @param name name
32 | */
33 | ResultEnum(final String name) {
34 | this.name = name;
35 | }
36 |
37 | /**
38 | * get name.
39 | *
40 | * @return name
41 | */
42 | public String getName() {
43 | return name;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/exception/QingException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.exception;
17 |
18 | import cn.qing.common.enums.QingExceptionEnum;
19 | import lombok.Getter;
20 |
21 | /**
22 | * @author conghuhu
23 | * @create 2022-04-03 19:08
24 | */
25 | @Getter
26 | public class QingException extends RuntimeException {
27 |
28 | private Integer code;
29 |
30 | private String errMsg;
31 |
32 | public QingException(String message) {
33 | super(message);
34 | this.code = 5000;
35 | this.errMsg = message;
36 | }
37 |
38 | public QingException(String message, Integer code) {
39 | super(message);
40 | this.code = code;
41 | this.errMsg = message;
42 | }
43 |
44 | public QingException(QingExceptionEnum exceptionEnum) {
45 | super(exceptionEnum.getMessage());
46 | this.code = exceptionEnum.getCode();
47 | this.errMsg = exceptionEnum.getMessage();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/utils/ObjectTypeUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.utils;
17 |
18 | /**
19 | * @author conghuhu
20 | * @create 2022/12/26 18:44
21 | */
22 | public class ObjectTypeUtils {
23 |
24 | /**
25 | * is basic type or not.
26 | *
27 | * @param object the object
28 | * @return true is basic
29 | */
30 | public static boolean isBasicType(final Object object) {
31 | return (object instanceof Integer)
32 | || (object instanceof Byte)
33 | || (object instanceof Long)
34 | || (object instanceof Double)
35 | || (object instanceof Float)
36 | || (object instanceof Short)
37 | || (object instanceof Boolean)
38 | || (object instanceof CharSequence);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/utils/ParamCheckUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.utils;
17 |
18 | import cn.qing.common.exception.QingException;
19 |
20 | /**
21 | * The type Param check utils.
22 | *
23 | * @author conghuhu
24 | * @create 2022/12/26 18:45
25 | */
26 | public class ParamCheckUtils {
27 |
28 | /**
29 | * Body is empty boolean.
30 | *
31 | * @param body the body
32 | * @return the boolean
33 | */
34 | public static boolean bodyIsEmpty(final String body) {
35 | return null == body || "".equals(body) || "null".equals(body);
36 | }
37 |
38 | /**
39 | * Check params length.
40 | *
41 | * @param argsLength params length.
42 | * @param typesLength types length.
43 | */
44 | public static void checkParamsLength(final Integer argsLength, final Integer typesLength) {
45 | if (argsLength < typesLength) {
46 | throw new QingException("args.length < types.length");
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/java/cn/qing/common/utils/ThreadUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.utils;
17 |
18 | import java.util.concurrent.TimeUnit;
19 |
20 | /**
21 | * @author conghuhu
22 | * @create 2022/12/26 17:56
23 | */
24 | public class ThreadUtils {
25 |
26 | /**
27 | * sleep current thread.
28 | *
29 | * @param timeUnit the time unit
30 | * @param time the time
31 | */
32 | public static void sleep(final TimeUnit timeUnit, final int time) {
33 | try {
34 | timeUnit.sleep(time);
35 | } catch (InterruptedException ex) {
36 | Thread.currentThread().interrupt();
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/main/resources/license.txt:
--------------------------------------------------------------------------------
1 | Copyright 2023 qing-gateway
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/test/java/cn/qing/common/concurrent/QingThreadFactoryTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.concurrent;
17 |
18 | import org.junit.jupiter.api.Test;
19 |
20 | import java.util.concurrent.ThreadFactory;
21 |
22 | import static org.hamcrest.MatcherAssert.assertThat;
23 | import static org.hamcrest.Matchers.notNullValue;
24 |
25 | /**
26 | * Test cases for QingThreadFactory.
27 | */
28 | public final class QingThreadFactoryTest {
29 |
30 | private static final String NAME_PREFIX = "qing##thread##";
31 |
32 | @Test
33 | public void testCreate() {
34 | ThreadFactory threadFactory = QingThreadFactory.create(NAME_PREFIX, true);
35 | assertThat(threadFactory, notNullValue());
36 | }
37 |
38 | @Test
39 | public void testCustomCreate() {
40 | ThreadFactory threadFactory = QingThreadFactory.create(NAME_PREFIX, true, 2);
41 | Thread thread = threadFactory.newThread(() -> Thread.currentThread().getId());
42 | assertThat(thread, notNullValue());
43 | }
44 |
45 | @Test
46 | public void testNewThread() {
47 | ThreadFactory threadFactory = QingThreadFactory.create(NAME_PREFIX, true);
48 | threadFactory.newThread(() -> Thread.currentThread().setName("NAME_PREFIX"));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/qing-gateway/qing-common/src/test/java/cn/qing/common/utils/ObjectTypeUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.common.utils;
17 |
18 | import org.junit.jupiter.api.Test;
19 |
20 | import static org.junit.jupiter.api.Assertions.assertTrue;
21 |
22 | public class ObjectTypeUtilsTest {
23 |
24 | @Test
25 | public void testIsBasicType() {
26 | Object o = 1;
27 | assertTrue(ObjectTypeUtils.isBasicType(o));
28 | o = new Short("1");
29 | assertTrue(ObjectTypeUtils.isBasicType(o));
30 | o = new Long("1");
31 | assertTrue(ObjectTypeUtils.isBasicType(o));
32 | o = new Double("1");
33 | assertTrue(ObjectTypeUtils.isBasicType(o));
34 | o = new Float("1");
35 | assertTrue(ObjectTypeUtils.isBasicType(o));
36 | o = Boolean.TRUE;
37 | assertTrue(ObjectTypeUtils.isBasicType(o));
38 | CharSequence str = "hello world";
39 | assertTrue(ObjectTypeUtils.isBasicType(str));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/qing-gateway/qing-examples/client-example-traffic/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/example1_dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jre-alpine
2 | MAINTAINER conghuhu
3 | ADD ./example1.jar /example1.jar
4 | CMD java -jar /example1.jar
5 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/src/main/java/com/example/qingclientexqmple/QingClientExqmpleApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.qingclientexqmple;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 |
7 | @SpringBootApplication
8 | @EnableDiscoveryClient
9 | public class QingClientExqmpleApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(QingClientExqmpleApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/src/main/java/com/example/qingclientexqmple/config/MyWebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package com.example.qingclientexqmple.config;
2 |
3 | import com.example.qingclientexqmple.filter.TraceInterceptor;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7 |
8 | /**
9 | * @author conghuhu
10 | * @create 2023/1/6 17:00
11 | */
12 | @Configuration
13 | public class MyWebMvcConfig implements WebMvcConfigurer {
14 |
15 | private final TraceInterceptor traceInterceptor;
16 |
17 | public MyWebMvcConfig(TraceInterceptor traceInterceptor) {
18 | this.traceInterceptor = traceInterceptor;
19 | }
20 |
21 | @Override
22 | public void addInterceptors(InterceptorRegistry registry) {
23 | registry.addInterceptor(traceInterceptor)
24 | .addPathPatterns("/**");
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/src/main/java/com/example/qingclientexqmple/controller/TrafficController.java:
--------------------------------------------------------------------------------
1 | package com.example.qingclientexqmple.controller;
2 |
3 | import com.example.qingclientexqmple.params.QueryParam;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.slf4j.LoggerFactory;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.*;
8 |
9 | /**
10 | * @author conghuhu
11 | * @create 2022-04-07 13:52
12 | */
13 | @Slf4j
14 | @RestController
15 | @RequestMapping("/traffic")
16 | public class TrafficController {
17 |
18 | @GetMapping("/getTraffic")
19 | public ResponseEntity> getTraffic() {
20 | log.info("getTraffic success");
21 | return ResponseEntity.ok("getTraffic success");
22 | }
23 |
24 | @PostMapping("/setTraffic")
25 | public ResponseEntity> setTraffic() {
26 | return ResponseEntity.ok("setTraffic success");
27 | }
28 |
29 | @PostMapping("/getTrafficByPage")
30 | public ResponseEntity> getTrafficByPage(@RequestBody QueryParam queryParam) {
31 | return ResponseEntity.ok("getTraffic success,current page is" + queryParam.getPageNum()
32 | + ",page size is" + queryParam.getPageSize()
33 | + ",content is" + queryParam.getContent()
34 | );
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/src/main/java/com/example/qingclientexqmple/params/QueryParam.java:
--------------------------------------------------------------------------------
1 | package com.example.qingclientexqmple.params;
2 |
3 |
4 | public class QueryParam {
5 |
6 | private Integer PageNum;
7 |
8 | private Integer PageSize;
9 |
10 | private String content;
11 |
12 | public Integer getPageNum() {
13 | return PageNum;
14 | }
15 |
16 | public void setPageNum(Integer pageNum) {
17 | PageNum = pageNum;
18 | }
19 |
20 | public Integer getPageSize() {
21 | return PageSize;
22 | }
23 |
24 | public void setPageSize(Integer pageSize) {
25 | PageSize = pageSize;
26 | }
27 |
28 | public String getContent() {
29 | return content;
30 | }
31 |
32 | public void setContent(String content) {
33 | this.content = content;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/src/main/java/com/example/qingclientexqmple/utils/TraceIdUtil.java:
--------------------------------------------------------------------------------
1 | package com.example.qingclientexqmple.utils;
2 |
3 | import org.slf4j.MDC;
4 |
5 | import java.util.UUID;
6 |
7 | /**
8 | * @author conghuhu
9 | * @create 2023/1/6 16:08
10 | */
11 | public class TraceIdUtil {
12 | public static final String TRACE_ID = "trace_id";
13 |
14 | public static final String SPAN_ID = "span_id";
15 |
16 | public static String getTraceId() {
17 | String traceId = (String) MDC.get(TRACE_ID);
18 | return traceId == null ? "" : traceId;
19 | }
20 |
21 | public static void setTraceId(String traceId, String spanId) {
22 | MDC.put(TRACE_ID, traceId);
23 | MDC.put(SPAN_ID, spanId);
24 | }
25 |
26 | public static void remove() {
27 | MDC.remove(TRACE_ID);
28 | MDC.remove(SPAN_ID);
29 | }
30 |
31 | public static void clear() {
32 | MDC.clear();
33 | }
34 |
35 | public static String generateTraceId() {
36 | return UUID.randomUUID().toString().replace("-", "");
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-example-traffic/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8900
3 | spring:
4 | application:
5 | name: traffic
6 | cloud:
7 | nacos:
8 | server-addr: 124.222.60.243:8848
9 | discovery:
10 | # ip: 124.222.224.173
11 | group: QING_GROUP
12 | metadata:
13 | version: 2.0
14 | protocol: http
15 | qing:
16 | tracing:
17 | endpoint_url: http://localhost:9411
18 |
19 | logging:
20 | pattern:
21 | level: trace_id=%mdc{trace_id} span_id=%mdc{span_id} %5p
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-exqmple-medical/example2_dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jre-alpine
2 | MAINTAINER conghuhu
3 | ADD ./example2.jar /example2.jar
4 | CMD java -jar /example2.jar
5 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-exqmple-medical/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | qing-examples
9 | cn.qing.gateway
10 | 1.0-SNAPSHOT
11 |
12 |
13 | qing-client-exqmple-medical
14 | qing-client-exqmple=medical
15 |
16 | org.example
17 | client-exqmple-medical
18 | 1.0-SNAPSHOT
19 |
20 |
21 | 1.8
22 | 1.8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-web
30 |
31 |
32 | com.alibaba.cloud
33 | spring-cloud-starter-alibaba-nacos-discovery
34 |
35 |
36 |
37 |
38 | medical-example
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-maven-plugin
43 | 2.3.12.RELEASE
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-exqmple-medical/src/main/java/org/example/QingClientMedicalApplication.java:
--------------------------------------------------------------------------------
1 | package org.example;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 |
7 | @SpringBootApplication
8 | @EnableDiscoveryClient
9 | public class QingClientMedicalApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(QingClientMedicalApplication.class, args);
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-exqmple-medical/src/main/java/org/example/controller/MedicalController.java:
--------------------------------------------------------------------------------
1 | package org.example.controller;
2 |
3 | import org.springframework.http.ResponseEntity;
4 | import org.springframework.web.bind.annotation.*;
5 |
6 | @RestController
7 | @RequestMapping("/medical")
8 | public class MedicalController {
9 |
10 | @GetMapping("/getMedical")
11 | public ResponseEntity> getMedical() {
12 | return ResponseEntity.ok("getMedical success");
13 | }
14 |
15 | @PostMapping("/setMedical")
16 | public ResponseEntity> setMedical() {
17 | return ResponseEntity.ok("setMedical success");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/qing-gateway/qing-examples/client-exqmple-medical/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8500
3 | servlet:
4 | context-path: /medical-api
5 | spring:
6 | application:
7 | name: medical
8 | cloud:
9 | nacos:
10 | server-addr: 124.222.60.243:8848
11 | discovery:
12 | # ip: 124.222.224.173
13 | group: QING_GROUP
14 | metadata:
15 | version: 1.0
16 | protocol: http
--------------------------------------------------------------------------------
/qing-gateway/qing-server/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/qing-gateway/qing-server/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/qing-gateway/qing-server/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/server_dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jre-alpine
2 | MAINTAINER conghuhu
3 | ADD ./qing_server.jar /qing_server.jar
4 | CMD java -jar /qing_server.jar --spring.profiles.active=prod
5 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/QingServerApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 |
21 | import javax.annotation.PostConstruct;
22 | import java.util.TimeZone;
23 |
24 | /**
25 | * @author cgq
26 | */
27 | @SpringBootApplication
28 | public class QingServerApplication {
29 |
30 | @PostConstruct
31 | void setDefaultTimezone() {
32 | TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
33 | }
34 |
35 | public static void main(String[] args) {
36 | SpringApplication.run(QingServerApplication.class, args);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/annotation/LoadBalanceType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.annotation;
17 |
18 | import java.lang.annotation.*;
19 |
20 | /**
21 | * @author conghuhu
22 | * @create 2022-04-06 20:27
23 | */
24 | @Target(ElementType.TYPE)
25 | @Retention(RetentionPolicy.RUNTIME)
26 | @Documented
27 | public @interface LoadBalanceType {
28 |
29 | String value() default "";
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/cache/IdentificationCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.cache;
17 |
18 | public class IdentificationCache {
19 |
20 | private static String gatewayId;
21 |
22 | public static String getGatewayId() {
23 | return gatewayId;
24 | }
25 |
26 | public static void setGatewayId(String gatewayId) {
27 | IdentificationCache.gatewayId = gatewayId;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/cache/PluginCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.cache;
17 |
18 | import lombok.extern.slf4j.Slf4j;
19 |
20 | import java.util.LinkedList;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.concurrent.ConcurrentHashMap;
24 |
25 | /**
26 | * 插件信息缓存
27 | *
28 | * @author conghuhu
29 | * @create 2022-04-04 15:11
30 | */
31 | @Slf4j
32 | public class PluginCache {
33 | /**
34 | * 定义一个ConcurrentHashMap,key: serviceName value: enabled plugins name
35 | */
36 | private static final Map> pluginMap = new ConcurrentHashMap<>();
37 |
38 | /**
39 | * 定义一个向pluginMap中添加数据的方法
40 | */
41 | public static void addPlugin(String serviceName, List plugins) {
42 | pluginMap.put(serviceName, plugins);
43 | }
44 |
45 | /**
46 | * 定义一个移除pluginMap中失效数据的方法
47 | */
48 | public static void removePlugin(List serviceNames) {
49 | List expiredKeys = new LinkedList<>();
50 | pluginMap.keySet().forEach(key -> {
51 | if (!serviceNames.contains(key)) {
52 | expiredKeys.add(key);
53 | }
54 | });
55 | expiredKeys.forEach(key -> pluginMap.remove(key));
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/chain/QingPluginChain.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.chain;
17 |
18 | import org.springframework.web.server.ServerWebExchange;
19 | import reactor.core.publisher.Mono;
20 |
21 | /**
22 | * 插件链
23 | *
24 | * @author cgq
25 | * @version 1.0
26 | * @date 2022/4/4
27 | * @since 1.0
28 | */
29 | public interface QingPluginChain {
30 |
31 | /**
32 | * 获取插件链所在服务名称
33 | *
34 | * @return
35 | */
36 | String serviceName();
37 |
38 | /**
39 | * 插件链所在的服务对应的路由名称
40 | *
41 | * @return
42 | */
43 | String routeName();
44 |
45 | /**
46 | * 执行插件链
47 | *
48 | * @param exchange
49 | * @return
50 | */
51 | Mono doChain(ServerWebExchange exchange);
52 | }
53 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/config/FilterConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.config;
17 |
18 | import cn.qing.server.filter.PluginFilter;
19 | import org.springframework.context.annotation.Bean;
20 | import org.springframework.context.annotation.Configuration;
21 | import org.springframework.core.annotation.Order;
22 | import org.springframework.web.reactive.config.EnableWebFlux;
23 |
24 | /**
25 | * @author conghuhu
26 | * @create 2022-04-03 15:45
27 | */
28 | @Configuration
29 | @EnableWebFlux
30 | public class FilterConfig {
31 |
32 | @Order(-1)
33 | @Bean
34 | public PluginFilter pluginFilter() {
35 | return new PluginFilter();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/config/ScheduledConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.config;
17 |
18 | import cn.qing.common.concurrent.QingThreadFactory;
19 | import org.springframework.context.annotation.Bean;
20 | import org.springframework.context.annotation.Configuration;
21 |
22 | import java.util.concurrent.ScheduledThreadPoolExecutor;
23 |
24 | @Configuration
25 | public class ScheduledConfig {
26 |
27 | @Bean
28 | public ScheduledThreadPoolExecutor scheduledThreadPoolExecutor() {
29 | return new ScheduledThreadPoolExecutor(3, QingThreadFactory.create("guard", true));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/config/WebFluxConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.config;
17 |
18 | import org.springframework.context.annotation.Configuration;
19 | import org.springframework.web.reactive.config.CorsRegistry;
20 | import org.springframework.web.reactive.config.WebFluxConfigurer;
21 |
22 | /**
23 | * @author conghuhu
24 | * @create 2022-04-10 9:44
25 | */
26 | @Configuration
27 | public class WebFluxConfig implements WebFluxConfigurer {
28 | @Override
29 | public void addCorsMappings(CorsRegistry registry) {
30 | registry.addMapping("/**")
31 | .allowedOriginPatterns("*")
32 | // 允许本地请求方法:PUT、POST、DELETE、GET等
33 | .allowedMethods("*")
34 | // 预检间隔时间
35 | .maxAge(3600)
36 | // 允许头部设置
37 | .allowedHeaders("*")
38 | // 是否发送cookie
39 | .allowCredentials(true);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/config/properties/AccessLoggingProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.config.properties;
17 |
18 | import lombok.Data;
19 | import org.springframework.boot.context.properties.ConfigurationProperties;
20 | import org.springframework.context.annotation.Configuration;
21 |
22 | /**
23 | * @author conghuhu
24 | * @create 2023/1/8 10:21
25 | */
26 | @Data
27 | @ConfigurationProperties(prefix = "qing.logging")
28 | @Configuration
29 | public class AccessLoggingProperties {
30 |
31 | private String strategy = "admin";
32 |
33 | private String topic = "qing-access-logging";
34 |
35 | private String nameserverAddr;
36 |
37 | /**
38 | * 压缩算法,默认不压缩,目前支持LZ4压缩
39 | */
40 | private String compressAlg;
41 |
42 | /**
43 | * default 512KB.
44 | */
45 | private int maxResponseBody = 524288;
46 |
47 | /**
48 | * default 512kb.
49 | */
50 | private int maxRequestBody = 524288;
51 |
52 | /**
53 | * default 50000.
54 | */
55 | private int bufferQueueSize = 50000;
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/config/properties/AdminConfigProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.config.properties;
17 |
18 | import lombok.Data;
19 | import org.springframework.boot.context.properties.ConfigurationProperties;
20 | import org.springframework.context.annotation.Configuration;
21 |
22 | import java.util.List;
23 | import java.util.Map;
24 |
25 | /**
26 | * @author conghuhu
27 | * @create 2022/12/27 22:23
28 | */
29 | @Data
30 | @ConfigurationProperties(prefix = "qing.admin")
31 | @Configuration
32 | public class AdminConfigProperties {
33 |
34 | /**
35 | * 控制面的连接信息
36 | */
37 | private List infos;
38 |
39 | public static class AdminInfo {
40 | String url;
41 |
42 | public AdminInfo() {
43 | }
44 |
45 | public String getUrl() {
46 | return url;
47 | }
48 |
49 | public void setUrl(String url) {
50 | this.url = url;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/qing-gateway/qing-server/src/main/java/cn/qing/server/config/properties/RouteConfigProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 qing-gateway
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package cn.qing.server.config.properties;
17 |
18 | import lombok.Data;
19 | import org.springframework.boot.context.properties.ConfigurationProperties;
20 | import org.springframework.context.annotation.Configuration;
21 |
22 | import java.util.List;
23 | import java.util.Map;
24 |
25 | /**
26 | * 路由配置
27 | *
28 | * @author conghuhu
29 | * @create 2022-04-07 12:49
30 | */
31 | @Data
32 | @ConfigurationProperties(prefix = "qing")
33 | @Configuration
34 | public class RouteConfigProperties {
35 | private List