Skip to content

Commit be0e96e

Browse files
authored
Merge pull request #4 from xelloss00x/main
[feature] [1.1.0.0]
2 parents 69502e8 + c4583cc commit be0e96e

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@
1111

1212
[1.0.1.1] - 2021-01-27
1313

14-
* 优化OPPO获取AuthToken的机制
14+
* 优化OPPO获取AuthToken的机制
15+
16+
[1.1.0.0] - 2021-02-04
17+
18+
* 去除org.reflections.reflections依赖,涉及到使用reflections工具的地方自己实现
19+
* 调用XM和OP上传接口上传失败后,XM和OP的返回信息完整输出到返回结果的data中
20+
* XM的图片上传接口由/media/upload/smallIcon调整为/media/upload/image

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<dependency>
1212
<groupId>com.getui.push</groupId>
1313
<artifactId>getui-3rd-push-utils</artifactId>
14-
<version>1.0.0.0</version>
14+
<version>1.1.0.0</version>
1515
</dependency>
1616
```
1717

pom.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.getui.push</groupId>
88
<artifactId>getui-3rd-push-utils</artifactId>
9-
<version>1.0.1.1</version>
9+
<version>1.1.0.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>
@@ -60,11 +60,6 @@
6060
<artifactId>logback-classic</artifactId>
6161
<version>1.1.7</version>
6262
</dependency>
63-
<dependency>
64-
<groupId>org.reflections</groupId>
65-
<artifactId>reflections</artifactId>
66-
<version>0.9.11</version>
67-
</dependency>
6863
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
6964
<dependency>
7065
<groupId>com.github.ben-manes.caffeine</groupId>

src/main/java/com/getui/gtps/manufacturer/ManufacturerFactory.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import com.getui.gtps.config.CommonConfig;
44
import com.getui.gtps.config.GtSDKConstants;
55
import com.getui.gtps.exception.AuthFailedException;
6-
import org.reflections.Reflections;
6+
import com.getui.gtps.manufacturer.oppo.OppoService;
7+
import com.getui.gtps.manufacturer.xm.XmService;
78
import org.slf4j.Logger;
89
import org.slf4j.LoggerFactory;
910

@@ -14,6 +15,7 @@
1415
import java.lang.reflect.InvocationTargetException;
1516
import java.util.Arrays;
1617
import java.util.HashMap;
18+
import java.util.HashSet;
1719
import java.util.Map;
1820
import java.util.Optional;
1921
import java.util.Set;
@@ -39,6 +41,13 @@ public class ManufacturerFactory {
3941

4042
private static final Logger LOGGER = LoggerFactory.getLogger(ManufacturerFactory.class);
4143

44+
private static final Set<Class<? extends BaseManufacturer>> subTypes = new HashSet<Class<? extends BaseManufacturer>>() {
45+
{
46+
add(XmService.class);
47+
add(OppoService.class);
48+
}
49+
};
50+
4251
/**
4352
* 手动配置线程执行器的线程池大小,线程数请结合BaseManufacturer子类梳理调节
4453
*/
@@ -68,8 +77,6 @@ public static synchronized void init() {
6877
* 多厂商服务实例初始化
6978
*/
7079
private static void initManufacturersInstance() {
71-
Reflections reflections = new Reflections(BaseManufacturer.class.getPackage().getName());
72-
Set<Class<? extends BaseManufacturer>> subTypes = reflections.getSubTypesOf(BaseManufacturer.class);
7380
subTypes.forEach(clazz -> {
7481
String name = "";
7582
try {

src/main/java/com/getui/gtps/manufacturer/oppo/OppoService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private Result uploadIcon(File file, String cacheKey) {
151151
} else if (OppoConstants.ReturnCode.InvalidAuthCode.getCode() == returnCode) {
152152
return Result.invalidAuthToken();
153153
} else {
154-
return Result.fail(jsonNode.get("message").textValue());
154+
return Result.fail(jsonNode.toString());
155155
}
156156
} catch (JsonProcessingException e) {
157157
LOGGER.error("OppoService uploadIcon error. ", e);
@@ -191,7 +191,7 @@ private Result uploadPic(File file, String cacheKey) {
191191
} else if (OppoConstants.ReturnCode.InvalidAuthCode.getCode() == returnCode) {
192192
return Result.invalidAuthToken();
193193
} else {
194-
return Result.fail(jsonNode.get("message").textValue());
194+
return Result.fail(jsonNode.toString());
195195
}
196196
} catch (JsonProcessingException e) {
197197
LOGGER.error("OppoService uploadIcon error. ", e);

src/main/java/com/getui/gtps/manufacturer/xm/XmService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,19 @@ private Result uploadIcon(File file, String cacheKey) {
7171
Map<String, String> headParameters = new HashMap<>();
7272
headParameters.put("Authorization", "key=" + this.getAppSecret());
7373
Map<String, String> requestParameters = new HashMap<>();
74-
HttpResponse httpResponse = HttpUtils.postFile(XmConstants.RequestPath.UPLOAD_ICON.getPath(), headParameters, requestParameters, file, CommonConfig.callTimeout);
74+
requestParameters.put("is_global", "false");
75+
requestParameters.put("is_icon", "true");
76+
HttpResponse httpResponse = HttpUtils.postFile(XmConstants.RequestPath.UPLOAD_PIC.getPath(), headParameters, requestParameters, file, CommonConfig.callTimeout);
7577
LOGGER.info("XmService uploadIcon httpResponse: {}", httpResponse.toString());
7678
if (httpResponse.success()) {
7779
try {
7880
JsonNode jsonNode = new ObjectMapper().readTree(httpResponse.getContent());
7981
if (0 == jsonNode.get("code").intValue()) {
80-
String url = jsonNode.get("data").get("small_icon_url").textValue();
82+
String url = jsonNode.get("data").get("icon_url").textValue();
8183
this.cacheMap.put(ICON_URL, CacheServiceFactory.getCacheService(CaffeineCacheService.class).set(cacheKey, url));
8284
return Result.success(url);
8385
} else {
84-
return Result.fail(jsonNode.get("description").textValue());
86+
return Result.fail(jsonNode.toString());
8587
}
8688
} catch (JsonProcessingException e) {
8789
LOGGER.error("XmService uploadIcon error. ", e);
@@ -113,7 +115,7 @@ private Result uploadPic(File file, String cacheKey) {
113115
this.cacheMap.put(PIC_URL, CacheServiceFactory.getCacheService(CaffeineCacheService.class).set(cacheKey, url));
114116
return Result.success(url);
115117
} else {
116-
return Result.fail(jsonNode.get("description").textValue());
118+
return Result.fail(jsonNode.toString());
117119
}
118120
} catch (JsonProcessingException e) {
119121
LOGGER.error("XmService uploadIcon error. ", e);

0 commit comments

Comments
 (0)