luodangjia
2024-05-30 a3990d3644885c51f4ea0fc7a27c1097f4808bfb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//package com.stylefeng.guns.modular.system.util;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.stylefeng.guns.core.util.ToolUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.ResponseEntity;
//import org.springframework.stereotype.Component;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@Component
//public class UrlLinkUtil {
//    @Autowired
//    private HttpClientUtil httpClientUtil;
//
//    @Autowired
//    private RedisUtil redisUtil;
//    public String getWxAppletsAccessToken() throws Exception{
//        String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + "wxc89ecab90d24edd8" + "&secret=" + "bca863174d22736a4a9758a67484947e";
//        String s = httpClientUtil.pushHttpRequset("GET", url, null, null, "form");
//        if(ToolUtil.isEmpty(s)){
//            return null;
//        }
//        JSONObject jsonObject = JSON.parseObject(s);
//        return jsonObject.getString("access_token");
//    }
//
//    public String getUrlLink(String path, String query) throws Exception{
//        String wxAppletsAccessToken = redisUtil.getValue("wxAppletsAccessToken");
//        String url = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + wxAppletsAccessToken;
//        Map<String, Object> param = new HashMap<>();
//        param.put("expire_type", 1);
//        param.put("expire_interval", 1);
//        param.put("path", path);
//        param.put("query", query);
//        param.put("env_version", "release");
//        HttpHeaders httpHeaders = new HttpHeaders();
//        MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8");
//        httpHeaders.setContentType(type);
//        HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(param, httpHeaders);
//        ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
//        String body1 = exchange.getBody();
//        return body1;
//    }
//
//
//}