|
@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.miaxis.ZzjsApplication;
|
|
import com.miaxis.ZzjsApplication;
|
|
import com.miaxis.feign.dto.AddTemplate;
|
|
import com.miaxis.feign.dto.AddTemplate;
|
|
import com.miaxis.feign.dto.WxSend;
|
|
import com.miaxis.feign.dto.WxSend;
|
|
-import com.miaxis.feign.service.IWxAddTemplate;
|
|
|
|
import com.miaxis.feign.service.IWxSendService;
|
|
import com.miaxis.feign.service.IWxSendService;
|
|
-import com.miaxis.feign.service.IWxTemplateList;
|
|
|
|
-import com.miaxis.feign.service.IWxgetTokenService;
|
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -19,43 +16,39 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
@RunWith(SpringRunner.class)
|
|
@RunWith(SpringRunner.class)
|
|
public class WxTest {
|
|
public class WxTest {
|
|
|
|
|
|
- private String token ="45_NDxpMTA7H4BUlbToZa9IHTCe4zyctpzyt_RNoaIOAGxTAtT_OQ3fZ2iTuSyXjILqC21eG8Pcyi6756FCSR0YWDbXyMoyL3GdJ9JHNm-qhZQZfEIwLe12TC2_b7f3Zmkj684Ph7xfu6bmNB8TSRJcAEAYXP";
|
|
|
|
- @Autowired
|
|
|
|
- private IWxgetTokenService wxgetTokenService;
|
|
|
|
- @Autowired
|
|
|
|
- private IWxSendService wxSendService;
|
|
|
|
- @Autowired
|
|
|
|
- private IWxAddTemplate wxAddTemplate;
|
|
|
|
|
|
+ private String token ="45__6qC8wIAVRtGuk7lz5IlBk678dvuA3383qRGcHJ721sttRJSvxwz6ppCXHIfSFs6AWVdfek21KYvmokK1C3NlUnfYPXm_pKAhm61d9Q6pA1CENOAyIxbX3nJ5NP1knSZUzMLN73pRtGdNXvYWPEgAHARKZ";
|
|
|
|
+
|
|
|
|
+ private String token2 ="45_nGtdvZCMg8Kqr74QKw2po6FfKfdUaMYVGOGnnkz1ft1sSF8PzfYTk3hoxjynUx6cgos0WgpGUMU8ymmSw73s3UOkhb__vBJrFUyRLtDzAcQgk34IiRprxcrRo_unC_RftEklW6VM8bc0F7dCXALdAFABEP";
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private IWxTemplateList wxTemplateList;
|
|
|
|
|
|
+ private IWxSendService wxSendService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${app.appid}")
|
|
@Value("${app.appid}")
|
|
private String appid;
|
|
private String appid;
|
|
-
|
|
|
|
@Value("${app.secret}")
|
|
@Value("${app.secret}")
|
|
private String secret;
|
|
private String secret;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取微信小程序token
|
|
|
|
+ */
|
|
@Test
|
|
@Test
|
|
public void getWxgetTokenService(){
|
|
public void getWxgetTokenService(){
|
|
- String result = wxgetTokenService.getAccessToken("client_credential",appid,secret);
|
|
|
|
-
|
|
|
|
|
|
+ String result = wxSendService.getAccessToken("client_credential",appid,secret);
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
String accessToken = json.get("access_token").toString();
|
|
String accessToken = json.get("access_token").toString();
|
|
String expiresIn = json.get("expires_in").toString();
|
|
String expiresIn = json.get("expires_in").toString();
|
|
-
|
|
|
|
System.out.println(accessToken);
|
|
System.out.println(accessToken);
|
|
System.out.println(expiresIn);
|
|
System.out.println(expiresIn);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void getWxSendService(){
|
|
public void getWxSendService(){
|
|
WxSend wxSend = new WxSend();
|
|
WxSend wxSend = new WxSend();
|
|
- wxSend.setAccess_token(token);
|
|
|
|
- wxSend.setTouser("oO7PJ5JxqYj0kVYLb1e3FG55mD8E");
|
|
|
|
|
|
+ wxSend.setAccess_token(token2);
|
|
|
|
+ wxSend.setTouser("oO7PJ5FlradAM7tqw3TM2zvEj4O4");
|
|
wxSend.setTemplate_id("NlZAFJj1p5aHFOg6BBesP7xFAJh5kIZ0kp_YwtJje0g");
|
|
wxSend.setTemplate_id("NlZAFJj1p5aHFOg6BBesP7xFAJh5kIZ0kp_YwtJje0g");
|
|
wxSend.setPage("/pages/index/index?active=user");
|
|
wxSend.setPage("/pages/index/index?active=user");
|
|
|
|
|
|
@@ -79,22 +72,5 @@ public class WxTest {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @Test
|
|
|
|
- public void addWxTemplate(){
|
|
|
|
- AddTemplate addTemplate = new AddTemplate();
|
|
|
|
- addTemplate.setAccess_token(token);
|
|
|
|
- addTemplate.setTid("gAayj95qwP5C59NApKj9VCis3zpnfg5G3TqJIOx-CGc");
|
|
|
|
- Integer[] intList = {1,2,3};
|
|
|
|
- addTemplate.setKidList(intList);
|
|
|
|
- addTemplate.setSceneDesc("测试模板");
|
|
|
|
- String result = wxAddTemplate.addTemplate(token,addTemplate);
|
|
|
|
- System.out.println(result);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void getWxTemplate(){
|
|
|
|
- String result = wxTemplateList.getAccessToken(token);;
|
|
|
|
- System.out.println(result);
|
|
|
|
- }
|
|
|
|
|
|
|
|
}
|
|
}
|