Skip to content

Commit 170b772

Browse files
committed
Merge branch 'feat_1.10_release_4.0.x_restfulapi' into beat_1.10_4.0_restful
2 parents 301b3b4 + 0e383d0 commit 170b772

30 files changed

+1771
-59
lines changed

flinkx-restapi/flinkx-restapi-core/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@
1616
<artifactId>httpclient</artifactId>
1717
<version>${http.version}</version>
1818
</dependency>
19+
20+
<dependency>
21+
<groupId>com.github.pfmiles</groupId>
22+
<artifactId>dropincc.java</artifactId>
23+
<version>0.2.2</version>
24+
</dependency>
1925
</dependencies>
2026
</project>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.dtstack.flinkx.restapi.common;
19+
20+
import org.apache.commons.lang3.StringUtils;
21+
22+
import java.sql.Date;
23+
import java.time.LocalDateTime;
24+
import java.time.ZoneId;
25+
import java.time.format.DateTimeFormatter;
26+
import java.util.Objects;
27+
28+
/**
29+
* ConstantParan
30+
*
31+
* @author by [email protected]
32+
* @Date 2020/9/26
33+
*/
34+
public class ConstantParam<T> implements ParamDefinition {
35+
36+
private final String name;
37+
38+
private final ParamType paramType;
39+
40+
private final Class<T> valueClass;
41+
42+
protected Object value;
43+
44+
private final String description;
45+
46+
private String formatDescription;
47+
48+
private final DateTimeFormatter format;
49+
50+
public ConstantParam(String name, ParamType paramType, Class valueClass, Object value, String description, String format) {
51+
this.name = name;
52+
this.paramType = paramType;
53+
this.valueClass = valueClass;
54+
this.description = description;
55+
this.value = value;
56+
this.formatDescription = format;
57+
if (StringUtils.isNotBlank(format)) {
58+
this.format = DateTimeFormatter.ofPattern(format);
59+
} else {
60+
this.format = null;
61+
}
62+
63+
}
64+
65+
@Override
66+
public String getName() {
67+
return name;
68+
}
69+
70+
@Override
71+
public ParamType getType() {
72+
return paramType;
73+
}
74+
75+
@Override
76+
public Object getValue() {
77+
return value;
78+
}
79+
80+
@Override
81+
public String getValueType() {
82+
return "valueClass";
83+
}
84+
85+
86+
@Override
87+
public String getDescription() {
88+
return description;
89+
}
90+
91+
@Override
92+
public String getFormat() {
93+
return formatDescription;
94+
}
95+
96+
@Override
97+
public Object format(Object data) {
98+
if (Objects.isNull(format) || Objects.isNull(data)) {
99+
return data;
100+
}
101+
if (getValueType().equals(Date.class)) {
102+
Date value1 = (Date) data;
103+
LocalDateTime ldt = value1.toInstant()
104+
.atZone(ZoneId.systemDefault())
105+
.toLocalDateTime();
106+
return format.format(ldt);
107+
}
108+
return null;
109+
}
110+
111+
112+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.dtstack.flinkx.restapi.common;
2+
3+
public class ConstantVarible<T> implements Paramitem {
4+
private final T object;
5+
private final String name;
6+
// private ParamDefinition paramDefinition;
7+
8+
public ConstantVarible(T object, String name) {
9+
this.object = object;
10+
this.name = name;
11+
// this.paramDefinition = paramDefinition;
12+
}
13+
14+
@Override
15+
public T getValue(RestContext restContext) {
16+
return object;
17+
}
18+
19+
@Override
20+
public String getName() {
21+
return name;
22+
}
23+
24+
// @Override
25+
// public ParamDefinition getParamDefinition() {
26+
// return paramDefinition;
27+
// }
28+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.dtstack.flinkx.restapi.common;
19+
20+
import java.util.Date;
21+
22+
/**
23+
* CurrentTimeVarible
24+
*
25+
* @author by [email protected]
26+
* @Date 2020/9/28
27+
*/
28+
public class CurrentTimeVarible implements Paramitem<Date> {
29+
30+
public CurrentTimeVarible() {
31+
32+
}
33+
34+
@Override
35+
public Date getValue(RestContext restContext) {
36+
return new Date();
37+
}
38+
39+
@Override
40+
public String getName() {
41+
return "currenttime";
42+
}
43+
}

0 commit comments

Comments
 (0)