zhaowenxuan
2025-04-30 aacaa3d2daafbd97ab008908b9f2fe9ed6c1f713
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.ltkj.web.tduck;
 
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.ltkj.tduck.utils.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.security.PermitAll;
import javax.validation.constraints.NotBlank;
 
/**
 * @author : smalljop
 * @description : 微信公众号网页
 * @create : 2020-12-02 13:40
 **/
@AllArgsConstructor
@RestController
@RequestMapping("/wx/jsapi/")
public class WxJsApiController {
//    private final WxMpService wxService;
 
 
    /**
     * 用户授权url
     *
     * @return hcah
     */
    @GetMapping("/authorization/url")
    @PermitAll
    public Result getAuthorizationUrl(@RequestParam @NotBlank String url) {
        String appId = "11111";
        String authorizationUrl = StrUtil.format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={}&redirect_uri={}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect", appId, URLUtil.encode(url));
        return Result.success(authorizationUrl);
    }
 
 
    /**
     * 根据code获取用户信息
     *
     * @param code
     * @return
     */
    @GetMapping("/authorization/user/info")
    @PermitAll
    public Result greetUser(@RequestParam @NotBlank String code)  {
//        WxOAuth2UserInfo userInfo = null;
//        try {
//            WxOAuth2AccessToken accessToken = wxService.getOAuth2Service().getAccessToken(code);
//            userInfo = wxService.getOAuth2Service().getUserInfo(accessToken, null);
//        } catch (WxErrorException e) {
//            return Result.success();
//        }
//        return Result.success(userInfo);
        return Result.success();
    }
 
 
    /**
     * 获取jsapi签名
     */
    @GetMapping("/signature")
    @PermitAll
    public Result getSignature(@RequestParam String url) throws Exception {
//        WxJsapiSignature signature = wxService.createJsapiSignature(url);
//        return Result.success(signature);
        return Result.success();
    }
 
 
}