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(); + } + +}