|
|
@ -60,8 +60,10 @@ public class WeChatController { |
|
|
|
// 替换为你的 AppID 和 AppSecret
|
|
|
|
private static final String APP_ID = "wxe2eba8943d47678e"; |
|
|
|
private static final String APP_SECRET = "7af0a56aaa7780ad041ee4cda2359353"; |
|
|
|
// 替换为你的 AppOpenID 和 AccessToken
|
|
|
|
private static final String APP_OPENID = "ohCQF7nRbdBVnk4GUD_TgTRv_IYs"; |
|
|
|
private static final String ACCESS_TOKEN = "93_Rdp-c-VBBN-2qNAxBQ1pmx3gvuxjoMk2A_BmczJinRcJ9G3IwJ-okucNWz30OY7bb_8tk44XjQ5pdaRf8-lvrb8blIUjuFDklcyLtjX-1g4Ik9Q1cUuzhP-O9DwLYPhAEASFW"; |
|
|
|
private static final String ACCESS_TOKEN = "94__zxL178Y10nGfyMXXtYuLsAophgmEjiIzaBHdXz6vd5qw4dpgaG8msR-sPvkzIDx0LxlipMbizq5wwOj_t62RxCKFMuT3TwdO66Gvg5q1RsJ8EWQmOUjHllStFoCQSiADARFH"; |
|
|
|
// 模板ID
|
|
|
|
private static final String TEMPLATE_ID = "z9G-4dk8JHget0Ftm8ysEa6pT2mztklfDTYF9sYBDzM"; |
|
|
|
private static final String SUBSCRIBE_SEND_PREFIX = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="; |
|
|
|
|
|
|
@ -81,13 +83,17 @@ public class WeChatController { |
|
|
|
@GetMapping("/getOpenId") |
|
|
|
public R< Map<String, String>> getOpenId(String jsCode) throws JsonProcessingException { |
|
|
|
Map<String, String> result = getOpenIdForApp(jsCode); |
|
|
|
return R.ok("根据jsCode获取对应的openId", result); |
|
|
|
String openid = result.get("openid"); |
|
|
|
log.info("获取到:openid:{} " , openid); |
|
|
|
return R.ok("根据jsCode获取对应的openid", result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getAccessToken") |
|
|
|
public R<Map<String, String>> getAccessToken() throws JsonProcessingException { |
|
|
|
Map<String, String> result = getAccessTokenForApp(); |
|
|
|
String access_token = result.get("access_token"); |
|
|
|
log.info("获取到:access_token:{} " , access_token); |
|
|
|
// 5. 返回给前端
|
|
|
|
return R.ok("获取对应的access_token",result); |
|
|
|
} |
|
|
@ -172,12 +178,12 @@ public class WeChatController { |
|
|
|
request.setTemplate_id(TEMPLATE_ID); |
|
|
|
request.setPage("pages/index/index"); |
|
|
|
Map<String, WeComSubscribeDataItem> dataMap = new HashMap<>(); |
|
|
|
dataMap.put("character_string5", new WeComSubscribeDataItem("工单编号:123456")); |
|
|
|
dataMap.put("thing2", new WeComSubscribeDataItem("故障标题:空调内部故障")); |
|
|
|
dataMap.put("time13", new WeComSubscribeDataItem("发生时间:2025年6月20日")); |
|
|
|
dataMap.put("thing10", new WeComSubscribeDataItem("发生位置:宁波国研机房")); |
|
|
|
dataMap.put("thing8", new WeComSubscribeDataItem("计划完成时间:2025年6月21日")); |
|
|
|
|
|
|
|
dataMap.put("character_string5", new WeComSubscribeDataItem("123456")); |
|
|
|
dataMap.put("thing2", new WeComSubscribeDataItem("空调内部故障")); |
|
|
|
dataMap.put("time13", new WeComSubscribeDataItem("2025年6月20日 9:00")); |
|
|
|
dataMap.put("thing10", new WeComSubscribeDataItem("宁波国研机房")); |
|
|
|
dataMap.put("time8", new WeComSubscribeDataItem("2025年5月23日 18:00")); |
|
|
|
//dataMap.put("time8", new WeComSubscribeDataItem("2025-07-14 13:47:00"));
|
|
|
|
request.setData(dataMap); |
|
|
|
// 序列化 JSON 并记录日志
|
|
|
|
String jsonBody; |
|
|
|