init
This commit is contained in:
278
fizz-bootstrap/pom.xml
Normal file
278
fizz-bootstrap/pom.xml
Normal file
@@ -0,0 +1,278 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>fizz-gateway-community</artifactId>
|
||||
<groupId>we</groupId>
|
||||
<version>1.5.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>fizz-bootstrap</artifactId>
|
||||
|
||||
<properties>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.networknt</groupId>
|
||||
<artifactId>json-schema-validator-i18n-support</artifactId>
|
||||
<version>1.0.39_4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/json-schema-validator-i18n-support-1.0.39_4.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>we</groupId>
|
||||
<artifactId>fizz-core</artifactId>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>we</groupId>
|
||||
<artifactId>fizz-plugin</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-bom</artifactId>
|
||||
<version>Dragonfruit-RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.skyscreamer</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.minidev</groupId>
|
||||
<artifactId>json-smart</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tapestry</groupId>
|
||||
<artifactId>tapestry-json</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ctrip.framework.apollo</groupId>
|
||||
<artifactId>apollo-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-discovery-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>it.ozimov</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>snack3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- grpc -->
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-all</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<!-- grpc -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-framework</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-recipes</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
<artifactId>zookeeper</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2020 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package we;
|
||||
|
||||
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration;
|
||||
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import we.config.AggregateRedisConfig;
|
||||
import we.log.LogSendAppender;
|
||||
|
||||
/**
|
||||
* fizz gateway application boot entrance
|
||||
*
|
||||
* @author linwaiwai
|
||||
* @author Francis Dong
|
||||
* @author hongqiaowei
|
||||
* @author zhongjie
|
||||
*/
|
||||
@SpringBootApplication(
|
||||
exclude = {ErrorWebFluxAutoConfiguration.class, RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class},
|
||||
scanBasePackages = {"we"}
|
||||
)
|
||||
@NacosPropertySource(dataId = "${nacos.config.data-id}", groupId = "${nacos.config.group}", autoRefreshed = true)
|
||||
@EnableDiscoveryClient
|
||||
public class FizzBootstrapApplication {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FizzBootstrapApplication.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication springApplication = new SpringApplication(FizzBootstrapApplication.class);
|
||||
springApplication.setApplicationContextClass(CustomReactiveWebServerApplicationContext.class);
|
||||
FizzAppContext.appContext = springApplication.run(args);
|
||||
}
|
||||
|
||||
private static class CustomReactiveWebServerApplicationContext extends AnnotationConfigReactiveWebServerApplicationContext {
|
||||
@Override
|
||||
protected void onClose() {
|
||||
super.onClose();
|
||||
if (AggregateRedisConfig.proxyLettuceConnectionFactory != null) {
|
||||
LOGGER.info("FizzGatewayApplication stopped.");
|
||||
// set LogSendAppender.logEnabled to false to stop send log to fizz-manager
|
||||
LogSendAppender.logEnabled = Boolean.FALSE;
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
// the ProxyLettuceConnectionFactory remove DisposableBean interface, so invoke destroy method here
|
||||
AggregateRedisConfig.proxyLettuceConnectionFactory.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
app.id=fizz-gateway
|
||||
5
fizz-bootstrap/src/main/resources/apollo-env.properties
Normal file
5
fizz-bootstrap/src/main/resources/apollo-env.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
#local.meta=http://localhost:8080
|
||||
#dev.meta=http://localhost:8080
|
||||
#fat.meta=http://localhost:8080
|
||||
#uat.meta=http://localhost:8080
|
||||
#pro.meta=http://localhost:8080
|
||||
103
fizz-bootstrap/src/main/resources/application.yml
Normal file
103
fizz-bootstrap/src/main/resources/application.yml
Normal file
@@ -0,0 +1,103 @@
|
||||
# if you do not use Apollo, ignore the follow config
|
||||
################################################## Apollo config start ##################################################
|
||||
apollo:
|
||||
# if use Apollo set this flag to true
|
||||
enabled: false #use Apollo? (default:false)
|
||||
bootstrap:
|
||||
# if use Apollo set this flag to true
|
||||
enabled: false #use Apollo?
|
||||
namespaces: application #please input the apollo bootstrap namespaces (default:application)
|
||||
eagerLoad:
|
||||
# if use Apollo set this flag to true
|
||||
enabled: false #use Apollo?
|
||||
################################################### Apollo config end ###################################################
|
||||
|
||||
# if you do not use Nacos, ignore the follow config
|
||||
################################################## Nacos config start ###################################################
|
||||
nacos:
|
||||
config:
|
||||
# if use Nacos config set this flag to true
|
||||
enabled: false #use Nacos Config? (default:false)
|
||||
# need replace
|
||||
server-addr: localhost:8848 #please input the nacos config server-addr (default:localhost:8848)
|
||||
auto-refresh: true
|
||||
group: fizz-gateway #please input the nacos config group (default:fizz-gateway)
|
||||
data-id: application #please input the nacos config data-id (default:application)
|
||||
type: PROPERTIES #please input the nacos config type (default:PROPERTIES)
|
||||
# need replace
|
||||
namespace: null #please input the nacos config type (default:null)
|
||||
discovery:
|
||||
# if use Nacos discovery set this flag to true
|
||||
enabled: false #use Nacos Discovery? (default:false)
|
||||
# need replace
|
||||
server-addr: localhost:8848 #please input the nacos discovery server-addr (default:localhost:8848)
|
||||
auto-register: true
|
||||
register:
|
||||
group-name: fizz-gateway #please input the nacos discovery register group-name (default:fizz-gateway)
|
||||
################################################### Nacos config end ####################################################
|
||||
|
||||
# if you do not use Eureka, ignore the follow config
|
||||
################################################## Eureka config start ##################################################
|
||||
eureka:
|
||||
client:
|
||||
# if use Eureka set this flag to true
|
||||
enabled: false #use Eureka? (default:false)
|
||||
serviceUrl:
|
||||
# need replace
|
||||
defaultZone: http://localhost:6600/eureka/ #please input the eureka client serviceUrl defaultZone (default:http://localhost:6600/eureka/)
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
################################################### Eureka config end ###################################################
|
||||
|
||||
server:
|
||||
port: 8600
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
application:
|
||||
name: fizz-gateway
|
||||
cloud:
|
||||
loadbalancer:
|
||||
ribbon:
|
||||
enabled: false
|
||||
|
||||
aggregate:
|
||||
redis:
|
||||
# need replace
|
||||
host: 128.1.1.1 #please input the redis host (default:localhost)
|
||||
# need replace
|
||||
port: 6379 #please input the redis port (default:6379)
|
||||
# need replace
|
||||
password: 123456 #please input the redis password (default:123456)
|
||||
# need replace
|
||||
database: 10 #please input the redis database (default:9)
|
||||
proxy-webclient:
|
||||
name: proxy
|
||||
aggr-webclient:
|
||||
name: aggr
|
||||
fizz-web-client:
|
||||
timeout: 20000
|
||||
fizz-dubbo-client:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
log:
|
||||
headers: COOKIE,FIZZ-APPID,FIZZ-SIGN,FIZZ-TS,FIZZ-RSV,HOST
|
||||
|
||||
stat:
|
||||
# switch for push access stat data
|
||||
open: true
|
||||
send-log:
|
||||
# switch for push log data
|
||||
open: true
|
||||
sched:
|
||||
executors: 2
|
||||
flowControl: true
|
||||
flow-stat-sched:
|
||||
cron: 2/10 * * * * ?
|
||||
dest: redis
|
||||
queue: fizz_resource_access_stat
|
||||
|
||||
gateway:
|
||||
prefix: /proxy
|
||||
aggr:
|
||||
# set headers when calling the backend API
|
||||
proxy_set_headers: host,X-Real-IP,X-Forwarded-Proto,X-Forwarded-For
|
||||
243
fizz-bootstrap/src/main/resources/js/common.js
Normal file
243
fizz-bootstrap/src/main/resources/js/common.js
Normal file
@@ -0,0 +1,243 @@
|
||||
/**
|
||||
* context 上下文便捷操作函数
|
||||
*
|
||||
*/
|
||||
var common = {
|
||||
/* *********** private function begin *********** */
|
||||
|
||||
/**
|
||||
* 获取上下文中客户端请求对象
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
*/
|
||||
getInputReq: function (ctx){
|
||||
if(!ctx || !ctx['input'] || !ctx['input']['request']){
|
||||
return {};
|
||||
}
|
||||
return ctx['input']['request']
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取上下文步骤中请求接口的请求对象
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名称 【必填】
|
||||
* @param {*} requestName 请求名称 【必填】
|
||||
*/
|
||||
getStepReq: function (ctx, stepName, requestName){
|
||||
if(!ctx || !stepName || !requestName){
|
||||
return {};
|
||||
}
|
||||
if(!ctx[stepName] || !ctx[stepName]['requests'] || !ctx[stepName]['requests'][requestName] ||
|
||||
!ctx[stepName]['requests'][requestName]['request']){
|
||||
return {};
|
||||
}
|
||||
return ctx[stepName]['requests'][requestName]['request'];
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取上下文步骤中请求接口的响应对象
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名称 【必填】
|
||||
* @param {*} requestName 请求名称 【必填】
|
||||
*/
|
||||
getStepResp: function (ctx, stepName, requestName){
|
||||
if(!ctx || !stepName || !requestName){
|
||||
return {};
|
||||
}
|
||||
if(!ctx[stepName] || !ctx[stepName]['requests'] || !ctx[stepName]['requests'][requestName] ||
|
||||
!ctx[stepName]['requests'][requestName]['response']){
|
||||
return {};
|
||||
}
|
||||
return ctx[stepName]['requests'][requestName]['response'];
|
||||
},
|
||||
|
||||
/* *********** private function end *********** */
|
||||
|
||||
/* *********** input begin ************ */
|
||||
|
||||
/**
|
||||
* 获取客户端请求头
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} headerName 请求头字段名 【选填】,不传时返回所有请求头
|
||||
*/
|
||||
getInputReqHeader: function (ctx, headerName){
|
||||
var req = this.getInputReq(ctx);
|
||||
var headers = req['headers'] || {};
|
||||
return headerName ? headers[headerName.toUpperCase()] : headers;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取客户端URL请求参数(query string)
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} paramName URL参数名 【选填】,不传时返回所有请求参数
|
||||
*/
|
||||
getInputReqParam: function (ctx, paramName){
|
||||
var req = this.getInputReq(ctx);
|
||||
var params = req['params'] || {};
|
||||
return paramName ? params[paramName] : params;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取客户端请求体
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} field 字段名 【选填】,不传时返回整个请求体
|
||||
*/
|
||||
getInputReqBody: function (ctx, field){
|
||||
var req = this.getInputReq(ctx);
|
||||
var body = req['body'] || {};
|
||||
return field ? body[field] : body;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取返回给客户端的响应头
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} headerName 响应头字段名 【选填】,不传时返回所有响应头
|
||||
*/
|
||||
getInputRespHeader: function (ctx, headerName){
|
||||
var req = this.getInputReq(ctx);
|
||||
var headers = req['headers'] || {};
|
||||
return headerName ? headers[headerName.toUpperCase()] : headers;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取返回给客户端的响应体
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} field 字段名 【选填】,不传时返回整个响应体
|
||||
*/
|
||||
getInputRespBody: function (ctx, field){
|
||||
var req = this.getInputReq(ctx);
|
||||
var body = req['body'] || {};
|
||||
return field ? body[field] : body;
|
||||
},
|
||||
|
||||
/* *********** input begin ************ */
|
||||
|
||||
/* *********** step request begin ************ */
|
||||
|
||||
/**
|
||||
* 获取步骤中调用的接口的请求头
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名【必填】
|
||||
* @param {*} requestName 请求的接口名 【必填】
|
||||
* @param {*} headerName 请求头字段名 【选填】,不传时返回所有请求头
|
||||
*/
|
||||
getStepReqHeader: function (ctx, stepName, requestName, headerName){
|
||||
var req = this.getStepReq(ctx, stepName, requestName);
|
||||
var headers = req['headers'] || {};
|
||||
return headerName ? headers[headerName.toUpperCase()] : headers;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取步骤中调用的接口的URL参数
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名【必填】
|
||||
* @param {*} requestName 请求的接口名 【必填】
|
||||
* @param {*} paramName URL参数名 【选填】,不传时返回所有URL参数
|
||||
*/
|
||||
getStepReqParam: function (ctx, stepName, requestName, paramName){
|
||||
var req = this.getStepReq(ctx, stepName, requestName);
|
||||
var params = req['params'] || {};
|
||||
return paramName ? params[paramName] : params;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取步骤中调用的接口的请求体
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名【必填】
|
||||
* @param {*} requestName 请求的接口名 【必填】
|
||||
* @param {*} field 字段名 【选填】,不传时返回整个请求体
|
||||
*/
|
||||
getStepReqBody: function (ctx, stepName, requestName, field){
|
||||
var req = this.getStepReq(ctx, stepName, requestName);
|
||||
var body = req['body'] || {};
|
||||
return field ? body[field] : body;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取步骤中调用的接口的响应头
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名【必填】
|
||||
* @param {*} requestName 请求的接口名 【必填】
|
||||
* @param {*} headerName 响应头字段名 【选填】,不传时返回所有响应头
|
||||
*/
|
||||
getStepRespHeader: function (ctx, stepName, requestName, headerName){
|
||||
var resp = this.getStepResp(ctx, stepName, requestName);
|
||||
var headers = resp['headers'] || {};
|
||||
return headerName ? headers[headerName.toUpperCase()] : headers;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取步骤中调用的接口的响应头
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名【必填】
|
||||
* @param {*} requestName 请求的接口名 【必填】
|
||||
* @param {*} field 字段名 【选填】,不传时返回整个响应头
|
||||
*/
|
||||
getStepRespBody: function (ctx, stepName, requestName, field){
|
||||
var resp = this.getStepResp(ctx, stepName, requestName);
|
||||
var body = resp['body'] || {};
|
||||
return field ? body[field] : body;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取步骤结果
|
||||
* @param {*} ctx 上下文 【必填】
|
||||
* @param {*} stepName 步骤名【必填】
|
||||
* @param {*} field 字段名 【选填】,不传时返回整个步骤结果对象
|
||||
*/
|
||||
getStepResult: function (ctx, stepName, field){
|
||||
if(!ctx || !stepName || !ctx[stepName]){
|
||||
return {};
|
||||
}
|
||||
var result = ctx[stepName]['result'] || {};
|
||||
return field ? result[field] : result;
|
||||
}
|
||||
|
||||
/* *********** step request end ************ */
|
||||
|
||||
,/**
|
||||
** 乘法函数,用来得到精确的乘法结果
|
||||
** 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
|
||||
** 调用:accMul(arg1,arg2)
|
||||
** 返回值:arg1乘以 arg2的精确结果
|
||||
**/
|
||||
accMul:function (arg1, arg2) {
|
||||
var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
|
||||
try {
|
||||
m += s1.split(".")[1].length;
|
||||
} catch (e) {
|
||||
}
|
||||
try {
|
||||
m += s2.split(".")[1].length;
|
||||
} catch (e) {
|
||||
}
|
||||
return Number(s1.replace(".", "")) * Number(s2.replace(".", ""))
|
||||
/ Math.pow(10, m);
|
||||
},
|
||||
|
||||
/**
|
||||
** 除法函数,用来得到精确的除法结果
|
||||
** 说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
|
||||
** 调用:accDiv(arg1,arg2)
|
||||
** 返回值:arg1除以arg2的精确结果
|
||||
**/
|
||||
accDiv:function (arg1, arg2) {
|
||||
var t1 = 0, t2 = 0, r1, r2;
|
||||
try {
|
||||
t1 = arg1.toString().split(".")[1].length;
|
||||
} catch (e) {
|
||||
}
|
||||
try {
|
||||
t2 = arg2.toString().split(".")[1].length;
|
||||
} catch (e) {
|
||||
}
|
||||
with (Math) {
|
||||
r1 = Number(arg1.toString().replace(".", ""));
|
||||
r2 = Number(arg2.toString().replace(".", ""));
|
||||
return (r1 / r2) * pow(10, t2 - t1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
22
fizz-bootstrap/src/main/resources/log4j2-spring.xml
Normal file
22
fizz-bootstrap/src/main/resources/log4j2-spring.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<Configuration status="info" packages="we.log">
|
||||
<properties>
|
||||
<property name="APP_NAME">${sys:APP_NAME}</property>
|
||||
</properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %level %logger{36} - %X{traceId} %msg%n" />
|
||||
</Console>
|
||||
<LogSend name="LogSend">
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %level %logger{36} - %msg%n" />
|
||||
</LogSend>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console" />
|
||||
<AppenderRef ref="LogSend" />
|
||||
</Root>
|
||||
<Logger name="we" level="DEBUG"/>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
BIN
fizz-bootstrap/src/main/resources/static/favicon.ico
Normal file
BIN
fizz-bootstrap/src/main/resources/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 885 B |
5
fizz-bootstrap/src/test/resource/application.properties
Normal file
5
fizz-bootstrap/src/test/resource/application.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
# author: hongqiaowei
|
||||
|
||||
embeded.redis.host = localhost
|
||||
embeded.redis.port = 6379
|
||||
embeded.redis.database = 4
|
||||
18
fizz-bootstrap/src/test/resource/log4j2-test.xml
Normal file
18
fizz-bootstrap/src/test/resource/log4j2-test.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<Configuration status="info">
|
||||
<properties>
|
||||
<property name="APP_NAME">fizz-gateway</property>
|
||||
</properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %level %logger{36} - %X{traceId} %msg%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
<Logger name="we" level="DEBUG"/>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user