1 package com.foxinmy.weixin4j.model.card;
2
3 import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject;
5 import com.alibaba.fastjson.annotation.JSONField;
6 import com.foxinmy.weixin4j.type.card.ActivateCommonField;
7 import com.foxinmy.weixin4j.type.card.ActivateFormFieldType;
8
9 import java.util.HashSet;
10
11
12
13
14
15
16
17 public class MemberUserForm {
18
19
20
21
22 @JSONField(name = "card_id")
23 private String cardId;
24
25
26
27
28 @JSONField(name = "service_statement")
29 private JSONObject serviceStatement;
30
31
32
33 @JSONField(name = "bind_old_card")
34 private JSONObject bindOldCard;
35
36
37
38
39 @JSONField(name = "required_form")
40 private FormBudiler requiredForm;
41
42
43
44
45 @JSONField(name = "optional_form")
46 private FormBudiler optionalForm;
47
48
49 public String getCardId() {
50 return cardId;
51 }
52
53 public void setCardId(String cardId) {
54 this.cardId = cardId;
55 }
56
57 public JSONObject getServiceStatement() {
58 return serviceStatement;
59 }
60
61 public void setServiceStatement(String name,String url) {
62 JSONObject serviceStatement = new JSONObject();
63 serviceStatement.put("name",name);
64 serviceStatement.put("url",url);
65 this.serviceStatement = serviceStatement;
66 }
67
68 public JSONObject getBindOldCard() {
69 return bindOldCard;
70 }
71
72 public void setBindOldCard(String name,String url) {
73 JSONObject bindOldCard = new JSONObject();
74 bindOldCard.put("name",name);
75 bindOldCard.put("url",url);
76 this.bindOldCard = bindOldCard;
77 }
78
79 public void setRequiredForm(FormBudiler formBudiler) {
80 this.requiredForm = formBudiler;
81 }
82
83 public void setOptionalForm(FormBudiler formBudiler) {
84 this.optionalForm = formBudiler;
85 }
86
87 public FormBudiler getRequiredForm() {
88 return requiredForm;
89 }
90
91 public FormBudiler getOptionalForm() {
92 return optionalForm;
93 }
94
95 public final static class FormBudiler {
96
97
98
99
100
101
102 @JSONField(name = "can_modify")
103 private boolean canModify;
104
105
106
107 @JSONField(name = "rich_field_list")
108 private JSONArray richFieldList;
109
110
111
112
113 @JSONField(name = "common_field_id_list")
114 private HashSet<ActivateCommonField> commonFieldIdList;
115
116
117
118
119 @JSONField(name = "custom_field_list")
120 private HashSet<String> customFieldList;
121
122
123
124
125 public FormBudiler addRichField(ActivateFormFieldType fieldType, String name, String... values) {
126 if (richFieldList == null) {
127 richFieldList = new JSONArray();
128 }
129 JSONObject obj = new JSONObject();
130 obj.put("type", fieldType);
131 obj.put("name", name);
132 obj.put("values", values);
133 richFieldList.add(obj);
134 return this;
135 }
136
137 public FormBudiler canModify(boolean modify){
138 this.canModify = modify;
139 return this;
140 }
141
142
143
144
145
146 public FormBudiler addCommonField(ActivateCommonField... fields) {
147 if (commonFieldIdList == null) {
148 commonFieldIdList = new HashSet<ActivateCommonField>();
149 }
150 for (ActivateCommonField field : fields) {
151 commonFieldIdList.add(field);
152 }
153 return this;
154 }
155
156
157
158
159
160 public FormBudiler addCustomField(String... names) {
161 if (customFieldList == null) {
162 customFieldList = new HashSet<String>();
163 }
164 for (String name : names) {
165 customFieldList.add(name);
166 }
167 return this;
168 }
169
170 public boolean isCanModify() {
171 return canModify;
172 }
173
174 public JSONArray getRichFieldList() {
175 return richFieldList;
176 }
177
178 public HashSet<ActivateCommonField> getCommonFieldIdList() {
179 return commonFieldIdList;
180 }
181
182 public HashSet<String> getCustomFieldList() {
183 return customFieldList;
184 }
185 }
186
187 }