-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e237f0b
commit cd72fbf
Showing
7 changed files
with
112 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 21 additions & 14 deletions
35
...a-common/src/main/java/me/chanjar/weixin/common/util/json/WxMediaUploadResultAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
package me.chanjar.weixin.common.util.json; | ||
|
||
import com.google.gson.*; | ||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParseException; | ||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||
|
||
/** | ||
* @author Daniel Qian | ||
*/ | ||
public class WxMediaUploadResultAdapter implements JsonDeserializer<WxMediaUploadResult> { | ||
|
||
@Override | ||
public WxMediaUploadResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||
WxMediaUploadResult uploadResult = new WxMediaUploadResult(); | ||
JsonObject uploadResultJsonObject = json.getAsJsonObject(); | ||
WxMediaUploadResult result = new WxMediaUploadResult(); | ||
JsonObject jsonObject = json.getAsJsonObject(); | ||
if (jsonObject.get("url") != null && !jsonObject.get("url").isJsonNull()) { | ||
result.setUrl(GsonHelper.getAsString(jsonObject.get("url"))); | ||
} | ||
|
||
if (uploadResultJsonObject.get("type") != null && !uploadResultJsonObject.get("type").isJsonNull()) { | ||
uploadResult.setType(GsonHelper.getAsString(uploadResultJsonObject.get("type"))); | ||
if (jsonObject.get("type") != null && !jsonObject.get("type").isJsonNull()) { | ||
result.setType(GsonHelper.getAsString(jsonObject.get("type"))); | ||
} | ||
if (uploadResultJsonObject.get("media_id") != null && !uploadResultJsonObject.get("media_id").isJsonNull()) { | ||
uploadResult.setMediaId(GsonHelper.getAsString(uploadResultJsonObject.get("media_id"))); | ||
if (jsonObject.get("media_id") != null && !jsonObject.get("media_id").isJsonNull()) { | ||
result.setMediaId(GsonHelper.getAsString(jsonObject.get("media_id"))); | ||
} | ||
if (uploadResultJsonObject.get("thumb_media_id") != null && !uploadResultJsonObject.get("thumb_media_id").isJsonNull()) { | ||
uploadResult.setThumbMediaId(GsonHelper.getAsString(uploadResultJsonObject.get("thumb_media_id"))); | ||
if (jsonObject.get("thumb_media_id") != null && !jsonObject.get("thumb_media_id").isJsonNull()) { | ||
result.setThumbMediaId(GsonHelper.getAsString(jsonObject.get("thumb_media_id"))); | ||
} | ||
if (uploadResultJsonObject.get("created_at") != null && !uploadResultJsonObject.get("created_at").isJsonNull()) { | ||
uploadResult.setCreatedAt(GsonHelper.getAsPrimitiveLong(uploadResultJsonObject.get("created_at"))); | ||
if (jsonObject.get("created_at") != null && !jsonObject.get("created_at").isJsonNull()) { | ||
result.setCreatedAt(GsonHelper.getAsPrimitiveLong(jsonObject.get("created_at"))); | ||
} | ||
return uploadResult; | ||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 23 additions & 11 deletions
34
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters