From 3fd361d0a43d81483f292aec2f26b3380e159d00 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Sun, 4 Dec 2022 09:00:14 -0500 Subject: [PATCH] =?UTF-8?q?USVT-125=20=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=BE=AE=E4=BF=A1=20QR=20=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=9A=84=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/auth/WeChatController.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/main/java/com/northtecom/visatrack/api/controller/auth/WeChatController.java diff --git a/src/main/java/com/northtecom/visatrack/api/controller/auth/WeChatController.java b/src/main/java/com/northtecom/visatrack/api/controller/auth/WeChatController.java new file mode 100644 index 0000000..4163540 --- /dev/null +++ b/src/main/java/com/northtecom/visatrack/api/controller/auth/WeChatController.java @@ -0,0 +1,67 @@ +package com.northtecom.visatrack.api.controller.auth; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.northtecom.visatrack.api.service.impl.UserService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.web.bind.annotation.*; + +import java.util.UUID; + +/** + * Created with IntelliJ IDEA. + * + * @Author: XieYang + * @Date: 2022/10/08/15:59 + * @Description: + */ +@RestController +@Slf4j +@RequestMapping(WeChatController.BASE_URL) +@Tag(name = WeChatController.TAG_NAME, description = WeChatController.TAG_DESCRIPTION) +public class WeChatController { + + protected static final String DATA_NAME = "授权"; + protected static final String BASE_URL = "/auth/wechat"; + protected static final String TAG_NAME = "Auth"; + protected static final String TAG_DESCRIPTION = DATA_NAME + "管理API"; + + + private final ObjectMapper objectMapper; + private final UserService userService; + private final AuthenticationManager authenticationManager; + + @Autowired + public WeChatController(ObjectMapper objectMapper, UserService userService, AuthenticationManager authenticationManager, BCryptPasswordEncoder encoder) { + this.objectMapper = objectMapper; + this.userService = userService; + this.authenticationManager = authenticationManager; + } + + + @GetMapping("/qrconnect") + @ResponseBody + @Operation(summary = "用户注册接口", description = "用户注册接口,用户注册以后会给用户发送一封邮件,邮件中包含了激活链接,用户点击激活链接以后,用户的账号才会被激活") + public String getWeChatLoginQR() throws JsonProcessingException { + log.debug("Get WeChat Login QR link"); + StringBuffer qrconnect = new StringBuffer(); + qrconnect.append("https://open.weixin.qq.com/connect/qrconnect?"); + qrconnect.append("appid=wx26e01c2be46730f3&"); + qrconnect.append("redirect_uri=https%3A%2F%2Fwww.usvisatrack.com%2Fwechat%2Fcallback&"); + qrconnect.append("response_type=code&"); + qrconnect.append("scope=snsapi_login&"); + qrconnect.append("state=" + UUID.randomUUID().toString() + "#wechat_redirect"); + + + https: +//open.weixin.qq.com/connect/qrconnect?appid=wxbdc5610cc59c1631&redirect_uri=https%3A%2F%2Fpassport.yhd.com%2Fwechat%2Fcallback.do&response_type=code&scope=snsapi_login&state=3d6be0a4035d839573b04816624a415e#wechat_redirect + + return qrconnect.toString(); + } + +}