@@ -0,0 +1,91 @@ | |||||
package me.chanjar.weixin.mp.bean; | |||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||||
/** | |||||
* 语义理解查询用对象 | |||||
* | |||||
* http://mp.weixin.qq.com/wiki/index.php?title=语义理解 | |||||
* | |||||
* @author Daniel Qian | |||||
*/ | |||||
public class WxMpSemanticQuery { | |||||
private String query; | |||||
private String category; | |||||
private Float latitude; | |||||
private Float longitude; | |||||
private String city; | |||||
private String region; | |||||
private String appid; | |||||
private String uid; | |||||
public String getQuery() { | |||||
return query; | |||||
} | |||||
public void setQuery(String query) { | |||||
this.query = query; | |||||
} | |||||
public String getCategory() { | |||||
return category; | |||||
} | |||||
public void setCategory(String category) { | |||||
this.category = category; | |||||
} | |||||
public Float getLatitude() { | |||||
return latitude; | |||||
} | |||||
public void setLatitude(Float latitude) { | |||||
this.latitude = latitude; | |||||
} | |||||
public Float getLongitude() { | |||||
return longitude; | |||||
} | |||||
public void setLongitude(Float longitude) { | |||||
this.longitude = longitude; | |||||
} | |||||
public String getCity() { | |||||
return city; | |||||
} | |||||
public void setCity(String city) { | |||||
this.city = city; | |||||
} | |||||
public String getRegion() { | |||||
return region; | |||||
} | |||||
public void setRegion(String region) { | |||||
this.region = region; | |||||
} | |||||
public String getAppid() { | |||||
return appid; | |||||
} | |||||
public void setAppid(String appid) { | |||||
this.appid = appid; | |||||
} | |||||
public String getUid() { | |||||
return uid; | |||||
} | |||||
public void setUid(String uid) { | |||||
this.uid = uid; | |||||
} | |||||
public String toJson() { | |||||
return WxMpGsonBuilder.create().toJson(this); | |||||
} | |||||
} |
@@ -0,0 +1,73 @@ | |||||
package me.chanjar.weixin.mp.bean.result; | |||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||||
/** | |||||
* 语义理解查询结果对象 | |||||
* | |||||
* http://mp.weixin.qq.com/wiki/index.php?title=语义理解 | |||||
* | |||||
* @author Daniel Qian | |||||
*/ | |||||
public class WxMpSemanticQueryResult { | |||||
private String query; | |||||
private String type; | |||||
private String semantic; | |||||
private String result; | |||||
private String answer; | |||||
private String text; | |||||
public String getQuery() { | |||||
return query; | |||||
} | |||||
public void setQuery(String query) { | |||||
this.query = query; | |||||
} | |||||
public String getType() { | |||||
return type; | |||||
} | |||||
public void setType(String type) { | |||||
this.type = type; | |||||
} | |||||
public String getSemantic() { | |||||
return semantic; | |||||
} | |||||
public void setSemantic(String semantic) { | |||||
this.semantic = semantic; | |||||
} | |||||
public String getResult() { | |||||
return result; | |||||
} | |||||
public void setResult(String result) { | |||||
this.result = result; | |||||
} | |||||
public String getAnswer() { | |||||
return answer; | |||||
} | |||||
public void setAnswer(String answer) { | |||||
this.answer = answer; | |||||
} | |||||
public String getText() { | |||||
return text; | |||||
} | |||||
public void setText(String text) { | |||||
this.text = text; | |||||
} | |||||
public static WxMpSemanticQueryResult fromJson(String json) { | |||||
return WxMpGsonBuilder.create().fromJson(json, WxMpSemanticQueryResult.class); | |||||
} | |||||
} |
@@ -23,6 +23,7 @@ public class WxMpGsonBuilder { | |||||
INSTANCE.registerTypeAdapter(WxMpMassUploadResult.class, new WxMpMassUploadResultAdapter()); | INSTANCE.registerTypeAdapter(WxMpMassUploadResult.class, new WxMpMassUploadResultAdapter()); | ||||
INSTANCE.registerTypeAdapter(WxMpQrCodeTicket.class, new WxQrCodeTicketAdapter()); | INSTANCE.registerTypeAdapter(WxMpQrCodeTicket.class, new WxQrCodeTicketAdapter()); | ||||
INSTANCE.registerTypeAdapter(WxMpTemplateMessage.class, new WxMpTemplateMessageGsonAdapter()); | INSTANCE.registerTypeAdapter(WxMpTemplateMessage.class, new WxMpTemplateMessageGsonAdapter()); | ||||
INSTANCE.registerTypeAdapter(WxMpSemanticQueryResult.class, new WxMpSemanticQueryResultAdapter()); | |||||
} | } | ||||
public static Gson create() { | public static Gson create() { | ||||
@@ -0,0 +1,51 @@ | |||||
/* | |||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved. | |||||
* | |||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended | |||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction | |||||
* arose from modification of the original source, or other redistribution of this source | |||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD. | |||||
*/ | |||||
package me.chanjar.weixin.mp.util.json; | |||||
import com.google.gson.*; | |||||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||||
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; | |||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; | |||||
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult; | |||||
import java.lang.reflect.Type; | |||||
/** | |||||
* | |||||
* @author Daniel Qian | |||||
* | |||||
*/ | |||||
public class WxMpSemanticQueryResultAdapter implements JsonDeserializer<WxMpSemanticQueryResult> { | |||||
public WxMpSemanticQueryResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | |||||
WxMpSemanticQueryResult result = new WxMpSemanticQueryResult(); | |||||
JsonObject resultJsonObject = json.getAsJsonObject(); | |||||
if (GsonHelper.getString(resultJsonObject, "query") != null) { | |||||
result.setQuery(GsonHelper.getString(resultJsonObject, "query")); | |||||
} | |||||
if (GsonHelper.getString(resultJsonObject, "type") != null) { | |||||
result.setType(GsonHelper.getString(resultJsonObject, "type")); | |||||
} | |||||
if (resultJsonObject.get("semantic") != null) { | |||||
result.setSemantic(resultJsonObject.get("semantic").toString()); | |||||
} | |||||
if (resultJsonObject.get("result") != null) { | |||||
result.setResult(resultJsonObject.get("result").toString()); | |||||
} | |||||
if (GsonHelper.getString(resultJsonObject, "answer") != null) { | |||||
result.setAnswer(GsonHelper.getString(resultJsonObject, "answer")); | |||||
} | |||||
if (GsonHelper.getString(resultJsonObject, "text") != null) { | |||||
result.setText(GsonHelper.getString(resultJsonObject, "text")); | |||||
} | |||||
return result; | |||||
} | |||||
} |