Commit 16e0ba49f45d8f5fe19c5290c7eda46ceecc364d
1 parent
15a3967b69
Exists in
master
入库重复时, 不再上传图片
Showing
2 changed files
with
14 additions
and
6 deletions
Show diff stats
app/src/main/java/com/hjx/parent/dialog/AddHomeworkDialog.java
... | ... | @@ -222,18 +222,19 @@ public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ |
222 | 222 | int index = pair.first; |
223 | 223 | String path = pair.second; |
224 | 224 | File file = new File(path); |
225 | - String id = file.getName().substring(0, file.getName().lastIndexOf(".")); | |
226 | 225 | return Observable.just(file) |
227 | 226 | .map(var -> { |
227 | + String id = file.getName().substring(0, file.getName().lastIndexOf(".")); | |
228 | 228 | BaiduInput baiduInput = NetWorks.inputImage(path, id).blockingGet(); |
229 | 229 | if (baiduInput.getError_code() != null && baiduInput.getBrief() == null) { |
230 | 230 | throw new RuntimeException("图片入库失败"); |
231 | + } | |
232 | + if (baiduInput.getBrief() != null) { | |
233 | + id = baiduInput.briefId(); | |
231 | 234 | } else { |
232 | - return baiduInput; | |
235 | + NetWorks.uploadImage(path, id).blockingGet(); | |
233 | 236 | } |
234 | - }) | |
235 | - .map(var -> NetWorks.uploadImage(path, id).blockingGet()) | |
236 | - .map(var -> { | |
237 | + | |
237 | 238 | Map<String, Object> map = new HashMap<>(); |
238 | 239 | map.put("brief", id); |
239 | 240 | map.put("sort", index); | ... | ... |
libs/common/src/main/java/com/prws/common/bean/baidu/BaiduInput.java
1 | 1 | package com.prws.common.bean.baidu; |
2 | 2 | |
3 | +import com.google.gson.Gson; | |
4 | + | |
3 | 5 | public class BaiduInput { |
4 | 6 | String brief; |
5 | 7 | String error_code; |
... | ... | @@ -26,6 +28,11 @@ public class BaiduInput { |
26 | 28 | return brief; |
27 | 29 | } |
28 | 30 | |
31 | + public String briefId() { | |
32 | + Brief briefBean = new Gson().fromJson(brief, Brief.class); | |
33 | + return briefBean.id; | |
34 | + } | |
35 | + | |
29 | 36 | public String getError_code() { |
30 | 37 | return error_code; |
31 | 38 | } |
... | ... | @@ -38,7 +45,7 @@ public class BaiduInput { |
38 | 45 | return log_id; |
39 | 46 | } |
40 | 47 | |
41 | - public class Brief { | |
48 | + public static class Brief { | |
42 | 49 | String name; |
43 | 50 | String id; |
44 | 51 | ... | ... |