3333import org .hamster .weixinmp .controller .util .WxXmlUtil ;
3434import org .hamster .weixinmp .dao .entity .auth .WxAuth ;
3535import org .hamster .weixinmp .dao .entity .auth .WxAuthReq ;
36+ import org .hamster .weixinmp .dao .entity .base .WxBaseMsgEntity ;
37+ import org .hamster .weixinmp .dao .entity .base .WxBaseRespEntity ;
3638import org .hamster .weixinmp .dao .entity .item .WxItemMusic ;
3739import org .hamster .weixinmp .dao .entity .item .WxItemPicDesc ;
3840import org .hamster .weixinmp .dao .entity .menu .WxMenuBtn ;
@@ -78,38 +80,38 @@ public class WxService {
7880 public static final String DEFAULT_GET_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET" ;
7981
8082 @ Autowired (required = false )
81- WxAuthDao wxAuthDao ;
83+ protected WxAuthDao wxAuthDao ;
8284 @ Autowired (required = false )
83- WxAuthReqDao authReqDao ;
85+ protected WxAuthReqDao authReqDao ;
8486
8587 @ Autowired (required = false )
86- WxMsgTextDao msgTextDao ;
88+ protected WxMsgTextDao msgTextDao ;
8789 @ Autowired (required = false )
88- WxMsgImgDao msgImgDao ;
90+ protected WxMsgImgDao msgImgDao ;
8991 @ Autowired (required = false )
90- WxMsgLinkDao msgLinkDao ;
92+ protected WxMsgLinkDao msgLinkDao ;
9193 @ Autowired (required = false )
92- WxMsgLocDao msgLocDao ;
94+ protected WxMsgLocDao msgLocDao ;
9395 @ Autowired (required = false )
94- WxMsgEventDao msgEventDao ;
96+ protected WxMsgEventDao msgEventDao ;
9597
9698 @ Autowired (required = false )
97- WxRespTextDao respTextDao ;
99+ protected WxRespTextDao respTextDao ;
98100 @ Autowired (required = false )
99- WxRespPicDescDao respPicDescDao ;
101+ protected WxRespPicDescDao respPicDescDao ;
100102 @ Autowired (required = false )
101- WxRespMusicDao respMusicDao ;
103+ protected WxRespMusicDao respMusicDao ;
102104 @ Autowired (required = false )
103- WxItemPicDescDao wxItemPicDescDao ;
105+ protected WxItemPicDescDao wxItemPicDescDao ;
104106
105107 @ Autowired (required = false )
106- WxMenuBtnDao wxMenuBtnDao ;
108+ protected WxMenuBtnDao wxMenuBtnDao ;
107109
108110 @ Setter
109- private String token ;
111+ protected String token ;
110112
111113 @ Autowired (required = false )
112- WxConfig wxConfig ;
114+ protected WxConfig wxConfig ;
113115
114116 public boolean validateAuth (String signature , String timestamp ,
115117 String nonce , String echostr ) throws WxException {
@@ -343,8 +345,13 @@ public void createMenu(List<WxMenuBtn> wxMenuBtnList, String accessToken)
343345 throw new WxException (e );
344346 }
345347 }
348+
349+ public WxBaseRespEntity handleMessage (WxBaseMsgEntity msg ) {
350+ WxRespText respText = createRespText ("Only test message, please ignore this." , msg .getToUserName (), msg .getFromUserName (), 1 );
351+ return respText ;
352+ }
346353
347- private static String getParameterizedUrl (String url , String ... args ) {
354+ protected static String getParameterizedUrl (String url , String ... args ) {
348355 String result = url ;
349356 for (int i = 0 ; i < args .length ; i += 2 ) {
350357 String p = args [i ];
@@ -354,7 +361,7 @@ private static String getParameterizedUrl(String url, String... args) {
354361 return result ;
355362 }
356363
357- private static String getStringToHash (String timestamp , String nonce ,
364+ protected static String getStringToHash (String timestamp , String nonce ,
358365 String token ) {
359366 List <String > list = new ArrayList <String >();
360367 list .add (timestamp );
@@ -372,7 +379,7 @@ private static String getStringToHash(String timestamp, String nonce,
372379
373380 /**
374381 */
375- private static String hash (String str ) {
382+ protected static String hash (String str ) {
376383 try {
377384 MessageDigest md = MessageDigest .getInstance ("SHA-1" );
378385 byte [] b = md .digest (str .getBytes ());
0 commit comments