Skip to content

Commit f84ccb3

Browse files
authored
🎨 #2923【企业微信】模版卡片消息增加更新为新的卡片功能
1 parent 3def66b commit f84ccb3

File tree

3 files changed

+285
-0
lines changed

3 files changed

+285
-0
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.chanjar.weixin.cp.api;
22

33
import me.chanjar.weixin.common.error.WxErrorException;
4+
import me.chanjar.weixin.cp.bean.message.TemplateCardMessage;
45

56
import java.util.List;
67

@@ -48,4 +49,5 @@ void updateTemplateCardButton(List<String> userIds, List<Integer> partyIds,
4849
List<Integer> tagIds, Integer atAll, String responseCode,
4950
String replaceName) throws WxErrorException;
5051

52+
void updateTemplateCardButton(TemplateCardMessage templateCardMessage) throws WxErrorException;
5153
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
66
import me.chanjar.weixin.cp.api.WxCpService;
77
import me.chanjar.weixin.cp.api.WxCpTaskCardService;
8+
import me.chanjar.weixin.cp.bean.message.TemplateCardMessage;
89

910
import java.util.HashMap;
1011
import java.util.List;
@@ -60,4 +61,10 @@ public void updateTemplateCardButton(List<String> userIds, List<Integer> partyId
6061
this.mainService.post(url, WxGsonBuilder.create().toJson(data));
6162

6263
}
64+
65+
@Override
66+
public void updateTemplateCardButton(TemplateCardMessage templateCardMessage) throws WxErrorException {
67+
String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE_CARD);
68+
this.mainService.post(url, WxGsonBuilder.create().toJson(templateCardMessage));
69+
}
6370
}
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
package me.chanjar.weixin.cp.bean.message;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.io.Serializable;
9+
import java.util.List;
10+
11+
@Data
12+
@NoArgsConstructor
13+
@AllArgsConstructor
14+
public class TemplateCardMessage implements Serializable {
15+
private static final long serialVersionUID = 8833792280163704239L;
16+
17+
@JsonProperty("userids")
18+
private List<String> userids;
19+
@JsonProperty("partyids")
20+
private List<Integer> partyids;
21+
@JsonProperty("tagids")
22+
private List<Integer> tagids;
23+
@JsonProperty("atall")
24+
private Integer atall;
25+
@JsonProperty("agentid")
26+
private Integer agentid;
27+
@JsonProperty("response_code")
28+
private String responseCode;
29+
@JsonProperty("enable_id_trans")
30+
private Integer enableIdTrans;
31+
@JsonProperty("template_card")
32+
private TemplateCardDTO templateCard;
33+
34+
@NoArgsConstructor
35+
@Data
36+
public static class TemplateCardDTO {
37+
@JsonProperty("card_type")
38+
private String cardType;
39+
@JsonProperty("source")
40+
private SourceDTO source;
41+
@JsonProperty("main_title")
42+
private MainTitleDTO mainTitle;
43+
@JsonProperty("select_list")
44+
private List<SelectListDTO> selectList;
45+
@JsonProperty("submit_button")
46+
private SubmitButtonDTO submitButton;
47+
@JsonProperty("replace_text")
48+
private String replaceText;
49+
50+
@JsonProperty("checkbox")
51+
private CheckboxDTO checkbox;
52+
53+
54+
@JsonProperty("action_menu")
55+
private ActionMenuDTO actionMenu;
56+
@JsonProperty("quote_area")
57+
private QuoteAreaDTO quoteArea;
58+
@JsonProperty("sub_title_text")
59+
private String subTitleText;
60+
@JsonProperty("horizontal_content_list")
61+
private List<HorizontalContentListDTO> horizontalContentList;
62+
@JsonProperty("card_action")
63+
private CardActionDTO cardAction;
64+
@JsonProperty("button_selection")
65+
private ButtonSelectionDTO buttonSelection;
66+
@JsonProperty("button_list")
67+
private List<ButtonListDTO> buttonList;
68+
69+
@JsonProperty("image_text_area")
70+
private ImageTextAreaDTO imageTextArea;
71+
@JsonProperty("card_image")
72+
private CardImageDTO cardImage;
73+
@JsonProperty("vertical_content_list")
74+
private List<MainTitleDTO> verticalContentList;
75+
@JsonProperty("jump_list")
76+
private List<JumpListDTO> jumpList;
77+
78+
79+
@NoArgsConstructor
80+
@Data
81+
public static class SourceDTO {
82+
@JsonProperty("icon_url")
83+
private String iconUrl;
84+
@JsonProperty("desc")
85+
private String desc;
86+
@JsonProperty("desc_color")
87+
private Integer descColor;
88+
}
89+
90+
@NoArgsConstructor
91+
@Data
92+
public static class ActionMenuDTO {
93+
@JsonProperty("desc")
94+
private String desc;
95+
@JsonProperty("action_list")
96+
private List<SubmitButtonDTO> actionList;
97+
}
98+
99+
@NoArgsConstructor
100+
@Data
101+
public static class QuoteAreaDTO {
102+
@JsonProperty("type")
103+
private Integer type;
104+
@JsonProperty("url")
105+
private String url;
106+
@JsonProperty("title")
107+
private String title;
108+
@JsonProperty("quote_text")
109+
private String quoteText;
110+
}
111+
112+
@NoArgsConstructor
113+
@Data
114+
public static class CardActionDTO {
115+
@JsonProperty("type")
116+
private Integer type;
117+
@JsonProperty("url")
118+
private String url;
119+
@JsonProperty("appid")
120+
private String appid;
121+
@JsonProperty("pagepath")
122+
private String pagepath;
123+
}
124+
125+
@NoArgsConstructor
126+
@Data
127+
public static class ButtonSelectionDTO {
128+
@JsonProperty("question_key")
129+
private String questionKey;
130+
@JsonProperty("title")
131+
private String title;
132+
@JsonProperty("option_list")
133+
private List<SelectListDTO.OptionListDTO> optionList;
134+
@JsonProperty("selected_id")
135+
private String selectedId;
136+
}
137+
138+
@NoArgsConstructor
139+
@Data
140+
public static class HorizontalContentListDTO {
141+
@JsonProperty("keyname")
142+
private String keyname;
143+
@JsonProperty("value")
144+
private String value;
145+
@JsonProperty("type")
146+
private Integer type;
147+
@JsonProperty("url")
148+
private String url;
149+
@JsonProperty("media_id")
150+
private String mediaId;
151+
@JsonProperty("userid")
152+
private String userid;
153+
}
154+
155+
@NoArgsConstructor
156+
@Data
157+
public static class ButtonListDTO {
158+
@JsonProperty("text")
159+
private String text;
160+
@JsonProperty("style")
161+
private Integer style;
162+
@JsonProperty("key")
163+
private String key;
164+
}
165+
166+
167+
@NoArgsConstructor
168+
@Data
169+
public static class CheckboxDTO {
170+
@JsonProperty("question_key")
171+
private String questionKey;
172+
@JsonProperty("option_list")
173+
private List<OptionListDTO> optionList;
174+
@JsonProperty("disable")
175+
private Boolean disable;
176+
@JsonProperty("mode")
177+
private Integer mode;
178+
179+
@NoArgsConstructor
180+
@Data
181+
public static class OptionListDTO {
182+
@JsonProperty("id")
183+
private String id;
184+
@JsonProperty("text")
185+
private String text;
186+
@JsonProperty("is_checked")
187+
private Boolean isChecked;
188+
}
189+
190+
}
191+
192+
@NoArgsConstructor
193+
@Data
194+
public static class MainTitleDTO {
195+
@JsonProperty("title")
196+
private String title;
197+
@JsonProperty("desc")
198+
private String desc;
199+
}
200+
201+
@NoArgsConstructor
202+
@Data
203+
public static class SubmitButtonDTO {
204+
@JsonProperty("text")
205+
private String text;
206+
@JsonProperty("key")
207+
private String key;
208+
}
209+
210+
@NoArgsConstructor
211+
@Data
212+
public static class SelectListDTO {
213+
@JsonProperty("question_key")
214+
private String questionKey;
215+
@JsonProperty("title")
216+
private String title;
217+
@JsonProperty("selected_id")
218+
private String selectedId;
219+
@JsonProperty("disable")
220+
private Boolean disable;
221+
@JsonProperty("option_list")
222+
private List<OptionListDTO> optionList;
223+
224+
@NoArgsConstructor
225+
@Data
226+
public static class OptionListDTO {
227+
@JsonProperty("id")
228+
private String id;
229+
@JsonProperty("text")
230+
private String text;
231+
}
232+
}
233+
234+
@NoArgsConstructor
235+
@Data
236+
public static class ImageTextAreaDTO {
237+
@JsonProperty("type")
238+
private Integer type;
239+
@JsonProperty("url")
240+
private String url;
241+
@JsonProperty("title")
242+
private String title;
243+
@JsonProperty("desc")
244+
private String desc;
245+
@JsonProperty("image_url")
246+
private String imageUrl;
247+
}
248+
249+
@NoArgsConstructor
250+
@Data
251+
public static class CardImageDTO {
252+
@JsonProperty("url")
253+
private String url;
254+
@JsonProperty("aspect_ratio")
255+
private Double aspectRatio;
256+
}
257+
258+
@NoArgsConstructor
259+
@Data
260+
public static class JumpListDTO {
261+
@JsonProperty("type")
262+
private Integer type;
263+
@JsonProperty("title")
264+
private String title;
265+
@JsonProperty("url")
266+
private String url;
267+
@JsonProperty("appid")
268+
private String appid;
269+
@JsonProperty("pagepath")
270+
private String pagepath;
271+
}
272+
273+
274+
}
275+
276+
}

0 commit comments

Comments
 (0)