File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
main/java/me/chanjar/weixin/cp/api/impl
test/java/me/chanjar/weixin/cp/api Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException
131131 @ Override
132132 public WxCpMessageSendResult messageSend (WxCpMessage message ) throws WxErrorException {
133133 String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send" ;
134+ Integer agentId = message .getAgentId ();
135+ if (null == agentId ){
136+ message .setAgentId (this .getWxCpConfigStorage ().getAgentId ());
137+ }
134138 return WxCpMessageSendResult .fromJson (this .post (url , message .toJson ()));
135139 }
136140
Original file line number Diff line number Diff line change 2020public class WxCpMessageAPITest {
2121
2222 @ Inject
23- protected WxCpServiceImpl wxService ;
23+ protected WxCpService wxService ;
24+
2425 private ApiTestModule .WxXmlCpInMemoryConfigStorage configStorage ;
2526
2627 @ BeforeTest
@@ -30,7 +31,7 @@ public void setup() {
3031
3132 public void testSendMessage () throws WxErrorException {
3233 WxCpMessage message = new WxCpMessage ();
33- message .setAgentId (configStorage .getAgentId ());
34+ // message.setAgentId(configStorage.getAgentId());
3435 message .setMsgType (WxConsts .CUSTOM_MSG_TEXT );
3536 message .setToUser (configStorage .getUserId ());
3637 message .setContent ("欢迎欢迎,热烈欢迎\n 换行测试\n 超链接:<a href=\" http://www.baidu.com\" >Hello World</a>" );
@@ -43,10 +44,11 @@ public void testSendMessage() throws WxErrorException {
4344 System .out .println (messageSendResult .getInvalidTagList ());
4445 }
4546
47+ @ Test
4648 public void testSendMessage1 () throws WxErrorException {
4749 WxCpMessage message = WxCpMessage
4850 .TEXT ()
49- .agentId (configStorage .getAgentId ())
51+ // .agentId(configStorage.getAgentId())
5052 .toUser (configStorage .getUserId ())
5153 .content ("欢迎欢迎,热烈欢迎\n 换行测试\n 超链接:<a href=\" http://www.baidu.com\" >Hello World</a>" )
5254 .build ();
You can’t perform that action at this time.
0 commit comments