@rdmind/rdmind 0.1.8 → 0.1.9-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +287 -78
- package/locales/en.js +3 -1
- package/locales/zh.js +3 -0
- package/package.json +2 -2
- package/template/pom.xml +40 -0
- package/template/sns-demo-app/pom.xml +0 -5
- package/template/sns-demo-common/pom.xml +4 -5
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/constants/AppPlatform.java +57 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/enums/ErrorCodeEnum.java +30 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/exception/AppBizException.java +51 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/utils/AssertUtils.java +137 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/utils/JsonHelper.java +129 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/utils/WrappedContextHelper.java +182 -0
- package/template/sns-demo-domain/pom.xml +0 -5
- package/template/sns-demo-infrastructure/pom.xml +0 -5
- package/template/sns-demo-start/pom.xml +0 -5
- package/template/sns-demo-start/src/main/resources/logback-spring.xml +5 -8
- package/templates/idl-template/wiki/.idea/codeStyles/Project.xml +7 -0
- package/templates/idl-template/wiki/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/templates/idl-template/wiki/.idea/inspectionProfiles/Project_Default.xml +5 -0
- package/templates/idl-template/wiki/.idea/misc.xml +14 -0
- package/templates/idl-template/wiki/.idea/modules.xml +8 -0
- package/templates/idl-template/wiki/.idea/vcs.xml +6 -0
- package/templates/idl-template/wiki/.idea/wiki.iml +9 -0
- package/templates/idl-template/wiki/SDK-Dev-Guide.md +0 -2
- package/templates/idl-template/wiki/example/.gitlab-ci.yml +3 -17
- package/templates/idl-template/wiki/example/base.thrift +94 -0
- package/templates/idl-template/wiki/example/common.thrift +39 -0
- package/templates/idl-template/wiki/example/dto.thrift +3 -0
- package/templates/idl-template/wiki/example/enum.thrift +1 -0
- package/templates/idl-template/wiki/example/gen-java.sh +5 -2
- package/templates/idl-template/wiki/example/maven_project/pom.xml +57 -38
- package/templates/idl-template/wiki/example/req.thrift +4 -0
- package/templates/idl-template/wiki/example/res.thrift +5 -0
- package/templates/idl-template/wiki/example/sdk-spec.yml +4 -3
- package/templates/idl-template/wiki/example/service.thrift +15 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/enums/.gitkeep +0 -0
- package/template/sns-demo-start/src/main/java/com/xiaohongshu/sns/demo/start/provider/.gitkeep +0 -0
- package/templates/idl-template/wiki/.arcconfig +0 -3
- package/templates/idl-template/wiki/example/.arcconfig +0 -3
- package/templates/idl-template/wiki/example/hello.thrift +0 -29
- package/templates/idl-template/wiki/example/maven_project/src/main/java/com/xiaohongshu/sns/thrift/hello/HelloServiceAutoConfiguration.java +0 -46
- package/templates/idl-template/wiki/example/maven_project/src/main/java/com/xiaohongshu/sns/thrift/hello/HelloServiceProperties.java +0 -18
- package/templates/idl-template/wiki/example/maven_project/src/main/resources/META-INF/spring.factories +0 -3
- package/templates/idl-template/wiki/example/maven_project/src/test/java/com/xiaohongshu/sns/thrift/test/AutoConfigureTest.java +0 -53
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
package com.xiaohongshu.sns.demo.common.utils;
|
|
2
|
+
|
|
3
|
+
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
4
|
+
import com.xiaohongshu.infra.apm.utils.ContextHelper;
|
|
5
|
+
import com.xiaohongshu.infra.rpc.base.Context;
|
|
6
|
+
|
|
7
|
+
import com.xiaohongshu.sns.demo.common.constants.AppPlatform;
|
|
8
|
+
import lombok.Data;
|
|
9
|
+
import lombok.extern.slf4j.Slf4j;
|
|
10
|
+
import org.apache.commons.lang3.ObjectUtils;
|
|
11
|
+
import org.apache.commons.lang3.StringUtils;
|
|
12
|
+
import org.apache.commons.lang3.math.NumberUtils;
|
|
13
|
+
import org.springframework.stereotype.Component;
|
|
14
|
+
import org.springframework.util.CollectionUtils;
|
|
15
|
+
|
|
16
|
+
import java.net.URLDecoder;
|
|
17
|
+
import java.util.Collections;
|
|
18
|
+
import java.util.HashMap;
|
|
19
|
+
import java.util.Map;
|
|
20
|
+
import java.util.Optional;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 对中间件 ContextHelper 的封装,便于拿到当前的请求信息。
|
|
24
|
+
* 整合了 ContextUtils 现有功能及增强的上下文解析能力。
|
|
25
|
+
*
|
|
26
|
+
* @author RDMind
|
|
27
|
+
*/
|
|
28
|
+
@Component
|
|
29
|
+
@Slf4j
|
|
30
|
+
public class WrappedContextHelper {
|
|
31
|
+
|
|
32
|
+
public static final String APP_CONTEXT_PREFIX = "__app_context:";
|
|
33
|
+
public static final String HTTP_HEADER = "httpHeader";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 获取原始 Context
|
|
37
|
+
*/
|
|
38
|
+
public static Context get() {
|
|
39
|
+
return ContextHelper.getContext();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 获取当前用户 ID
|
|
44
|
+
*/
|
|
45
|
+
public static String getUserId() {
|
|
46
|
+
Context context = get();
|
|
47
|
+
if (context == null) {
|
|
48
|
+
return StringUtils.EMPTY;
|
|
49
|
+
}
|
|
50
|
+
String userId = context.getUserID();
|
|
51
|
+
if (StringUtils.isBlank(userId)) {
|
|
52
|
+
Map<String, String> baggageMap = context.getBaggage();
|
|
53
|
+
if (!CollectionUtils.isEmpty(baggageMap)) {
|
|
54
|
+
userId = baggageMap.get("viewerUserId");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return StringUtils.isBlank(userId) ? StringUtils.EMPTY : userId;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 获取当前操作者邮箱
|
|
62
|
+
*/
|
|
63
|
+
public static String getUserEmail() {
|
|
64
|
+
Context context = get();
|
|
65
|
+
return context == null ? StringUtils.EMPTY : context.getBaggage().getOrDefault("__app_context:operatorEmail", StringUtils.EMPTY);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 获取当前操作者展示名称
|
|
70
|
+
*/
|
|
71
|
+
public static String getUserDisplayName() {
|
|
72
|
+
Context context = get();
|
|
73
|
+
return context == null ? StringUtils.EMPTY : context.getBaggage().getOrDefault("__app_context:displayName", StringUtils.EMPTY);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 获取当前操作者真实姓名
|
|
78
|
+
*/
|
|
79
|
+
public static String getUserRealName() {
|
|
80
|
+
Context context = get();
|
|
81
|
+
return context == null ? StringUtils.EMPTY : context.getBaggage().getOrDefault("__app_context:operatorName", StringUtils.EMPTY);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 获取当前用户IP
|
|
86
|
+
*/
|
|
87
|
+
public static String getUserIp() {
|
|
88
|
+
Context context = get();
|
|
89
|
+
if (context == null) {
|
|
90
|
+
return StringUtils.EMPTY;
|
|
91
|
+
}
|
|
92
|
+
return StringUtils.isBlank(context.getUserIP()) ? StringUtils.EMPTY : context.getUserIP();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 获取 requestId
|
|
97
|
+
*/
|
|
98
|
+
public static String getRequestId() {
|
|
99
|
+
Context context = get();
|
|
100
|
+
if (context == null || CollectionUtils.isEmpty(context.getBaggage())) {
|
|
101
|
+
return StringUtils.EMPTY;
|
|
102
|
+
}
|
|
103
|
+
return context.getBaggage().getOrDefault(APP_CONTEXT_PREFIX + "requestId", StringUtils.EMPTY);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 获取当前客户端平台
|
|
108
|
+
*/
|
|
109
|
+
public static String getPlatform() {
|
|
110
|
+
Context context = get();
|
|
111
|
+
if (context == null) {
|
|
112
|
+
return AppPlatform.UNKNOWN.value();
|
|
113
|
+
}
|
|
114
|
+
String platform = context.getAppPlatform();
|
|
115
|
+
return StringUtils.isBlank(platform) ? AppPlatform.UNKNOWN.value() : AppPlatform.findBy(platform).value();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 获取 networkType
|
|
120
|
+
*/
|
|
121
|
+
public static int getNetworkType() {
|
|
122
|
+
String cAppNetworkType = ContextHelper.getAppContext("c_app_network_type");
|
|
123
|
+
return NumberUtils.toInt(cAppNetworkType);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public static String getHttpHeaderStr() {
|
|
127
|
+
Context context = get();
|
|
128
|
+
if (context == null) {
|
|
129
|
+
return StringUtils.EMPTY;
|
|
130
|
+
}
|
|
131
|
+
Map<String, String> baggage = Optional.ofNullable(context.getBaggage()).orElse(Collections.emptyMap());
|
|
132
|
+
return baggage.getOrDefault(APP_CONTEXT_PREFIX + HTTP_HEADER, "");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private HttpHeader getParsedHttpHeader() {
|
|
136
|
+
Context context = get();
|
|
137
|
+
if (context != null && context.getBaggage().containsKey(APP_CONTEXT_PREFIX + HTTP_HEADER)) {
|
|
138
|
+
String headerJson = ContextHelper.getAppContext(HTTP_HEADER);
|
|
139
|
+
HttpHeader header = JsonHelper.fromJson(headerJson, HttpHeader.class, false);
|
|
140
|
+
return ObjectUtils.defaultIfNull(header, new HttpHeader());
|
|
141
|
+
}
|
|
142
|
+
return new HttpHeader();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 内部封装的 Http Header 对象 (使用 Jackson 注解)
|
|
147
|
+
*/
|
|
148
|
+
@Data
|
|
149
|
+
static class HttpHeader {
|
|
150
|
+
@JsonProperty("User-Agent")
|
|
151
|
+
private String userAgent;
|
|
152
|
+
@JsonProperty("xy-common-params")
|
|
153
|
+
private String commonParams;
|
|
154
|
+
@JsonProperty("X-Network-Source")
|
|
155
|
+
private String xNetworkSource;
|
|
156
|
+
@JsonProperty("Xy-Platform-Info")
|
|
157
|
+
private String platformInfo;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private Map<String, String> parseCommonParams() {
|
|
161
|
+
String paramStr = this.getParsedHttpHeader().getCommonParams();
|
|
162
|
+
if (StringUtils.isEmpty(paramStr)) {
|
|
163
|
+
return Collections.emptyMap();
|
|
164
|
+
}
|
|
165
|
+
Map<String, String> params = new HashMap<>();
|
|
166
|
+
for (String kv : paramStr.split("&")) {
|
|
167
|
+
String[] arr = kv.split("=");
|
|
168
|
+
if (arr.length == 2) {
|
|
169
|
+
try {
|
|
170
|
+
params.put(arr[0], URLDecoder.decode(arr[1], "UTF-8"));
|
|
171
|
+
} catch (Exception e) {
|
|
172
|
+
// ignore
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return params;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public String getDeviceId() {
|
|
180
|
+
return StringUtils.trimToEmpty(parseCommonParams().get("deviceId"));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -26,11 +26,6 @@
|
|
|
26
26
|
<groupId>com.xiaohongshu</groupId>
|
|
27
27
|
<artifactId>infra-framework-context</artifactId>
|
|
28
28
|
</dependency>
|
|
29
|
-
<dependency>
|
|
30
|
-
<groupId>org.springframework.boot</groupId>
|
|
31
|
-
<artifactId>spring-boot-starter-test</artifactId>
|
|
32
|
-
<scope>test</scope>
|
|
33
|
-
</dependency>
|
|
34
29
|
</dependencies>
|
|
35
30
|
|
|
36
31
|
</project>
|
|
@@ -47,11 +47,6 @@
|
|
|
47
47
|
<groupId>com.xiaohongshu</groupId>
|
|
48
48
|
<artifactId>infra-framework-rpc-core</artifactId>
|
|
49
49
|
</dependency>
|
|
50
|
-
<dependency>
|
|
51
|
-
<groupId>org.springframework.boot</groupId>
|
|
52
|
-
<artifactId>spring-boot-starter-test</artifactId>
|
|
53
|
-
<scope>test</scope>
|
|
54
|
-
</dependency>
|
|
55
50
|
</dependencies>
|
|
56
51
|
|
|
57
52
|
</project>
|
|
@@ -24,11 +24,6 @@
|
|
|
24
24
|
<groupId>com.xiaohongshu.xray</groupId>
|
|
25
25
|
<artifactId>xray-logging</artifactId>
|
|
26
26
|
</dependency>
|
|
27
|
-
<dependency>
|
|
28
|
-
<groupId>org.springframework.boot</groupId>
|
|
29
|
-
<artifactId>spring-boot-starter-test</artifactId>
|
|
30
|
-
<scope>test</scope>
|
|
31
|
-
</dependency>
|
|
32
27
|
</dependencies>
|
|
33
28
|
|
|
34
29
|
<build>
|
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
<property name="LOG_LEVEL" value="INFO"/>
|
|
4
4
|
<include resource="logback-xray-base.xml"/>
|
|
5
5
|
|
|
6
|
-
<root level="${LOG_LEVEL}">
|
|
7
|
-
<appender-ref ref="ASYNC-CONSOLE-APPENDER"/>
|
|
8
|
-
<!-- <appender-ref ref="Sentry"/>-->
|
|
9
|
-
</root>
|
|
10
|
-
|
|
11
|
-
<logger name="com.xiaohongshu.sns" level="debug"></logger>
|
|
12
6
|
<logger name="org.apache.ibatis" level="INFO"></logger>
|
|
13
7
|
<logger name="org.apache.catalina" level="ERROR"></logger>
|
|
14
8
|
<logger name="org.apache.zookeeper" level="INFO"></logger>
|
|
@@ -17,6 +11,9 @@
|
|
|
17
11
|
<logger name="com.xiaohongshu.racing" level="WARN"></logger>
|
|
18
12
|
<logger name="com.dianping.cat" level="INFO"></logger>
|
|
19
13
|
<logger name="red.midware.shaded" level="INFO"></logger>
|
|
14
|
+
<logger name="com.xiaohongshu.infra.xds.cds.CDSSharedStubWrapper" level="ERROR"></logger>
|
|
20
15
|
<logger name="events" level="INFO"></logger>
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
<logger name="com.zaxxer.hikari.HikariConfig" level="WARN"></logger>
|
|
17
|
+
<logger name="com.zaxxer.hikari.HikariDataSource" level="WARN"></logger>
|
|
18
|
+
<logger name="com.xiaohongshu.infra.rpc.core.registry.eds.MultiRegionsEdsThriftAddressSubscriberProvider" level="off"/>
|
|
19
|
+
</configuration>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="AnalysisProjectProfileManager">
|
|
4
|
+
<option name="PROJECT_PROFILE" />
|
|
5
|
+
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
|
|
6
|
+
<list size="0" />
|
|
7
|
+
</component>
|
|
8
|
+
<component name="ProjectRootManager">
|
|
9
|
+
<output url="file://$PROJECT_DIR$/out" />
|
|
10
|
+
</component>
|
|
11
|
+
<component name="SuppressionsComponent">
|
|
12
|
+
<option name="suppComments" value="[]" />
|
|
13
|
+
</component>
|
|
14
|
+
</project>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
|
@@ -49,8 +49,6 @@ thrift idl开发参考[Thrift IDL开发规范](./README.md)
|
|
|
49
49
|
|
|
50
50
|
Java sdk会以`maven_project`目录作为打包的基础目录,因此可以在目录中添加代码来定制sdk的功能。
|
|
51
51
|
|
|
52
|
-
例如,使用[SpringBoot AutoConfiguration](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html)为sdk开发自动配置功能,参考[例子](example)。
|
|
53
|
-
|
|
54
52
|
## 常见问题
|
|
55
53
|
|
|
56
54
|
1. Invalid remote: origin
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
+
image: docker-reg.devops.xiaohongshu.com/shequ/sns-sdk-ci:latest
|
|
2
|
+
|
|
1
3
|
stages:
|
|
2
4
|
- build
|
|
3
|
-
# 根据项目类型保留需要build的stage 并删掉其他stage
|
|
4
|
-
build:java:
|
|
5
|
-
stage: build
|
|
6
|
-
image: docker-reg.devops.xiaohongshu.com/shequ/sns-sdk-ci:latest
|
|
7
|
-
script:
|
|
8
|
-
- skr -p ${CI_PROJECT_NAME} -c ${CI_COMMIT_REF_NAME}
|
|
9
|
-
only:
|
|
10
|
-
- branches
|
|
11
|
-
- /^\d+\.\d+\.\d+$/
|
|
12
5
|
|
|
13
|
-
build:
|
|
6
|
+
build:java:
|
|
14
7
|
stage: build
|
|
15
|
-
image: docker-reg.devops.xiaohongshu.com/shequ/sns-gosdk-ci:latest
|
|
16
8
|
script:
|
|
17
9
|
- skr -p ${CI_PROJECT_NAME} -c ${CI_COMMIT_REF_NAME}
|
|
18
10
|
only:
|
|
19
11
|
- branches
|
|
20
12
|
- /^\d+\.\d+\.\d+$/
|
|
21
|
-
|
|
22
|
-
build:node:
|
|
23
|
-
stage: build
|
|
24
|
-
image: docker-reg.devops.xiaohongshu.com/fe/ts-generator:latest
|
|
25
|
-
script:
|
|
26
|
-
- DEBUG=common-bin tsGen build --branch ${CI_COMMIT_REF_NAME} --userEmail ${GITLAB_USER_EMAIL} --ciId ${CI_COMMIT_SHA:0:8} --pId ${CI_PROJECT_ID}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
namespace java com.xiaohongshu.infra.rpc.base
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* rpc context that contains:
|
|
5
|
+
* 1: open tracing infomation
|
|
6
|
+
* 2: userID for log coloring
|
|
7
|
+
* 3: an expandable map for custom loads
|
|
8
|
+
*/
|
|
9
|
+
struct Context {
|
|
10
|
+
/**
|
|
11
|
+
* open tracing trace id
|
|
12
|
+
**/
|
|
13
|
+
1: string traceID;
|
|
14
|
+
/**
|
|
15
|
+
* the caller's host (IP or hostname)
|
|
16
|
+
**/
|
|
17
|
+
2: string clientHost;
|
|
18
|
+
/**
|
|
19
|
+
* open tracing baggae, can be used to carry custom loads
|
|
20
|
+
**/
|
|
21
|
+
3: map<string, string> baggage;
|
|
22
|
+
/**
|
|
23
|
+
* open tracing span id
|
|
24
|
+
**/
|
|
25
|
+
4: string spanID;
|
|
26
|
+
/**
|
|
27
|
+
* whether the very request is sampled
|
|
28
|
+
**/
|
|
29
|
+
5: bool sampled;
|
|
30
|
+
/**
|
|
31
|
+
* open tracing parent span ID
|
|
32
|
+
**/
|
|
33
|
+
6: string parentSpanID;
|
|
34
|
+
/**
|
|
35
|
+
* userID for log coloring
|
|
36
|
+
**/
|
|
37
|
+
7: string userID;
|
|
38
|
+
/**
|
|
39
|
+
* appID for multi-app
|
|
40
|
+
**/
|
|
41
|
+
8: string appID;
|
|
42
|
+
/**
|
|
43
|
+
* projectID for multi-app
|
|
44
|
+
**/
|
|
45
|
+
9: string projectID;
|
|
46
|
+
/**
|
|
47
|
+
* app build number
|
|
48
|
+
**/
|
|
49
|
+
10: i32 appBuild;
|
|
50
|
+
/**
|
|
51
|
+
* app platform
|
|
52
|
+
**/
|
|
53
|
+
11: string appPlatform;
|
|
54
|
+
/**
|
|
55
|
+
* user ip address
|
|
56
|
+
**/
|
|
57
|
+
12: string userIP;
|
|
58
|
+
/**
|
|
59
|
+
* session locale
|
|
60
|
+
**/
|
|
61
|
+
13: string locale;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* multi-app 枚举类型
|
|
66
|
+
**/
|
|
67
|
+
enum ProjectType {
|
|
68
|
+
XHS = 0
|
|
69
|
+
TOP = 1
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* common result
|
|
74
|
+
*/
|
|
75
|
+
struct Result {
|
|
76
|
+
1: required bool success,
|
|
77
|
+
2: optional i32 code,
|
|
78
|
+
3: optional string message
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* typedefs
|
|
83
|
+
*/
|
|
84
|
+
typedef i64 Timestamp
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* the BaseService is defined for management purpose, such as check alive.
|
|
88
|
+
**/
|
|
89
|
+
service BaseService {
|
|
90
|
+
/**
|
|
91
|
+
* for checking alive
|
|
92
|
+
**/
|
|
93
|
+
void ping()
|
|
94
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
namespace java com.xiaohongshu.sns.demo.api.common
|
|
2
|
+
|
|
3
|
+
include "../base/base.thrift"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 分页-请求对象
|
|
7
|
+
**/
|
|
8
|
+
struct PageParam {
|
|
9
|
+
/**
|
|
10
|
+
* 页码
|
|
11
|
+
**/
|
|
12
|
+
1:optional i32 pageNo;
|
|
13
|
+
/**
|
|
14
|
+
* 分页大小
|
|
15
|
+
**/
|
|
16
|
+
2:optional i32 pageSize;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 分页-返回对象
|
|
21
|
+
**/
|
|
22
|
+
struct PageResp {
|
|
23
|
+
/**
|
|
24
|
+
* 当前页
|
|
25
|
+
**/
|
|
26
|
+
1:optional i32 currentPage;
|
|
27
|
+
/**
|
|
28
|
+
* 分页大小
|
|
29
|
+
**/
|
|
30
|
+
2:optional i32 pageSize;
|
|
31
|
+
/**
|
|
32
|
+
* 总页数
|
|
33
|
+
**/
|
|
34
|
+
3:optional i32 totalPages;
|
|
35
|
+
/**
|
|
36
|
+
* 总条数
|
|
37
|
+
**/
|
|
38
|
+
4:optional i32 totalCount;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
namespace java com.xiaohongshu.sns.demo.api.enum
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
thrift
|
|
3
|
+
# 这里每一行就是一个thrift文件路径,直接遍历来快速构建
|
|
4
|
+
filename="./service.thrift"
|
|
5
|
+
for file in $filename; do
|
|
6
|
+
thrift --gen java:generated_annotations=undated -out maven_project/src/main/java/ $file
|
|
7
|
+
done
|
|
@@ -1,40 +1,23 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
1
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
3
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
5
4
|
<modelVersion>4.0.0</modelVersion>
|
|
6
5
|
|
|
7
|
-
<groupId>com.xiaohongshu.sns
|
|
8
|
-
<artifactId>
|
|
6
|
+
<groupId>com.xiaohongshu.sns</groupId>
|
|
7
|
+
<artifactId>demo-api</artifactId>
|
|
8
|
+
|
|
9
|
+
<!-- 无须动,ci的时候会自动覆盖的 -->
|
|
9
10
|
<version>${sdk.version}</version>
|
|
10
11
|
|
|
11
12
|
<properties>
|
|
12
|
-
<
|
|
13
|
-
<sdk.version>1.0.0-SNAPSHOT</sdk.version>
|
|
14
|
-
<midware.version>2.2.31-RELEASE</midware.version>
|
|
13
|
+
<midware.version>3.3.11-RELEASE</midware.version>
|
|
15
14
|
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
|
|
15
|
+
<!--这里换成jdk11 david解析不了,不支持-->
|
|
16
|
+
<maven.compiler.source>8</maven.compiler.source>
|
|
17
|
+
<maven.compiler.target>8</maven.compiler.target>
|
|
18
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
16
19
|
</properties>
|
|
17
20
|
|
|
18
|
-
<build>
|
|
19
|
-
<plugins>
|
|
20
|
-
<plugin>
|
|
21
|
-
<groupId>org.apache.maven.plugins</groupId>
|
|
22
|
-
<artifactId>maven-compiler-plugin</artifactId>
|
|
23
|
-
<configuration>
|
|
24
|
-
<source>1.8</source>
|
|
25
|
-
<target>1.8</target>
|
|
26
|
-
</configuration>
|
|
27
|
-
</plugin>
|
|
28
|
-
<plugin>
|
|
29
|
-
<groupId>org.apache.maven.plugins</groupId>
|
|
30
|
-
<artifactId>maven-surefire-plugin</artifactId>
|
|
31
|
-
<configuration>
|
|
32
|
-
<skip>true</skip>
|
|
33
|
-
</configuration>
|
|
34
|
-
</plugin>
|
|
35
|
-
</plugins>
|
|
36
|
-
</build>
|
|
37
|
-
|
|
38
21
|
<dependencyManagement>
|
|
39
22
|
<dependencies>
|
|
40
23
|
<dependency>
|
|
@@ -51,25 +34,31 @@
|
|
|
51
34
|
<type>pom</type>
|
|
52
35
|
<scope>import</scope>
|
|
53
36
|
</dependency>
|
|
37
|
+
|
|
54
38
|
</dependencies>
|
|
55
39
|
</dependencyManagement>
|
|
56
40
|
|
|
57
41
|
<dependencies>
|
|
42
|
+
<dependency>
|
|
43
|
+
<groupId>com.xiaohongshu</groupId>
|
|
44
|
+
<artifactId>rpc-context</artifactId>
|
|
45
|
+
</dependency>
|
|
58
46
|
|
|
59
47
|
<dependency>
|
|
60
48
|
<groupId>com.xiaohongshu</groupId>
|
|
61
49
|
<artifactId>thrift-springboot</artifactId>
|
|
50
|
+
<optional>true</optional>
|
|
62
51
|
</dependency>
|
|
63
52
|
|
|
64
53
|
<dependency>
|
|
65
54
|
<groupId>org.springframework.boot</groupId>
|
|
66
55
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
56
|
+
<optional>true</optional>
|
|
67
57
|
</dependency>
|
|
68
58
|
|
|
69
59
|
<dependency>
|
|
70
|
-
<groupId>org.
|
|
71
|
-
<artifactId>
|
|
72
|
-
<scope>test</scope>
|
|
60
|
+
<groupId>org.apache.thrift</groupId>
|
|
61
|
+
<artifactId>libthrift</artifactId>
|
|
73
62
|
</dependency>
|
|
74
63
|
|
|
75
64
|
<dependency>
|
|
@@ -77,19 +66,49 @@
|
|
|
77
66
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
78
67
|
<optional>true</optional>
|
|
79
68
|
</dependency>
|
|
69
|
+
|
|
80
70
|
</dependencies>
|
|
81
71
|
|
|
72
|
+
<build>
|
|
73
|
+
<plugins>
|
|
74
|
+
<plugin>
|
|
75
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
76
|
+
<artifactId>maven-compiler-plugin</artifactId>
|
|
77
|
+
<version>3.8.1</version>
|
|
78
|
+
<configuration>
|
|
79
|
+
<source>1.8</source>
|
|
80
|
+
<target>1.8</target>
|
|
81
|
+
</configuration>
|
|
82
|
+
</plugin>
|
|
83
|
+
<plugin>
|
|
84
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
85
|
+
<artifactId>maven-source-plugin</artifactId>
|
|
86
|
+
<version>2.1.1</version>
|
|
87
|
+
<executions>
|
|
88
|
+
<execution>
|
|
89
|
+
<id>attach-sources</id>
|
|
90
|
+
<goals>
|
|
91
|
+
<goal>jar-no-fork</goal>
|
|
92
|
+
</goals>
|
|
93
|
+
</execution>
|
|
94
|
+
</executions>
|
|
95
|
+
</plugin>
|
|
96
|
+
</plugins>
|
|
97
|
+
</build>
|
|
82
98
|
<distributionManagement>
|
|
83
99
|
<snapshotRepository>
|
|
84
100
|
<id>snapshots</id>
|
|
85
|
-
<name>
|
|
86
|
-
<url>
|
|
101
|
+
<name>nexus snapshot repository</name>
|
|
102
|
+
<url>
|
|
103
|
+
https://artifactory.devops.xiaohongshu.com/artifactory/maven-snapshots/
|
|
104
|
+
</url>
|
|
87
105
|
</snapshotRepository>
|
|
88
106
|
<repository>
|
|
89
107
|
<id>releases</id>
|
|
90
|
-
<name>
|
|
91
|
-
<url>
|
|
108
|
+
<name>nexus repository</name>
|
|
109
|
+
<url>
|
|
110
|
+
https://artifactory.devops.xiaohongshu.com/artifactory/maven-releases/
|
|
111
|
+
</url>
|
|
92
112
|
</repository>
|
|
93
|
-
</distributionManagement>
|
|
94
|
-
|
|
95
|
-
</project>
|
|
113
|
+
</distributionManagement>
|
|
114
|
+
</project>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
dependencies:
|
|
2
|
-
sns-idls/base: 1.
|
|
2
|
+
sns-idls/base: 1.1.7 # 依赖sns-idls/base项目,tag为1.1.7
|
|
3
3
|
build:
|
|
4
|
-
|
|
5
|
-
enabled: false
|
|
4
|
+
go:
|
|
5
|
+
enabled: false # 是否开启go编译 [gosdk](https://wiki.xiaohongshu.com/pages/viewpage.action?pageId=43487207)
|
|
6
|
+
recurse: true # 是否递归编译引用的thrift文件(默认会将com.xiaohongshu.infra.rpc.base包删除)
|