Browse Source

推送测试

koul 6 years ago
parent
commit
0e91fdb17f

+ 2 - 5
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/impl/WxNotifyServiceImpl.java

@@ -189,9 +189,8 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 			}else {
 				throw new Exception("系统内部错误,请联系管理员");
 			}
-		}else {
-			throw new Exception("通知已被删除,请刷新");
 		}
+		return getNotifyDetail(stuId,0L,notifyDO);
 	}
 
 	/**
@@ -211,10 +210,8 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 			}else {
 				throw new Exception("系统内部错误,请联系管理员");
 			}
-		}else {
-			throw new Exception("通知已被删除,请刷新");
 		}
-
+		return getNotifyDetail(0L,teacherId,notifyDO);
 	}
 
 	/**

+ 2 - 2
applications/wechat/wechat-api/src/main/java/com/usoftchina/smartschool/wechat/api/WxPushApi.java

@@ -17,7 +17,7 @@ public interface WxPushApi {
                          @RequestParam("keyword4") String keyword4, @RequestParam("remark") String remark,
                          @RequestParam("url") String url);
 
-    @GetMapping("/getWxAccessToken")
+    /*@GetMapping("/getWxAccessToken")
     public String getWxAccessToken(@RequestParam("appId") String appId, @RequestParam("secret") String secret);
-
+*/
 }

+ 1 - 1
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/service/WxPushService.java

@@ -16,5 +16,5 @@ public interface WxPushService {
                          @Param("keyword3") String keyword3, @Param("keyword4") String keyword4,
                          @Param("remark") String remark, @Param("url") String url);
 
-    public String getWxAccessToken(@Param("appId") String appId, @Param("secret") String secret);
+    /*public String getWxAccessToken(@Param("appId") String appId, @Param("secret") String secret);*/
 }

+ 13 - 19
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/service/impl/WxPushServiceImpl.java

@@ -32,9 +32,16 @@ public class WxPushServiceImpl implements WxPushService{
                         + "\"keyword3\":{\"value\":\""+keyword3+"\",\"color\":\"#173177\"},"
                         + "\"keyword4\":{\"value\":\""+keyword4+"\",\"color\":\"#173177\"},"
                         + "\"remark\":{\"value\":\""+remark+"\",\"color\":\"#173177\"}}}";
-                String access_token=  getWxAccessToken(appId,secret);
-                //System.err.println("wxPushAccess_token======" + access_token);
-                HttpRequest hRequest=  HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+access_token)
+                HashMap<String, Object> params=new HashMap<>();
+                params.put("appid", appId);
+                params.put("secret", secret);
+                params.put("grant_type", "client_credential");
+                HttpRequest httpRequest= HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token",params,false);
+                String content=httpRequest.body();
+                System.err.println("getWxAccessTokenContent======"+content);
+                String token= JSON.parseObject(content).getString("access_token");
+                System.err.println("getWxAccessTokenToken====="+ token);
+                HttpRequest hRequest=  HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token)
                         .header("Content-Type", "application/json")
                         .send(json.getBytes());
                 String result= hRequest.body();
@@ -52,21 +59,8 @@ public class WxPushServiceImpl implements WxPushService{
             return "已推送";
         }
 
-        public String getWxAccessToken(String appId,String secret){
-            HashMap<String, Object> params=new HashMap<>();
-            params.put("appid", appId);
-            params.put("secret", secret);
-            params.put("grant_type", "client_credential");
-            HttpRequest httpRequest= HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token",params,false);
-            String content=httpRequest.body();
-           // System.err.println("getWxAccessTokenContent======"+content);
-           // HttpRequest response= HttpRequest.get("https://api.weixin.qq.com/sns/oauth2/access_token", params, true);
-            //String result=response.body();
-            //System.err.println("getWxAccessTokenResult======"+result);
-            //String token= JSON.parseObject(result).getString("access_token");
-           // System.err.println("getWxAccessTokenToken====="+token);
-            String token= JSON.parseObject(content).getString("access_token");
-            System.err.println("getWxAccessToken======"+token);
+        /*public String getWxAccessToken(String appId,String secret){
+
             return token;
-        }
+        }*/
 }