Skip to content

Commit 28156fc

Browse files
committed
🎨 #2272 【企业微信】发送新客户欢迎语接口增加对file文件消息的支持
1 parent b65783b commit 28156fc

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package me.chanjar.weixin.cp.bean.external.msg;
22

33
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
45
import me.chanjar.weixin.cp.constant.WxCpConsts;
56

67
import java.io.Serializable;
78

9+
/**
10+
* @author chutian0124
11+
*/
12+
@Data
813
public class Attachment implements Serializable {
914
private static final long serialVersionUID = -8078748379570640198L;
1015

@@ -15,62 +20,35 @@ public class Attachment implements Serializable {
1520

1621
private Link link;
1722

18-
private MiniProgram miniprogram;
23+
@SerializedName("miniprogram")
24+
private MiniProgram miniProgram;
1925

2026
private Video video;
2127

22-
@Override
23-
public String toString() {
24-
return "Attachment{" +
25-
"msgType='" + msgType + '\'' +
26-
", image=" + image +
27-
", link=" + link +
28-
", miniprogram=" + miniprogram +
29-
", video=" + video +
30-
'}';
31-
}
32-
33-
private String getMsgType() {
34-
return msgType;
35-
}
36-
37-
private void setMsgType(String msgType) {
38-
this.msgType = msgType;
39-
}
40-
41-
public Image getImage() {
42-
return image;
43-
}
28+
private File file;
4429

4530
public void setImage(Image image) {
4631
this.image = image;
4732
this.msgType = WxCpConsts.WelcomeMsgType.IMAGE;
4833
}
4934

50-
public Link getLink() {
51-
return link;
52-
}
53-
5435
public void setLink(Link link) {
5536
this.link = link;
5637
this.msgType = WxCpConsts.WelcomeMsgType.LINK;
5738
}
5839

59-
public MiniProgram getMiniprogram() {
60-
return miniprogram;
61-
}
62-
63-
public void setMiniprogram(MiniProgram miniprogram) {
64-
this.miniprogram = miniprogram;
40+
public void setMiniProgram(MiniProgram miniProgram) {
41+
this.miniProgram = miniProgram;
6542
this.msgType = WxCpConsts.WelcomeMsgType.MINIPROGRAM;
6643
}
6744

68-
public Video getVideo() {
69-
return video;
70-
}
71-
7245
public void setVideo(Video video) {
7346
this.video = video;
7447
this.msgType = WxCpConsts.WelcomeMsgType.VIDEO;
7548
}
49+
50+
public void setFile(File file ) {
51+
this.file = file;
52+
this.msgType = WxCpConsts.WelcomeMsgType.FILE;
53+
}
7654
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package me.chanjar.weixin.cp.bean.external.msg;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
10+
* @date 2021-08-23
11+
*/
12+
@Data
13+
public class File implements Serializable {
14+
private static final long serialVersionUID = 2794189478198329090L;
15+
16+
@SerializedName("media_id")
17+
private String mediaId;
18+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java

+5
Original file line numberDiff line numberDiff line change
@@ -353,5 +353,10 @@ public static class WelcomeMsgType {
353353
* 小程序消息.
354354
*/
355355
public static final String MINIPROGRAM = "miniprogram";
356+
357+
/**
358+
* 文件消息.
359+
*/
360+
public static final String FILE = "file";
356361
}
357362
}

0 commit comments

Comments
 (0)