mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
#1095 修复微信营销接口中有问题的回传数据接口方法
This commit is contained in:
@@ -1,39 +1,69 @@
|
||||
package me.chanjar.weixin.mp.bean.marketing;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/007gzs">007</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class WxMpUserAction implements Serializable {
|
||||
private static final long serialVersionUID = 7042393762652152209L;
|
||||
|
||||
private Long userActionSetId;
|
||||
private String url;
|
||||
private Boolean actionTime;
|
||||
private Integer actionTime;
|
||||
private String actionType;
|
||||
private String clickId;
|
||||
private Integer actionParam;
|
||||
|
||||
public JsonObject toJsonObject() {
|
||||
private JsonObject toJsonObject() {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("user_action_set_id", this.userActionSetId);
|
||||
json.addProperty("url", this.url);
|
||||
json.addProperty("action_time", this.actionTime);
|
||||
json.addProperty("action_type", this.actionType);
|
||||
|
||||
if (this.clickId != null) {
|
||||
JsonObject traceJson = new JsonObject();
|
||||
traceJson.addProperty("click_id", this.clickId);
|
||||
json.add("trace", traceJson);
|
||||
}
|
||||
|
||||
if (this.actionParam != null) {
|
||||
JsonObject actionParamJson = new JsonObject();
|
||||
actionParamJson.addProperty("value", actionParam);
|
||||
json.add("action_param", actionParamJson);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* list对象转换为json字符串
|
||||
*
|
||||
* @param actions .
|
||||
* @return .
|
||||
*/
|
||||
public static String listToJson(List<WxMpUserAction> actions) {
|
||||
JsonArray array = new JsonArray();
|
||||
for (WxMpUserAction action : actions) {
|
||||
array.add(action.toJsonObject());
|
||||
}
|
||||
|
||||
JsonObject result = new JsonObject();
|
||||
result.add("actions", array);
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user