File tree Expand file tree Collapse file tree 3 files changed +45
-15
lines changed
main/java/me/chanjar/weixin/mp/api
test/java/me/chanjar/weixin/mp/api/impl Expand file tree Collapse file tree 3 files changed +45
-15
lines changed Original file line number Diff line number Diff line change 1
1
package me .chanjar .weixin .mp .api ;
2
2
3
- import java .util .List ;
4
-
5
3
import me .chanjar .weixin .common .exception .WxErrorException ;
6
4
import me .chanjar .weixin .mp .bean .template .WxMpTemplate ;
7
5
import me .chanjar .weixin .mp .bean .template .WxMpTemplateIndustry ;
8
6
import me .chanjar .weixin .mp .bean .template .WxMpTemplateMessage ;
9
7
8
+ import java .util .List ;
9
+
10
10
/**
11
11
* <pre>
12
12
* 模板消息接口
@@ -68,8 +68,20 @@ public interface WxMpTemplateMsgService {
68
68
* 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
69
69
* 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=ACCESS_TOKEN
70
70
* </pre>
71
- *
71
+ *
72
72
* @return templateId 模板Id
73
73
*/
74
74
List <WxMpTemplate > getAllPrivateTemplate () throws WxErrorException ;
75
+
76
+ /**
77
+ * <pre>
78
+ * 删除模板
79
+ * 删除模板可在MP中完成,为方便第三方开发者,提供通过接口调用的方式来删除某帐号下的模板
80
+ * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
81
+ * 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token=ACCESS_TOKEN
82
+ * </pre>
83
+ *
84
+ * @param templateId 模板Id
85
+ */
86
+ boolean delPrivateTemplate (String templateId ) throws WxErrorException ;
75
87
}
Original file line number Diff line number Diff line change 1
1
package me .chanjar .weixin .mp .api .impl ;
2
2
3
- import java .util .List ;
4
-
5
3
import com .google .gson .JsonObject ;
6
4
import com .google .gson .JsonParser ;
7
-
8
5
import me .chanjar .weixin .common .bean .result .WxError ;
9
6
import me .chanjar .weixin .common .exception .WxErrorException ;
10
7
import me .chanjar .weixin .mp .api .WxMpService ;
13
10
import me .chanjar .weixin .mp .bean .template .WxMpTemplateIndustry ;
14
11
import me .chanjar .weixin .mp .bean .template .WxMpTemplateMessage ;
15
12
13
+ import java .util .List ;
14
+
16
15
/**
17
16
* <pre>
18
17
* Created by Binary Wang on 2016-10-14.
@@ -79,4 +78,18 @@ public List<WxMpTemplate> getAllPrivateTemplate() throws WxErrorException {
79
78
return WxMpTemplate .fromJson (this .wxMpService .get (url , null ));
80
79
}
81
80
81
+ @ Override
82
+ public boolean delPrivateTemplate (String templateId ) throws WxErrorException {
83
+ String url = API_URL_PREFIX + "/del_private_template" ;
84
+ JsonObject jsonObject = new JsonObject ();
85
+ jsonObject .addProperty ("template_id" , templateId );
86
+ String responseContent = this .wxMpService .post (url , jsonObject .toString ());
87
+ WxError error = WxError .fromJson (responseContent );
88
+ if (error .getErrorCode () == 0 ) {
89
+ return true ;
90
+ }
91
+
92
+ throw new WxErrorException (error );
93
+ }
94
+
82
95
}
Original file line number Diff line number Diff line change 1
1
package me .chanjar .weixin .mp .api .impl ;
2
2
3
- import java .text .SimpleDateFormat ;
4
- import java .util .Date ;
5
- import java .util .List ;
6
-
7
- import org .testng .Assert ;
8
- import org .testng .annotations .Guice ;
9
- import org .testng .annotations .Test ;
10
-
11
3
import com .google .inject .Inject ;
12
-
13
4
import me .chanjar .weixin .common .exception .WxErrorException ;
14
5
import me .chanjar .weixin .mp .api .ApiTestModule ;
15
6
import me .chanjar .weixin .mp .api .WxXmlMpInMemoryConfigStorage ;
16
7
import me .chanjar .weixin .mp .bean .template .WxMpTemplate ;
17
8
import me .chanjar .weixin .mp .bean .template .WxMpTemplateData ;
18
9
import me .chanjar .weixin .mp .bean .template .WxMpTemplateIndustry ;
19
10
import me .chanjar .weixin .mp .bean .template .WxMpTemplateMessage ;
11
+ import org .testng .Assert ;
12
+ import org .testng .annotations .Guice ;
13
+ import org .testng .annotations .Test ;
14
+
15
+ import java .text .SimpleDateFormat ;
16
+ import java .util .Date ;
17
+ import java .util .List ;
20
18
21
19
/**
22
20
* <pre>
@@ -74,4 +72,11 @@ public void testGetAllPrivateTemplate() throws Exception {
74
72
System .err .println (result );
75
73
}
76
74
75
+ @ Test
76
+ public void testDelPrivateTemplate () throws Exception {
77
+ String templateId = "RPcTe7-4BkU5A2J3imC6W0b4JbjEERcJg0whOMKJKIc" ;
78
+ boolean result = this .wxService .getTemplateMsgService ().delPrivateTemplate (templateId );
79
+ Assert .assertTrue (result );
80
+ }
81
+
77
82
}
You can’t perform that action at this time.
0 commit comments