├── .gitattributes ├── .github ├── pull_request_template.md └── workflows │ └── ci.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── asset ├── dump-struct-qing_gateway-202206182109.sql ├── 单机性能.png ├── 处理流程.drawio ├── 处理流程.jpg ├── 实时监控.drawio ├── 实时监控.jpg ├── 数据同步.drawio ├── 数据同步.jpg ├── 整体架构.drawio ├── 整体架构.jpg ├── 监控metrics.png ├── 网关管理平台首页.png ├── 限流.drawio ├── 限流.jpg └── 集群性能.png ├── codecov.yml ├── docs ├── Qing GatewayPPT.pptx ├── dev │ ├── development.md │ └── images │ │ ├── grafana.png │ │ ├── res.png │ │ ├── route.png │ │ ├── templeate.png │ │ └── zipkin.png ├── 作品设计文档.docx └── 技术文档.docx ├── qing-gateway-front ├── .browserslistrc ├── .gitignore ├── README.md ├── ice.config.mts ├── package.json ├── pnpm-lock.yaml ├── public │ └── favicon.ico ├── src │ ├── api │ │ └── GlobalInterface.ts │ ├── app.ts │ ├── assets │ │ ├── login4.svg │ │ └── logo.png │ ├── components │ │ ├── AddRouteForm │ │ │ └── index.tsx │ │ └── EditRouteForm │ │ │ └── index.tsx │ ├── document.tsx │ ├── global.css │ ├── models │ │ └── user.ts │ ├── pages │ │ ├── $.tsx │ │ ├── Config │ │ │ └── index.tsx │ │ ├── GatewayNode │ │ │ ├── index.module.css │ │ │ └── index.tsx │ │ ├── Limit │ │ │ ├── index.module.css │ │ │ └── index.tsx │ │ ├── LoadBalance │ │ │ ├── index.module.css │ │ │ └── index.tsx │ │ ├── LogPage │ │ │ ├── index.module.css │ │ │ └── index.tsx │ │ ├── Login │ │ │ ├── index.module.css │ │ │ └── index.tsx │ │ ├── Route │ │ │ ├── index.module.css │ │ │ └── index.tsx │ │ ├── ServiceAndInstance │ │ │ ├── index.module.css │ │ │ └── index.tsx │ │ ├── index.module.css │ │ ├── index.tsx │ │ ├── layout.tsx │ │ └── menuConfig.tsx │ ├── services │ │ └── GlobalService.ts │ └── typings.d.ts └── tsconfig.json └── qing-gateway ├── .gitignore ├── README.md ├── db └── mysql │ ├── dump.sql │ └── qing_gateway.sql ├── mvnw ├── mvnw.cmd ├── pom.xml ├── qing-admin ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── admin_dockerfile ├── pom.xml └── src │ ├── http │ ├── test.http │ └── 网关客户端测试.http │ ├── main │ ├── java │ │ └── cn │ │ │ └── qing │ │ │ └── admin │ │ │ ├── CodeGenerator.java │ │ │ ├── QingAdminApplication.java │ │ │ ├── cache │ │ │ └── LoadBalanceCache.java │ │ │ ├── config │ │ │ ├── MybatisPlusConfig.java │ │ │ ├── RedisConfig.java │ │ │ ├── RedisSubListenerConfig.java │ │ │ ├── ScheduledConfig.java │ │ │ ├── Swagger3Config.java │ │ │ ├── ThreadPoolConfig.java │ │ │ ├── WebConfig.java │ │ │ └── properties │ │ │ │ └── WebsocketSyncProperties.java │ │ │ ├── controller │ │ │ ├── AuthController.java │ │ │ ├── LimitRuleController.java │ │ │ ├── NacosInfoController.java │ │ │ ├── PluginController.java │ │ │ ├── RouteRuleController.java │ │ │ ├── SystemController.java │ │ │ └── WebsocketInfoController.java │ │ │ ├── entity │ │ │ ├── QLimitRule.java │ │ │ ├── QLog.java │ │ │ ├── QNacosInfo.java │ │ │ ├── QPlugin.java │ │ │ ├── QRouteRule.java │ │ │ ├── QService.java │ │ │ ├── QServiceInstance.java │ │ │ ├── QUser.java │ │ │ └── QWebsocketInfo.java │ │ │ ├── event │ │ │ ├── limitEvent │ │ │ │ ├── LimitRuleAddEvent.java │ │ │ │ ├── LimitRuleDeleteEvent.java │ │ │ │ ├── LimitRuleUpdateEvent.java │ │ │ │ └── listener │ │ │ │ │ └── LimitRuleEventListener.java │ │ │ ├── ruleEvent │ │ │ │ ├── RuleAddEvent.java │ │ │ │ ├── RuleDeleteEvent.java │ │ │ │ ├── RuleUpdateEvent.java │ │ │ │ └── listener │ │ │ │ │ └── RuleEventListener.java │ │ │ └── serviceEvent │ │ │ │ ├── ServiceAddEvent.java │ │ │ │ ├── ServiceClearEvent.java │ │ │ │ ├── ServiceRemoveEvent.java │ │ │ │ ├── ServiceUpdateEvent.java │ │ │ │ └── listener │ │ │ │ └── ServiceEventListener.java │ │ │ ├── handler │ │ │ ├── MyInterceptor.java │ │ │ └── QingExceptionHandler.java │ │ │ ├── mapper │ │ │ ├── QLimitRuleMapper.java │ │ │ ├── QLogMapper.java │ │ │ ├── QNacosInfoMapper.java │ │ │ ├── QPluginMapper.java │ │ │ ├── QRouteRuleMapper.java │ │ │ ├── QServiceInstanceMapper.java │ │ │ ├── QServiceMapper.java │ │ │ ├── QUserMapper.java │ │ │ └── QWebsocketInfoMapper.java │ │ │ ├── pojo │ │ │ ├── params │ │ │ │ ├── InitParam.java │ │ │ │ ├── InstanceUpdateParam.java │ │ │ │ ├── PageParam.java │ │ │ │ ├── RegisterParam.java │ │ │ │ ├── RouteRuleParam.java │ │ │ │ └── WebsocketParam.java │ │ │ └── vo │ │ │ │ ├── ConfigInfo.java │ │ │ │ ├── MonitorInfoVo.java │ │ │ │ ├── PageResult.java │ │ │ │ ├── Result.java │ │ │ │ ├── RouteRuleVo.java │ │ │ │ ├── ServiceInfoVo.java │ │ │ │ └── UserInfo.java │ │ │ ├── service │ │ │ ├── CoreService.java │ │ │ ├── QLimitRuleService.java │ │ │ ├── QLogService.java │ │ │ ├── QNacosInfoService.java │ │ │ ├── QPluginService.java │ │ │ ├── QRouteRuleService.java │ │ │ ├── QServiceInstanceService.java │ │ │ ├── QServiceService.java │ │ │ ├── QUserService.java │ │ │ ├── QWebsocketInfoService.java │ │ │ └── impl │ │ │ │ ├── QLimitRuleServiceImpl.java │ │ │ │ ├── QLogServiceImpl.java │ │ │ │ ├── QNacosInfoServiceImpl.java │ │ │ │ ├── QPluginServiceImpl.java │ │ │ │ ├── QRouteRuleServiceImpl.java │ │ │ │ ├── QServiceInstanceServiceImpl.java │ │ │ │ ├── QServiceServiceImpl.java │ │ │ │ ├── QUserServiceImpl.java │ │ │ │ └── QWebsocketInfoServiceImpl.java │ │ │ ├── spring │ │ │ └── QingApplicationContextAware.java │ │ │ ├── starter │ │ │ └── SystemInitStarter.java │ │ │ ├── sync │ │ │ ├── NacosSyncListener.java │ │ │ ├── RedisReceiver.java │ │ │ └── WebsocketDataSyncServer.java │ │ │ ├── transfer │ │ │ ├── LogTransfer.java │ │ │ ├── RouteRuleTransfer.java │ │ │ └── ServiceInstanceTransfer.java │ │ │ └── util │ │ │ ├── MD5UUIDSaltUtil.java │ │ │ ├── NacosUtil.java │ │ │ ├── RedisUtil.java │ │ │ ├── SpringContextUtil.java │ │ │ └── WebsocketClientUtil.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── mapper │ │ ├── QLimitRuleMapper.xml │ │ ├── QLogMapper.xml │ │ ├── QNacosInfoMapper.xml │ │ ├── QPluginMapper.xml │ │ ├── QRouteRuleMapper.xml │ │ ├── QServiceInstanceMapper.xml │ │ ├── QServiceMapper.xml │ │ ├── QUserMapper.xml │ │ └── QWebsocketInfoMapper.xml │ └── test │ └── java │ └── cn │ └── qing │ └── admin │ └── QingAdminApplicationTests.java ├── qing-common ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── qing │ │ │ └── common │ │ │ ├── concurrent │ │ │ └── QingThreadFactory.java │ │ │ ├── constants │ │ │ ├── CommonConstant.java │ │ │ ├── LoadBalanceConstants.java │ │ │ ├── NacosConstants.java │ │ │ ├── ProtocolConstantMap.java │ │ │ ├── PublicConstant.java │ │ │ └── RedisChannel.java │ │ │ ├── dto │ │ │ ├── CpuInfoDTO.java │ │ │ ├── JvmInfoDTO.java │ │ │ ├── LZ4CompressData.java │ │ │ ├── LimitRuleDTO.java │ │ │ ├── LogDTO.java │ │ │ ├── MemInfoDTO.java │ │ │ ├── QpsDTO.java │ │ │ ├── ServiceInstance.java │ │ │ ├── ServiceRuleDTO.java │ │ │ ├── SysInfoDTO.java │ │ │ ├── ThreadInfoDTO.java │ │ │ ├── ThreadInfoItemDTO.java │ │ │ └── WebsocketMessageDTO.java │ │ │ ├── enums │ │ │ ├── ActionTypeEnum.java │ │ │ ├── EventTypeEnum.java │ │ │ ├── QingExceptionEnum.java │ │ │ ├── QingPluginEnum.java │ │ │ └── ResultEnum.java │ │ │ ├── exception │ │ │ └── QingException.java │ │ │ └── utils │ │ │ ├── DateUtils.java │ │ │ ├── JwtTokenUtil.java │ │ │ ├── LicenseCopyUtils.java │ │ │ ├── ObjectTypeUtils.java │ │ │ ├── ParamCheckUtils.java │ │ │ ├── ThreadUtils.java │ │ │ └── UUIDUtils.java │ └── resources │ │ └── license.txt │ └── test │ └── java │ └── cn │ └── qing │ └── common │ ├── concurrent │ └── QingThreadFactoryTest.java │ └── utils │ ├── DateUtilsTest.java │ ├── ObjectTypeUtilsTest.java │ ├── ParamCheckUtilsTest.java │ └── UUIDUtilsTest.java ├── qing-examples ├── client-example-traffic │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── example1_dockerfile │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── qingclientexqmple │ │ │ ├── QingClientExqmpleApplication.java │ │ │ ├── config │ │ │ ├── MyWebMvcConfig.java │ │ │ └── OtelConfig.java │ │ │ ├── controller │ │ │ └── TrafficController.java │ │ │ ├── filter │ │ │ └── TraceInterceptor.java │ │ │ ├── params │ │ │ └── QueryParam.java │ │ │ └── utils │ │ │ └── TraceIdUtil.java │ │ └── resources │ │ └── application.yml ├── client-exqmple-medical │ ├── example2_dockerfile │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── example │ │ │ ├── QingClientMedicalApplication.java │ │ │ └── controller │ │ │ └── MedicalController.java │ │ └── resources │ │ └── application.yml └── pom.xml ├── qing-server ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml ├── server_dockerfile └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── qing │ │ │ └── server │ │ │ ├── QingServerApplication.java │ │ │ ├── annotation │ │ │ └── LoadBalanceType.java │ │ │ ├── cache │ │ │ ├── IdentificationCache.java │ │ │ ├── LimitRuleCache.java │ │ │ ├── LogCache.java │ │ │ ├── PluginCache.java │ │ │ ├── QpsCache.java │ │ │ ├── RouteRuleCache.java │ │ │ └── ServiceCache.java │ │ │ ├── chain │ │ │ ├── DefaultQingPluginChain.java │ │ │ └── QingPluginChain.java │ │ │ ├── config │ │ │ ├── FilterConfig.java │ │ │ ├── OtelTracingConfig.java │ │ │ ├── QingConfig.java │ │ │ ├── RedisConfig.java │ │ │ ├── ScheduledConfig.java │ │ │ ├── ThreadPoolConfig.java │ │ │ ├── WebClientConfig.java │ │ │ ├── WebFluxConfig.java │ │ │ └── properties │ │ │ │ ├── AccessLoggingProperties.java │ │ │ │ ├── AdminConfigProperties.java │ │ │ │ ├── RouteConfigProperties.java │ │ │ │ ├── ServerConfigProperties.java │ │ │ │ └── WebClientProperties.java │ │ │ ├── factory │ │ │ └── LoadBalanceFactory.java │ │ │ ├── filter │ │ │ └── PluginFilter.java │ │ │ ├── handler │ │ │ ├── ExceptionHandler.java │ │ │ └── QingWebHandler.java │ │ │ ├── plugin │ │ │ ├── base │ │ │ │ ├── AbstractQingPlugin.java │ │ │ │ ├── QingContext.java │ │ │ │ └── QingPlugin.java │ │ │ ├── impl │ │ │ │ ├── AuthPlugin.java │ │ │ │ ├── CurrentLimitingPlugin.java │ │ │ │ ├── DynamicRoutePlugin.java │ │ │ │ ├── GlobalPlugin.java │ │ │ │ ├── LoggingPlugin.java │ │ │ │ ├── MetricsPlugin.java │ │ │ │ ├── TracingPlugin.java │ │ │ │ └── WebHttpClientPlugin.java │ │ │ └── result │ │ │ │ └── QingResult.java │ │ │ ├── spi │ │ │ ├── LoadBalance.java │ │ │ └── balance │ │ │ │ ├── RandomBalance.java │ │ │ │ ├── RoundRobinBalance.java │ │ │ │ └── WeightRoundBalance.java │ │ │ ├── spring │ │ │ └── QingApplicationContextAware.java │ │ │ ├── sync │ │ │ └── WebsocketDataSyncClient.java │ │ │ └── utils │ │ │ ├── HttpUtil.java │ │ │ ├── MDCUtil.java │ │ │ ├── QingResponseUtil.java │ │ │ ├── RateLimiter.java │ │ │ ├── RedisSyncUtil.java │ │ │ ├── RedisUtil.java │ │ │ ├── RouteTrie.java │ │ │ └── SpringContextUtil.java │ └── resources │ │ ├── META-INF │ │ ├── additional-spring-configuration-metadata.json │ │ └── services │ │ │ └── cn.qing.server.spi.LoadBalance │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── lua │ │ └── limiter.lua │ └── test │ └── java │ └── cn │ └── qing │ └── server │ └── RouteTrieTest.java └── scripts └── checkstyle-header.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | *.java linguist-language=Java 2 | *.ts linguist-language=Java -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## What's changed and what's your intention? 2 | 3 | ***PLEASE DO NOT LEAVE THIS EMPTY !!!*** 4 | 5 | Please explain **IN DETAIL** what the changes are in this PR and why they are needed: 6 | 7 | - Summarize your change (**mandatory**) 8 | - How does this PR work? Need a brief introduction for the changed logic (optional) 9 | - Describe clearly one logical change and avoid lazy messages (optional) 10 | - Describe any limitations of the current code (optional) 11 | 12 | ## Checklist 13 | 14 | - [ ] I have written necessary docs and comments 15 | - [ ] I have added necessary unit tests and integration tests 16 | 17 | ## Refer to a related PR or issue link (optional) 18 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: pr-test 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | paths: 7 | - ".github/workflows/ci.yml" 8 | - "qing-gateway/**" 9 | push: 10 | branches: 11 | - main 12 | paths: 13 | - ".github/workflows/ci.yml" 14 | - "qing-gateway/**" 15 | jobs: 16 | run: 17 | runs-on: ubuntu-latest 18 | defaults: 19 | run: 20 | working-directory: ./qing-gateway 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v2 24 | - name: Set up JDK 1.8 25 | uses: actions/setup-java@v1 26 | with: 27 | java-version: 1.8 28 | - name: Install dependencies 29 | run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 30 | - name: Run tests and collect coverage 31 | run: mvn -B test 32 | - name: Upload coverage to Codecov 33 | uses: codecov/codecov-action@v3 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.mp4 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution and Development Guidelines 2 | 3 | Thanks for your interest in contributing to this project! We welcome and appreciate contributions. 4 | 5 | If you have questions, please [create a Github issue](https://github.com/conghuhu/qing-gateway/issues/new). 6 | 7 | ## Setting Up Development Environment 8 | 9 | Please refer to the [Development Guide](/docs/dev/development.md) for more information. 10 | 11 | ## Submit a PR 12 | 13 | ### Pull Request Title 14 | 15 | As described [here](https://github.com/commitizen/conventional-commit-types/blob/master/index.json), a valid PR title should begin with one of the following prefixes: 16 | 17 | - `feat`: A new feature 18 | - `fix`: A bug fix 19 | - `docs`: Documentation only changes 20 | - `style`: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc) 21 | - `refactor`: A code change that neither fixes a bug nor adds a feature 22 | - `perf`: A code change that improves performance 23 | - `test`: Adding missing tests or correcting existing tests 24 | - `build`: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) 25 | - `ci`: Changes to RisingWave CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) 26 | - `chore`: Other changes that don't modify src or test files 27 | - `revert`: Reverts a previous commit 28 | 29 | For example, a PR title could be: 30 | 31 | - `refactor: modify executor protobuf package path` 32 | - `feat(execution): enable comparison between nullable data arrays`, where `(execution)` means that this PR mainly focuses on the execution component. 33 | 34 | You may also check out previous PRs in the [PR list](https://github.com/conghuhu/qing-gateway/pulls). 35 | 36 | ### Pull Request Description 37 | 38 | - If your PR is small (such as a typo fix), you can go brief. 39 | - If it is large and you have changed a lot, it's better to write more details. 40 | -------------------------------------------------------------------------------- /asset/单机性能.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/单机性能.png -------------------------------------------------------------------------------- /asset/处理流程.drawio: -------------------------------------------------------------------------------- 1 | 5VpNc5swEP01OqaDkMDiCP5o0klnOpND29ywkQ0JRq6QYzu/vgLEVxGxO0ns2EkOgZVkSe/t7lspBmi43H7l/ir8zgIaA9MItgCNgGlCaJjyT2bZFRaCcWFY8ChQnWrDXfRMldFQ1nUU0LTVUTAWi2jVNs5YktCZaNl8ztmm3W3O4vasK39BO4a7mR93rT+jQIRqF+agtl/TaBGWM0PbKVqWftlZ7SQN/YBtGiY0BmjIGRPF03I7pHEGXolLMW7S01otjNNEHDIgmEO+c9AvForfs28318Efh1wpdp78eK02rBYrdiUCNJCAqFfGRcgWLPHjcW31OFsnAc2mMeRb3eeWsZU0Qml8oELsFLv+WjBpCsUyVq3FnNlEvXtTppSt+Uz1un+076lA8MHEKXRHNxOPbK5KH/H5gooXNg4rBqTrUrakgu/kOE5jX0RP7XX4yocWVb8aZvmgkNaj/tIiG6hfC7ECYwLcCfAGYGwDDwLS5aKN9CaMBL1b+TkgGxl/bVTnURwPWcx4PhbNrexX2lPB2SNttNj5TzaCJaJhL34qfjR0PFEu6LZh6iKqWqswUHkAlu+bOqoqW9iIKGy8ngStB+Azdv1+lz7A9dGRXF+/SOOzwj44KexWF/axBRwDuLYW/1t/KpW8hZkfR4tEPs8kRFSmCC+L/khKpasallEQFPTQNHr2p/nnZQStWJSIfEuWB6xRhX8nfVQ6rgbX6tlk5gXH6s0/V8YXWXuQVg4q1e9gCtSn/8i20+jC5vNUUv8vR9UiXkFbhzV3LbOl1AcyAY6kEAPPA16XQh6y5XSd/rdIBBYlAdaJBDGnKBeJXuo6wdMvBqU77sp3jRggjRiQ9xID+9KyEjowK1knzUrnXH6+CnZ4rPpTP7vG3S9MDcx9aoAMy24noY8uBkhDmgMcJ+MtOzFYgMCLkwakOyccVRrgxR0UrEOT1GlPCoOLT1J4b5IybdwKB/jRk1QZHJ8vWvoS23GiRX++Iy5wSa4JRi4OJLtdcidgPAAOzu6YLk0uMD61XOizlosBwTnskgg7R5sA4pUPhnpw3S7+VSjA/Ry8AaLYaF/UmUiDqHHMizrYPQWfN6RI56THhVRXS54zpNg+OaREA6nMtyPgDvNULNMsPDluVTQr3GzrQNys98LN1LjieRcM1f8p99bX5JQVg6kpGT4J8GZP4X0k4C/+9sXsuVVs3MVjhFqJ6OMfbHRViBTFQSaHmXaOgePmAukA4lxcYW1hqysURy2sTc09zFnXLJatgfSNahb5Wn+zpAiB+vs5aPwX -------------------------------------------------------------------------------- /asset/处理流程.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/处理流程.jpg -------------------------------------------------------------------------------- /asset/实时监控.drawio: -------------------------------------------------------------------------------- 1 | 3Zhbc6IwFMc/jY86QET0cb1sO512pq073cdOhANkC4QNsWo//QYJAgYVd7GXffFyEnL5/c8lpIMm4fqK4di/ow4EHUNz1h007RiGNdDEZ2rYZAZzaGQGjxEnM+mFYU7eQBrlc96SOJBUOnJKA07iqtGmUQQ2r9gwY3RV7ebSoDprjD1QDHMbB6r1J3G4n1mHhlXYr4F4fj6zPhhlLSHOO8udJD526KpkQrMOmjBKefYrXE8gSNnlXLLnvh9o3S2MQcSbPHB9s9488KfH8RhZsfPjCeD3pDvMRnnFwVJuWC6Wb3ICHqPLuIPGLgmCCQ0o25qRO3ItEEOPE87oC5Ra0ACNUNoixwbGYV0nFl7kc2jqZvQdIuFaQEPgbCO6yIH6lnxkk3M3emZmWZVkkp38kkJoIPth6RnebvACnvgh+Z3B0lBYPoJDEgWo4Bk5KbqpJiCtfMJhHmM7bV2JGBI2n4di5ql+jGGZ1WFpVYAfhsc67WrJC3Dbl2BwEmcB7ZL11tFKVGJKIr5doDnumNO0d0C8SBhsAQWEI45JuI3ssUsjLtOKbhT2KQk9sY2ALNLNJDYG8T3Btg/PW9We7xl1ljbvJa/eJWTIRzH33FhTnNisUalvXEgkfaSIAo5IiPIvZdynHo1wMCus46pDF31uKY2lYL+A842UAS85rXPydKKDbKUpoUtmw7EN5EUCMw+O6WLU68IgwJy8VhfSPmb9dDCclSb2k/PQBtuuS86Lodk3taYefTwJ64O9JGyp3quPatx359Ptg1WTcKtgbQcWw8XfVb3mYAfmabCD9+WKFK4P9/MjaPWWStsJDxxavWoGNbQaH0RmTQq9GCpTQXUHIZUjfzJadRH7vrTUE+jN090nRIXQR6MyVMf64sXaaFir9Q8t1rnwJe5XYrl16G/xQrz+VnApB9PUL4l4wfwmG0LiOJkykJA3+U6k1R5yDzp2kxeqIz51MAy6Wk8UeVQJhK6cszF8Ofp9up1SF+q6icRYVme3iH8IlIFarEgkjvvaFeawwmomFjx5VbZqfY9oBHuHAWlqLm9d0qoGYxt5q8HJQUd1R4dLZS3U4ET2xbLWsGHaQge0ep+0ZaiV9ZsTkuj/df79Y/PuguPEsRldrGKPFAnmNZVDFaDNopHGQiIvQM7QtgU90Mg8qcf75iL1tdtlNOLdme1jpgrT/k3dcWDWvgP3a7K3UUNsd290BjLxt7h8zkpvcYOPZn8A -------------------------------------------------------------------------------- /asset/实时监控.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/实时监控.jpg -------------------------------------------------------------------------------- /asset/数据同步.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/数据同步.jpg -------------------------------------------------------------------------------- /asset/整体架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/整体架构.jpg -------------------------------------------------------------------------------- /asset/监控metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/监控metrics.png -------------------------------------------------------------------------------- /asset/网关管理平台首页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/网关管理平台首页.png -------------------------------------------------------------------------------- /asset/限流.drawio: -------------------------------------------------------------------------------- 1 | 3Vhbb6M4GP01fpyIm8E8koRuHzqrajrSXl5GDhjwDmAEJpf59WvAQIhJlKrJRlupau3jC/h85/t6DDBX2f63EhfJVxaSFBhauAfmGhiGrmlI/GmQQ4c4mtkBcUlDOWkE3ugv0q+UaE1DUk0mcsZSTospGLA8JwGfYLgs2W46LWLp9KkFjokCvAU4VdE/aMiTDkWGM+LPhMZJ/2TddruRDPeT5UmqBIdsdwSZPjBXJWO8a2X7FUkb8npeunVPZ0aHFytJzq9ZEOHcMZ6zPEuKHdW3K+/r739/sbpdtjit5YHly/JDzwAJBSGyy0qesJjlOPVHdFmyOg9J8xhN9MY5L4wVAtQF+A/h/CCji2vOBJTwLJWj3TObB509m4QqVpcBuXCgXiO4jAm/MM8cIiCkS1hGeHkQ60qSYk630/fAUkPxMG+kWTQk0+9gXVdYf/7+/VVhfsrrLqGcvBW4Pf5OZNuUw4im6YqlrGzXmiEkKLQEXvGS/SRHI8jYmLY9sL4lJSf7y7yrPPULbNgtkdltQin23ZgrOpJYcpQnlnYvao3PpmjjSkXrZ0L130hapf0b5uSFZkK0pRh4TeuY5hckrr9b4lEUGUEwJ/HQ3tjwVhJ3pxKHcxI3ZiRu30vi8LMp3LxS4cYjBW4qrHu1iP8Vyr6ieN9Bp5b1aJ3qn89cXOsunIe6i5kC4dvARcB7Av4TWK6A6wHfBa740ZqhJQRIB74DvDVw7aYhxOTB2Wi94I2w+BOGcUrjXLQDQago9uayETIVHtqTAxkNwy6YpKK/8KbdrwlnwWjO2/PDJYDrS5kgDb5cDAZbfRzHCzI8mzdftIWOetcgc0f2rg6X3Py1Oc3RFBZFlZDJaTyHd/hAiJ1HZBLZU/5ns3wBZe+vo5H1Xu7cdg6yc/Ps+0BWnYRJCsCA1sKFwhdr8rc90QKCJ/WxS365yR1Ci2ayFzaJ6tlH2Svy2QJLH/giq3WAVp8kV88UzjFXTVc3/2e5qt72OlsssBUOEgJ8EUnU1N6m8HoAWW1UnbYhKjNqCvVYwActwCbsS7ep5Ei016oFSVi2qav33x0xQdGssbYDRDbRjQyLhRbO1LPYjupZhGlZQNW16NrdbIvq9BRmY1FLiw/J/zI3Vn9n7i8dtkrM3LV6AG/OiqOQ8o2EtFI1d3PbeyFIKn99UXg0XTNF/JSp6ifhQSKJwlXRfb2M6L5h75gltfAqRZxm7WfMZcRyLv99C0sz4GuaxeIYKd00h6kCLGrPU1t7frRR/PFasrAO+KLaxncJS7/NSbojJUpw7luR8e4gie74YbUr5OPnadP/Fw== -------------------------------------------------------------------------------- /asset/限流.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/限流.jpg -------------------------------------------------------------------------------- /asset/集群性能.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/asset/集群性能.png -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | # For documentation please see https://docs.codecov.com/docs/commit-status 2 | 3 | coverage: 4 | status: 5 | patch: off 6 | project: 7 | default: 8 | target: auto # base branch coverage is target 9 | threshold: 0% # percent deviation allowed from target branch coverage 10 | base: auto 11 | flags: 12 | - unittests 13 | paths: 14 | - "qing-gateway/qing-admin" 15 | - "qing-gateway/qing-server" 16 | - "qing-gateway/qing-common" -------------------------------------------------------------------------------- /docs/Qing GatewayPPT.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/Qing GatewayPPT.pptx -------------------------------------------------------------------------------- /docs/dev/images/grafana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/dev/images/grafana.png -------------------------------------------------------------------------------- /docs/dev/images/res.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/dev/images/res.png -------------------------------------------------------------------------------- /docs/dev/images/route.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/dev/images/route.png -------------------------------------------------------------------------------- /docs/dev/images/templeate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/dev/images/templeate.png -------------------------------------------------------------------------------- /docs/dev/images/zipkin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/dev/images/zipkin.png -------------------------------------------------------------------------------- /docs/作品设计文档.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/作品设计文档.docx -------------------------------------------------------------------------------- /docs/技术文档.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/docs/技术文档.docx -------------------------------------------------------------------------------- /qing-gateway-front/.browserslistrc: -------------------------------------------------------------------------------- 1 | defaults 2 | ios_saf 9 3 | -------------------------------------------------------------------------------- /qing-gateway-front/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # testing 5 | /coverage 6 | 7 | # production 8 | /build 9 | 10 | # misc 11 | .DS_Store 12 | *.swp 13 | *.dia~ 14 | 15 | # logs 16 | npm-debug.log* 17 | yarn-debug.log* 18 | yarn-error.log* 19 | pnpm-debug.log* 20 | 21 | # local env files 22 | .env*.local 23 | 24 | # tmp 25 | .ice 26 | .faas_debug_tmp 27 | .severless 28 | -------------------------------------------------------------------------------- /qing-gateway-front/README.md: -------------------------------------------------------------------------------- 1 | # ice.js 3 Lite Scaffold 2 | 3 | ## Usage 4 | 5 | ```bash 6 | $ npm install 7 | 8 | $ npm start 9 | ``` 10 | 11 | ## Directories 12 | 13 | ```md 14 | . 15 | ├── README.md 16 | ├── ice.config.mts # The project config 17 | ├── package.json 18 | ├── .browserslistrc # Browsers that we support 19 | ├── public 20 | │   ├── favicon.ico 21 | ├── src 22 | │   ├── app.ts # The app entry 23 | │   ├── assets 24 | │   │   └── logo.png 25 | │   ├── document.tsx 26 | │   ├── pages # Pages directory 27 | │   │   ├── index.module.css 28 | │   │   └── index.tsx # Index page entry 29 | │   └── typings.d.ts 30 | └── tsconfig.json 31 | ``` 32 | 33 | For more detail, please visit [docs](https://v3.ice.work/). 34 | -------------------------------------------------------------------------------- /qing-gateway-front/ice.config.mts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '@ice/app'; 2 | import antd from '@ice/plugin-antd'; 3 | import store from '@ice/plugin-store'; 4 | import request from '@ice/plugin-request'; 5 | 6 | // The project config, see https://v3.ice.work/docs/guide/basic/config 7 | const minify = process.env.NODE_ENV === 'production' ? 'swc' : false; 8 | export default defineConfig(() => ({ 9 | // Set your configs here. 10 | minify, 11 | plugins: [ 12 | antd({ 13 | importStyle: true, 14 | }), 15 | store(), 16 | request(), 17 | ], 18 | })); 19 | -------------------------------------------------------------------------------- /qing-gateway-front/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ice/lite-scaffold", 3 | "version": "0.1.0", 4 | "description": "ice.js 3 lite 模板", 5 | "dependencies": { 6 | "@ant-design/icons": "^4.8.0", 7 | "@ant-design/pro-layout": "^7.5.1", 8 | "@ice/runtime": "^1.0.0", 9 | "antd": "^5.1.2", 10 | "react": "^18.2.0", 11 | "react-dom": "^18.2.0" 12 | }, 13 | "devDependencies": { 14 | "@ice/app": "^3.0.0", 15 | "@ice/plugin-antd": "^1.0.0", 16 | "@ice/plugin-request": "^1.0.0", 17 | "@ice/plugin-store": "^1.0.1", 18 | "@types/node": "^18.11.17", 19 | "@types/react": "^18.0.0", 20 | "@types/react-dom": "^18.0.0" 21 | }, 22 | "scripts": { 23 | "start": "ice start", 24 | "build": "ice build" 25 | }, 26 | "private": true, 27 | "originTemplate": "@ice/lite-scaffold" 28 | } 29 | -------------------------------------------------------------------------------- /qing-gateway-front/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/qing-gateway-front/public/favicon.ico -------------------------------------------------------------------------------- /qing-gateway-front/src/app.ts: -------------------------------------------------------------------------------- 1 | import { defineAppConfig, history } from 'ice'; 2 | import { defineRequestConfig } from '@ice/plugin-request/esm/types'; 3 | import { message } from 'antd'; 4 | 5 | // App config, see https://v3.ice.work/docs/guide/basic/app 6 | export default defineAppConfig(() => ({ 7 | // Set your configs here. 8 | app: { 9 | rootId: 'ice-container', 10 | }, 11 | router: { 12 | type: 'hash', 13 | }, 14 | })); 15 | 16 | export const requestConfig = defineRequestConfig({ 17 | baseURL: 'http://localhost:8081', 18 | interceptors: { 19 | request: { 20 | onConfig: (config) => { 21 | // 发送请求前:可以对 RequestConfig 做一些统一处理 22 | const token = localStorage.getItem('token') || ''; 23 | if (token) { 24 | config.headers = { ...config.headers, Authorization: `Bearer ${token}` }; 25 | } 26 | return config; 27 | }, 28 | onError: (error) => { 29 | return Promise.reject(error); 30 | }, 31 | }, 32 | response: { 33 | onConfig: (response) => { 34 | if (!response.data.success) { 35 | message.warning(response.data.message); 36 | return Promise.reject(response.data.message); 37 | } 38 | return { ...response, data: response.data.result }; 39 | }, 40 | onError: (error) => { 41 | if (error.response?.data.message) { 42 | console.error(error.response); 43 | message.error(error.response.data.message); 44 | } 45 | if (error.response?.status === 401) { 46 | history?.push('/login'); 47 | } 48 | // 请求出错:服务端返回错误状态码 49 | return Promise.reject(error); 50 | }, 51 | }, 52 | }, 53 | }); -------------------------------------------------------------------------------- /qing-gateway-front/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conghuhu/qing-gateway/bc696fa677ee56875c0c04d931f1bcf9a4eec33c/qing-gateway-front/src/assets/logo.png -------------------------------------------------------------------------------- /qing-gateway-front/src/document.tsx: -------------------------------------------------------------------------------- 1 | import { Meta, Title, Links, Main, Scripts } from 'ice'; 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 | qing-gateway 9 | 10 | 11 | 12 | 13 | 14 | <Links /> 15 | </head> 16 | <body> 17 | <Main /> 18 | <Scripts /> 19 | </body> 20 | </html> 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /qing-gateway-front/src/global.css: -------------------------------------------------------------------------------- 1 | /* @import 'antd/dist/antd.css'; */ 2 | 3 | 4 | :root { 5 | --primary: #3178f6; 6 | --bg-primary: white; 7 | } 8 | 9 | body { 10 | margin: 0; 11 | } 12 | -------------------------------------------------------------------------------- /qing-gateway-front/src/models/user.ts: -------------------------------------------------------------------------------- 1 | import { createModel } from 'ice'; 2 | import { UserInfo } from '@/api/GlobalInterface'; 3 | 4 | interface ModelState { 5 | currentUser: UserInfo; 6 | } 7 | 8 | export default createModel({ 9 | state: { 10 | currentUser: {}, 11 | } as ModelState, 12 | reducers: { 13 | updateCurrentUser(prevState: ModelState, payload) { 14 | prevState.currentUser = payload; 15 | }, 16 | }, 17 | effects: (dispatch) => ({ 18 | getUserInfo() { 19 | dispatch.user.update({ 20 | username: 'taobao', 21 | userId: '123', 22 | }); 23 | }, 24 | }), 25 | }); -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/$.tsx: -------------------------------------------------------------------------------- 1 | import { history } from 'ice'; 2 | import { Button, Result } from 'antd'; 3 | import React from 'react'; 4 | 5 | const NotFoundPage: React.FC = () => ( 6 | <Result 7 | status="404" 8 | title="404" 9 | subTitle="你访问的页面不存在" 10 | extra={ 11 | <Button type="primary" onClick={() => history?.push('/')}> 12 | 返回 13 | </Button> 14 | } 15 | /> 16 | ); 17 | 18 | export default NotFoundPage; 19 | -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/GatewayNode/index.module.css: -------------------------------------------------------------------------------- 1 | .headContainer { 2 | margin-bottom: 1.5rem; 3 | } 4 | .button { 5 | margin-right: 2rem; 6 | margin-left: 2rem; 7 | } -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/Limit/index.module.css: -------------------------------------------------------------------------------- 1 | .headContainer { 2 | margin-bottom: 1.5rem; 3 | } 4 | 5 | .button { 6 | margin-right: 2rem; 7 | margin-left: 2rem; 8 | } -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/LoadBalance/index.module.css: -------------------------------------------------------------------------------- 1 | .leftTop::after { 2 | content:""; 3 | position: absolute; 4 | left: 0px; 5 | top: 0px; 6 | height: 20px; 7 | width: 20px; 8 | background-color: red; 9 | border: 1px solid rgba(44, 43, 43, 0.8); 10 | transform: skew(-40deg); 11 | } -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/LogPage/index.module.css: -------------------------------------------------------------------------------- 1 | .headContainer { 2 | margin-bottom: 1.5rem; 3 | } 4 | .button { 5 | margin-right: 2rem; 6 | margin-left: 2rem; 7 | } -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/Login/index.module.css: -------------------------------------------------------------------------------- 1 | .cointainer { 2 | background-color: rgb(255, 255, 255); 3 | min-height: 100vh; 4 | position: relative; 5 | overflow: hidden; 6 | } 7 | .cointainer::after { 8 | content: ""; 9 | position: absolute; 10 | width: 90vw; 11 | height: 150vh; 12 | border-radius: 50%; 13 | background-color: rgb(41,140,236); 14 | left: -40vw; 15 | top: -70vh; 16 | z-index: 1; 17 | } 18 | .title { 19 | position: absolute; 20 | width: 25vw; 21 | height: 3vh; 22 | z-index: 99; 23 | font-family: Arial, Helvetica, sans-serif; 24 | font-size: 2vw; 25 | color: white; 26 | left: 10vw; 27 | top: 5vh; 28 | } 29 | .left { 30 | position: absolute; 31 | left: 10vw; 32 | height: 50vh; 33 | width: 30vw; 34 | bottom: 10vh; 35 | z-index: 99; 36 | } 37 | .Login { 38 | position: absolute; 39 | display: flex; 40 | flex-direction: column; 41 | justify-content: center; 42 | align-items: center; 43 | width: 40vw; 44 | height: 80vh; 45 | /* border: 5px solid rgb(14, 14, 14,0.5); */ 46 | right: 8vw; 47 | top: 10vh; 48 | z-index: 100; 49 | } 50 | .Login > span { 51 | margin-top: -8vh; 52 | margin-bottom: 8vh; 53 | font-size: 3vw; 54 | font-weight: 700; 55 | color: rgb(70,70,70); 56 | } -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/Route/index.module.css: -------------------------------------------------------------------------------- 1 | .headContainer { 2 | margin-bottom: 1.5rem; 3 | } 4 | .button { 5 | margin-right: 2rem; 6 | margin-left: 2rem; 7 | } -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/ServiceAndInstance/index.module.css: -------------------------------------------------------------------------------- 1 | .headContainer { 2 | margin-bottom: 1.5rem; 3 | } 4 | 5 | .button {} 6 | 7 | .editable-row .ant-form-item-explain { 8 | position: absolute; 9 | top: 100%; 10 | font-size: 12px; 11 | } -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | .app { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | justify-content: center; 6 | height: 80vh; 7 | } 8 | 9 | .app > header { 10 | display: flex; 11 | flex-direction: column; 12 | align-items: center; 13 | } 14 | 15 | .app > header > img { 16 | width: 120px; 17 | } 18 | 19 | .app > header > p { 20 | margin: 20px 0; 21 | text-align: center; 22 | font-size: 2.6rem; 23 | } 24 | 25 | .app > main { 26 | display: flex; 27 | flex-direction: column; 28 | margin: 20px 0 10px; 29 | font-size: 0.9rem; 30 | } 31 | 32 | .link { 33 | font-size: 1.2rem; 34 | color: var(--primary); 35 | } 36 | 37 | .button { 38 | outline: none; 39 | border: none; 40 | border-radius: 8px; 41 | padding: 10px 35px; 42 | background: var(--primary); 43 | box-shadow: 0 5px 10px 0 #ddd; 44 | color: white; 45 | font-size: calc(10px + 2vmin); 46 | } 47 | -------------------------------------------------------------------------------- /qing-gateway-front/src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import logo from '@/assets/logo.png'; 3 | import styles from './index.module.css'; 4 | 5 | export default function Home() { 6 | const [count, setCount] = useState(1); 7 | const updateCount = () => setCount((c) => c + 1); 8 | 9 | return ( 10 | <div className={styles.app}> 11 | <header> 12 | <img src={logo} alt="logo" /> 13 | <p> 14 | Welcome to Qing Gateway 15 | </p> 16 | </header> 17 | <main> 18 | <button className={styles.button} type="button" onClick={updateCount}> 19 | 👍🏻 {count} 20 | </button> 21 | </main> 22 | </div> 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: <SmileOutlined />, 15 | }, 16 | { 17 | name: '监控', 18 | path: '/monitor', 19 | icon: <LineChartOutlined />, 20 | }, 21 | { 22 | name: '路由配置', 23 | icon: <WifiOutlined />, 24 | path: '/route', 25 | }, 26 | { 27 | name: '网关节点', 28 | path: '/gatewayNode', 29 | icon: <GatewayOutlined />, 30 | }, 31 | { 32 | name: '服务实例', 33 | path: '/serviceAndInstance', 34 | icon: <GroupOutlined />, 35 | }, 36 | { 37 | name: '限流规则', 38 | path: '/limit', 39 | icon: <InteractionOutlined />, 40 | }, 41 | { 42 | name: '负载均衡', 43 | path: '/loadBalance', 44 | icon: <ControlOutlined />, 45 | }, 46 | { 47 | name: '调用行为日志', 48 | path: '/logPage', 49 | icon: <FileSearchOutlined />, 50 | }, 51 | { 52 | name: '系统初始化', 53 | path: '/config', 54 | icon: <SettingOutlined />, 55 | }, 56 | ]; 57 | 58 | export { asideMenuConfig }; 59 | -------------------------------------------------------------------------------- /qing-gateway-front/src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /// <reference types="@ice/app/types" /> 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 | ![整体架构](D:\MainProject\Qing_Gateway\asset\整体架构.jpg) 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 <conghuhu_blog> 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<String> loadBalanceList = new CopyOnWriteArrayList<>(); 29 | 30 | private static String currentLoadBalance; 31 | 32 | public static void addAll(List<String> list) { 33 | loadBalanceList.addAll(list); 34 | List<String> distinctList = loadBalanceList.stream().distinct().collect(Collectors.toList()); 35 | loadBalanceList.clear(); 36 | loadBalanceList.addAll(distinctList); 37 | } 38 | 39 | public static List<String> 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<List<QPlugin>> getPluginList() { 49 | List<QPlugin> 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<List<QWebsocketInfo>> getWebsocketInfo() { 49 | List<QWebsocketInfo> 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 | * <p> 31 | * 32 | * </p> 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 | * <p> 31 | * 32 | * </p> 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 | * <p> 29 | * 30 | * </p> 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 | * <p> 29 | * 30 | * </p> 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 | * <p> 31 | * 32 | * </p> 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<String, LimitRuleDTO> limitRuleMap; 30 | 31 | public LimitRuleAddEvent(Object source, Map<String, LimitRuleDTO> limitRuleMap) { 32 | super(source); 33 | this.limitRuleMap = limitRuleMap; 34 | } 35 | 36 | public Map<String, LimitRuleDTO> 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<String, LimitRuleDTO> limitRuleMap; 30 | 31 | public LimitRuleUpdateEvent(Object source, Map<String, LimitRuleDTO> limitRuleMap) { 32 | super(source); 33 | this.limitRuleMap = limitRuleMap; 34 | } 35 | 36 | public Map<String, LimitRuleDTO> 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<String, ServiceRuleDTO> serviceRuleMap; 30 | 31 | public RuleAddEvent(Object source, Map<String, ServiceRuleDTO> serviceRuleMap) { 32 | super(source); 33 | this.serviceRuleMap = serviceRuleMap; 34 | } 35 | 36 | public Map<String, ServiceRuleDTO> 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<String, ServiceRuleDTO> serviceRuleMap; 30 | 31 | public RuleUpdateEvent(Object source, Map<String, ServiceRuleDTO> serviceRuleMap) { 32 | super(source); 33 | this.serviceRuleMap = serviceRuleMap; 34 | } 35 | 36 | public Map<String, ServiceRuleDTO> 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<String, List<ServiceInstance>> serviceMap; 31 | 32 | public ServiceAddEvent(Object source, Map<String, List<ServiceInstance>> serviceMap) { 33 | super(source); 34 | this.serviceMap = serviceMap; 35 | } 36 | 37 | public Map<String, List<ServiceInstance>> 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<String> onlineServices; 28 | 29 | public ServiceRemoveEvent(Object source, List<String> onlineServices) { 30 | super(source); 31 | this.onlineServices = onlineServices; 32 | } 33 | 34 | public List<String> 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<String, List<ServiceInstance>> serviceMap; 31 | 32 | public ServiceUpdateEvent(Object source, Map<String, List<ServiceInstance>> serviceMap) { 33 | super(source); 34 | this.serviceMap = serviceMap; 35 | } 36 | 37 | public Map<String, List<ServiceInstance>> 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 | * <p> 25 | * Mapper 接口 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-15 30 | */ 31 | @Repository 32 | @Mapper 33 | public interface QLimitRuleMapper extends BaseMapper<QLimitRule> { 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 | * <p> 25 | * Mapper 接口 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-18 30 | */ 31 | @Mapper 32 | @Repository 33 | public interface QLogMapper extends BaseMapper<QLog> { 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 | * <p> 27 | * Mapper 接口 28 | * </p> 29 | * 30 | * @author conghuhu 31 | * @since 2022-04-08 32 | */ 33 | @Mapper 34 | @Repository 35 | public interface QNacosInfoMapper extends BaseMapper<QNacosInfo> { 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 | * <p> 25 | * Mapper 接口 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-08 30 | */ 31 | @Mapper 32 | @Repository 33 | public interface QPluginMapper extends BaseMapper<QPlugin> { 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 | * <p> 25 | * Mapper 接口 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-08 30 | */ 31 | @Mapper 32 | @Repository 33 | public interface QRouteRuleMapper extends BaseMapper<QRouteRule> { 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 | * <p> 27 | * Mapper 接口 28 | * </p> 29 | * 30 | * @author conghuhu 31 | * @since 2022-04-08 32 | */ 33 | @Mapper 34 | @Repository 35 | public interface QServiceInstanceMapper extends BaseMapper<QServiceInstance> { 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 | * <p> 27 | * Mapper 接口 28 | * </p> 29 | * 30 | * @author conghuhu 31 | * @since 2022-04-08 32 | */ 33 | @Mapper 34 | @Repository 35 | public interface QServiceMapper extends BaseMapper<QService> { 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 | * <p> 25 | * Mapper 接口 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-24 30 | */ 31 | @Repository 32 | @Mapper 33 | public interface QUserMapper extends BaseMapper<QUser> { 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 | * <p> 27 | * Mapper 接口 28 | * </p> 29 | * 30 | * @author conghuhu 31 | * @since 2022-04-08 32 | */ 33 | @Mapper 34 | @Repository 35 | public interface QWebsocketInfoMapper extends BaseMapper<QWebsocketInfo> { 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<QWebsocketInfo> 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<QpsDTO> qpsDTOList; 36 | 37 | private List<CpuInfoDTO> cpuInfoList; 38 | 39 | private List<MemInfoDTO> memInfoList; 40 | 41 | private List<JvmInfoDTO> jvmInfoList; 42 | 43 | private List<ThreadInfoDTO> 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<T> { 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<QServiceInstance> 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 | * <p> 25 | * 服务类 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-15 30 | */ 31 | public interface QLimitRuleService extends IService<QLimitRule> { 32 | 33 | /** 34 | * 查询所有限制规则 35 | * @return 36 | */ 37 | List<QLimitRule> 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 | * <p> 27 | * 服务类 28 | * </p> 29 | * 30 | * @author conghuhu 31 | * @since 2022-04-18 32 | */ 33 | public interface QLogService extends IService<QLog> { 34 | 35 | /** 36 | * 查询所有日志 37 | * @return 38 | */ 39 | PageResult<List<QLog>> 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 | * <p> 23 | * 服务类 24 | * </p> 25 | * 26 | * @author conghuhu 27 | * @since 2022-04-08 28 | */ 29 | public interface QNacosInfoService extends IService<QNacosInfo> { 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 | * <p> 25 | * 服务类 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-08 30 | */ 31 | public interface QPluginService extends IService<QPlugin> { 32 | 33 | /** 34 | * 查询所有插件 35 | * @return 36 | */ 37 | List<QPlugin> 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 | * <p> 27 | * 服务类 28 | * </p> 29 | * 30 | * @author conghuhu 31 | * @since 2022-04-08 32 | */ 33 | public interface QRouteRuleService extends IService<QRouteRule> { 34 | 35 | /** 36 | * 获取路由规则列表 37 | * 38 | * @return 39 | */ 40 | List<RouteRuleVo> 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 | * <p> 25 | * 服务类 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-08 30 | */ 31 | public interface QServiceInstanceService extends IService<QServiceInstance> { 32 | 33 | /** 34 | * 查询某个服务下的所有实例 35 | * 36 | * @param id 37 | * @return 38 | */ 39 | List<QServiceInstance> 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 | * <p> 26 | * 服务类 27 | * </p> 28 | * 29 | * @author conghuhu 30 | * @since 2022-04-08 31 | */ 32 | public interface QServiceService extends IService<QService> { 33 | 34 | /** 35 | * 获取服务及其实例信息 36 | * 37 | * @return 38 | */ 39 | List<ServiceInfoVo> 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 | * <p> 24 | * 服务类 25 | * </p> 26 | * 27 | * @author conghuhu 28 | * @since 2022-04-24 29 | */ 30 | public interface QUserService extends IService<QUser> { 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 | * <p> 25 | * 服务类 26 | * </p> 27 | * 28 | * @author conghuhu 29 | * @since 2022-04-08 30 | */ 31 | public interface QWebsocketInfoService extends IService<QWebsocketInfo> { 32 | 33 | /** 34 | * 插入websocket信息 35 | * @param websocketInfo 36 | */ 37 | void insert(QWebsocketInfo websocketInfo); 38 | 39 | /** 40 | * 查询所有websocket信息 41 | * @return 42 | */ 43 | List<QWebsocketInfo> getWebsocketInfo(); 44 | 45 | /** 46 | * 清空表 47 | */ 48 | void clean(); 49 | 50 | Boolean changeWebsocketStatus(String clientId, Boolean status); 51 | 52 | List<QWebsocketInfo> 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 | * <p> 28 | * 服务实现类 29 | * </p> 30 | * 31 | * @author conghuhu 32 | * @since 2022-04-08 33 | */ 34 | @Service 35 | public class QNacosInfoServiceImpl extends ServiceImpl<QNacosInfoMapper, QNacosInfo> 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 | * <p> 30 | * 服务实现类 31 | * </p> 32 | * 33 | * @author conghuhu 34 | * @since 2022-04-08 35 | */ 36 | @Service 37 | public class QPluginServiceImpl extends ServiceImpl<QPluginMapper, QPlugin> 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<QPlugin> getPluginList() { 52 | List<QPlugin> 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 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QLimitRuleMapper"> 4 | 5 | </mapper> 6 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QLogMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QLogMapper"> 4 | 5 | </mapper> 6 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QNacosInfoMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QNacosInfoMapper"> 4 | 5 | <insert id="insertByReplace" parameterType="object"> 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 | </insert> 16 | </mapper> 17 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QPluginMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QPluginMapper"> 4 | 5 | </mapper> 6 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QRouteRuleMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QRouteRuleMapper"> 4 | 5 | </mapper> 6 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QServiceInstanceMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QServiceInstanceMapper"> 4 | 5 | <insert id="insertByReplace" parameterType="object"> 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 | </insert> 21 | </mapper> 22 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QServiceMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QServiceMapper"> 4 | 5 | <insert id="insertByReplace" parameterType="object"> 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 | </insert> 16 | </mapper> 17 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QUserMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QUserMapper"> 4 | 5 | </mapper> 6 | -------------------------------------------------------------------------------- /qing-gateway/qing-admin/src/main/resources/mapper/QWebsocketInfoMapper.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 | <mapper namespace="cn.qing.admin.mapper.QWebsocketInfoMapper"> 4 | 5 | <insert id="insertByReplace" parameterType="object"> 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 | </insert> 15 | </mapper> 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<String> PROTOCOL_SET = new HashSet<String>(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<ThreadInfoItemDTO> threadInfoItemDTOList; 31 | 32 | private Long collectTime; 33 | 34 | public ThreadInfoDTO(List<ThreadInfoItemDTO> 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<String, List<ServiceInstance>> serviceMap; 52 | 53 | /** 54 | * 路由规则map 55 | */ 56 | private Map<String, ServiceRuleDTO> routeRuleMap; 57 | 58 | /** 59 | * 在线的服务 60 | */ 61 | private List<String> onlineServices; 62 | 63 | /** 64 | * 负载均衡策略 65 | */ 66 | private List<String> loadBalanceList; 67 | 68 | /** 69 | * 限流策略map 70 | */ 71 | private Map<String, LimitRuleDTO> limitRuleMap; 72 | 73 | /** 74 | * 日志记录 75 | */ 76 | private List<LogDTO> 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 <conghuhu_blog> 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 <conghuhu_blog> 3 | ADD ./example2.jar /example2.jar 4 | CMD java -jar /example2.jar 5 | -------------------------------------------------------------------------------- /qing-gateway/qing-examples/client-exqmple-medical/pom.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 | <modelVersion>4.0.0</modelVersion> 6 | 7 | <parent> 8 | <artifactId>qing-examples</artifactId> 9 | <groupId>cn.qing.gateway</groupId> 10 | <version>1.0-SNAPSHOT</version> 11 | </parent> 12 | 13 | <name>qing-client-exqmple-medical</name> 14 | <description>qing-client-exqmple=medical</description> 15 | 16 | <groupId>org.example</groupId> 17 | <artifactId>client-exqmple-medical</artifactId> 18 | <version>1.0-SNAPSHOT</version> 19 | 20 | <properties> 21 | <maven.compiler.source>1.8</maven.compiler.source> 22 | <maven.compiler.target>1.8</maven.compiler.target> 23 | <java.version>1.8</java.version> 24 | </properties> 25 | 26 | <dependencies> 27 | <dependency> 28 | <groupId>org.springframework.boot</groupId> 29 | <artifactId>spring-boot-starter-web</artifactId> 30 | </dependency> 31 | <dependency> 32 | <groupId>com.alibaba.cloud</groupId> 33 | <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> 34 | </dependency> 35 | </dependencies> 36 | 37 | <build> 38 | <finalName>medical-example</finalName> 39 | <plugins> 40 | <plugin> 41 | <groupId>org.springframework.boot</groupId> 42 | <artifactId>spring-boot-maven-plugin</artifactId> 43 | <version>2.3.12.RELEASE</version> 44 | </plugin> 45 | </plugins> 46 | </build> 47 | 48 | </project> -------------------------------------------------------------------------------- /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 <conghuhu_blog> 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<String, List<String>> pluginMap = new ConcurrentHashMap<>(); 37 | 38 | /** 39 | * 定义一个向pluginMap中添加数据的方法 40 | */ 41 | public static void addPlugin(String serviceName, List<String> plugins) { 42 | pluginMap.put(serviceName, plugins); 43 | } 44 | 45 | /** 46 | * 定义一个移除pluginMap中失效数据的方法 47 | */ 48 | public static void removePlugin(List<String> serviceNames) { 49 | List<String> 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<Void> 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<AdminInfo> 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<Map<String, String>> routes; 36 | } 37 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/config/properties/ServerConfigProperties.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 cn.qing.common.constants.LoadBalanceConstants; 19 | import lombok.Data; 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | /** 24 | * @author conghuhu 25 | * @create 2022-04-03 21:36 26 | */ 27 | @Data 28 | @ConfigurationProperties(prefix = "qing.server") 29 | @Configuration 30 | public class ServerConfigProperties { 31 | /** 32 | * 负载均衡算法,默认轮询 33 | */ 34 | private String loadBalance = LoadBalanceConstants.LOAD_BALANCE_ROUND_ROBIN; 35 | /** 36 | * 网关超时时间,默认5s 37 | */ 38 | private Long timeOutMillis = 5000L; 39 | /** 40 | * 缓存刷新间隔,默认10s 41 | */ 42 | private Long cacheRefreshIntervalMillis = 10000L; 43 | } 44 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/filter/PluginFilter.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.filter; 17 | 18 | import cn.qing.server.cache.QpsCache; 19 | import cn.qing.server.handler.QingWebHandler; 20 | import lombok.extern.slf4j.Slf4j; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.core.annotation.Order; 23 | import org.springframework.lang.NonNull; 24 | import org.springframework.web.server.ServerWebExchange; 25 | import org.springframework.web.server.WebFilter; 26 | import org.springframework.web.server.WebFilterChain; 27 | import reactor.core.publisher.Mono; 28 | 29 | /** 30 | * 插件过滤器 31 | * 32 | * @author conghuhu 33 | * @create 2022-04-03 15:41 34 | */ 35 | @Slf4j 36 | public class PluginFilter implements WebFilter { 37 | @Autowired 38 | private QingWebHandler qingWebHandler; 39 | 40 | @NonNull 41 | @Override 42 | public Mono<Void> filter(@NonNull ServerWebExchange exchange, @NonNull WebFilterChain chain) { 43 | final String urlPath = exchange.getRequest().getURI().getPath(); 44 | if (urlPath.contains("/actuator/prometheus")) { 45 | return chain.filter(exchange); 46 | } 47 | log.info("插件过滤器开始执行"); 48 | QpsCache.qps.getAndIncrement(); 49 | return qingWebHandler.handle(exchange); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/plugin/base/AbstractQingPlugin.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.plugin.base; 17 | 18 | import cn.qing.server.chain.QingPluginChain; 19 | import lombok.extern.slf4j.Slf4j; 20 | import org.springframework.web.server.ServerWebExchange; 21 | import reactor.core.publisher.Mono; 22 | 23 | /** 24 | * @author conghuhu 25 | * @create 2022-04-04 13:56 26 | */ 27 | @Slf4j 28 | public abstract class AbstractQingPlugin implements QingPlugin { 29 | 30 | @Override 31 | public Mono<Void> execute(ServerWebExchange exchange, QingPluginChain chain) { 32 | log.info("{} plugin execute", getName()); 33 | return doExecute(exchange, chain); 34 | } 35 | 36 | protected abstract Mono<Void> doExecute(ServerWebExchange exchange, QingPluginChain chain); 37 | } 38 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/plugin/base/QingPlugin.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.plugin.base; 17 | 18 | import cn.qing.server.chain.QingPluginChain; 19 | import org.springframework.web.server.ServerWebExchange; 20 | import reactor.core.publisher.Mono; 21 | 22 | /** 23 | * @author conghuhu 24 | * @create 2022-04-04 13:36 25 | */ 26 | public interface QingPlugin { 27 | 28 | /** 29 | * 插件执行 30 | * 31 | * @param exchange 32 | * @param chain 33 | * @return 34 | */ 35 | Mono<Void> execute(ServerWebExchange exchange, QingPluginChain chain); 36 | 37 | /** 38 | * 插件名称 39 | * 40 | * @return 41 | */ 42 | default String getName() { 43 | return ""; 44 | } 45 | 46 | /** 47 | * 插件顺序 48 | * 49 | * @return 50 | */ 51 | int getOrder(); 52 | 53 | /** 54 | * 是否跳过插件 55 | * 56 | * @param exchange 57 | * @return 58 | */ 59 | default boolean skip(ServerWebExchange exchange) { 60 | return false; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/plugin/impl/GlobalPlugin.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.plugin.impl; 17 | 18 | import cn.qing.common.constants.CommonConstant; 19 | import cn.qing.common.enums.QingPluginEnum; 20 | import cn.qing.server.chain.QingPluginChain; 21 | import cn.qing.server.plugin.base.AbstractQingPlugin; 22 | import cn.qing.server.plugin.base.QingContext; 23 | import lombok.extern.slf4j.Slf4j; 24 | import org.springframework.web.server.ServerWebExchange; 25 | import reactor.core.publisher.Mono; 26 | 27 | /** 28 | * @author conghuhu 29 | * @create 2022/12/29 23:28 30 | */ 31 | @Slf4j 32 | public class GlobalPlugin extends AbstractQingPlugin { 33 | @Override 34 | public Mono<Void> doExecute(ServerWebExchange exchange, QingPluginChain chain) { 35 | QingContext context = QingContext.build(exchange.getRequest()); 36 | exchange.getAttributes().put(CommonConstant.CONTEXT, context); 37 | return chain.doChain(exchange); 38 | } 39 | 40 | @Override 41 | public String getName() { 42 | return QingPluginEnum.GLOBAL.getName(); 43 | } 44 | 45 | @Override 46 | public int getOrder() { 47 | return QingPluginEnum.GLOBAL.getOrder(); 48 | } 49 | 50 | @Override 51 | public boolean skip(ServerWebExchange exchange) { 52 | return super.skip(exchange); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/spi/LoadBalance.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.spi; 17 | 18 | import cn.qing.common.dto.ServiceInstance; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * @author conghuhu 24 | * @create 2022-04-06 20:20 25 | */ 26 | public interface LoadBalance { 27 | /** 28 | * Select an instance based on the load balancing algorithm 29 | * @param instances 30 | * @return 31 | */ 32 | ServiceInstance chooseOne(List<ServiceInstance> instances); 33 | } 34 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/spi/balance/RandomBalance.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.spi.balance; 17 | 18 | import cn.qing.common.constants.LoadBalanceConstants; 19 | import cn.qing.common.dto.ServiceInstance; 20 | import cn.qing.server.annotation.LoadBalanceType; 21 | import cn.qing.server.spi.LoadBalance; 22 | 23 | import java.util.List; 24 | import java.util.Random; 25 | 26 | /** 27 | * 随机算法 28 | * 29 | * @author conghuhu 30 | */ 31 | @LoadBalanceType(LoadBalanceConstants.RANDOM) 32 | public class RandomBalance implements LoadBalance { 33 | 34 | private static Random random = new Random(); 35 | 36 | @Override 37 | public ServiceInstance chooseOne(List<ServiceInstance> instances) { 38 | return instances.get(random.nextInt(instances.size())); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/spi/balance/RoundRobinBalance.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.spi.balance; 17 | 18 | import cn.qing.common.constants.LoadBalanceConstants; 19 | import cn.qing.common.dto.ServiceInstance; 20 | import cn.qing.server.annotation.LoadBalanceType; 21 | import cn.qing.server.spi.LoadBalance; 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * 轮询算法 27 | * 28 | * @author conghuhu 29 | */ 30 | @LoadBalanceType(LoadBalanceConstants.LOAD_BALANCE_ROUND_ROBIN) 31 | public class RoundRobinBalance implements LoadBalance { 32 | 33 | private volatile int index; 34 | 35 | @Override 36 | public synchronized ServiceInstance chooseOne(List<ServiceInstance> instances) { 37 | if (index == instances.size()) { 38 | index = 0; 39 | } 40 | return instances.get(index++); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/spi/balance/WeightRoundBalance.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.spi.balance; 17 | 18 | import cn.qing.common.constants.LoadBalanceConstants; 19 | import cn.qing.common.dto.ServiceInstance; 20 | import cn.qing.server.annotation.LoadBalanceType; 21 | import cn.qing.server.spi.LoadBalance; 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * @author conghuu 27 | * @create Created in 2020/12/30 28 | */ 29 | @LoadBalanceType(LoadBalanceConstants.WEIGHT_ROUND) 30 | public class WeightRoundBalance implements LoadBalance { 31 | 32 | private volatile int index; 33 | 34 | @Override 35 | public synchronized ServiceInstance chooseOne(List<ServiceInstance> instances) { 36 | int allWeight = instances.stream().mapToInt(ServiceInstance::getWeight).sum(); 37 | int number = (index++) % allWeight; 38 | for (ServiceInstance instance : instances) { 39 | if (instance.getWeight() > number) { 40 | return instance; 41 | } 42 | number -= instance.getWeight(); 43 | } 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/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.server.spring; 17 | 18 | import cn.qing.server.utils.SpringContextUtil; 19 | import org.springframework.beans.BeansException; 20 | import org.springframework.context.ApplicationContext; 21 | import org.springframework.context.ApplicationContextAware; 22 | import org.springframework.stereotype.Component; 23 | 24 | /** 25 | * @author conghuhu 26 | * @create 2022/12/26 20:08 27 | */ 28 | @Component 29 | public class QingApplicationContextAware implements ApplicationContextAware { 30 | @Override 31 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 32 | SpringContextUtil.getInstance().setApplicationContext(applicationContext); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/java/cn/qing/server/utils/MDCUtil.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.utils; 17 | 18 | import org.slf4j.MDC; 19 | 20 | import java.util.UUID; 21 | 22 | /** 23 | * @author conghuhu 24 | * @create 2023/1/6 16:08 25 | */ 26 | public class MDCUtil { 27 | public static final String TRACE_ID = "trace_id"; 28 | public static final String SPAN_ID = "span_id"; 29 | 30 | public static String getTraceId() { 31 | String traceId = (String) MDC.get(TRACE_ID); 32 | return traceId == null ? "" : traceId; 33 | } 34 | 35 | public static void setTraceId(String traceId, String spanId) { 36 | MDC.put(TRACE_ID, traceId); 37 | MDC.put(SPAN_ID, spanId); 38 | } 39 | 40 | public static void remove() { 41 | MDC.remove(TRACE_ID); 42 | MDC.remove(SPAN_ID); 43 | } 44 | 45 | public static void clear() { 46 | MDC.clear(); 47 | } 48 | 49 | public static String generateTraceId() { 50 | return UUID.randomUUID().toString().replace("-", ""); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": [ 3 | { 4 | "name": "web.client.max-idle-time", 5 | "type": "java.lang.String", 6 | "description": "Description for web.client.max-idle-time." 7 | } 8 | ] } -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/resources/META-INF/services/cn.qing.server.spi.LoadBalance: -------------------------------------------------------------------------------- 1 | cn.qing.server.spi.balance.RandomBalance 2 | cn.qing.server.spi.balance.RoundRobinBalance 3 | cn.qing.server.spi.balance.WeightRoundBalance -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: qing-gateway 4 | profiles: 5 | active: dev -------------------------------------------------------------------------------- /qing-gateway/qing-server/src/main/resources/lua/limiter.lua: -------------------------------------------------------------------------------- 1 | --KEYS[1]: 限流 key 2 | --ARGV[1]: 时间戳 - 时间窗口 3 | --ARGV[2]: 当前时间戳(作为score) 4 | --ARGV[3]: 阈值 5 | --ARGV[4]: score 对应的唯一value 6 | -- 1. 移除时间窗口之前的数据 7 | redis.call('ZREMRANGEBYSCORE', KEYS[1], 0, tonumber(ARGV[1])) 8 | -- 2. 统计当前元素数量 9 | local res = redis.call('ZCARD', KEYS[1]) 10 | -- 3. 是否超过阈值 11 | if (res == nil) or (res < tonumber(ARGV[3])) then 12 | redis.call('ZADD', KEYS[1], ARGV[2], ARGV[4]) 13 | return 1 14 | else 15 | return 0 16 | end -------------------------------------------------------------------------------- /qing-gateway/scripts/checkstyle-header.txt: -------------------------------------------------------------------------------- 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 | */ --------------------------------------------------------------------------------