USVT-132 配置一个新的 API Endpoint 让微信能够对平台进行校验
This commit is contained in:
parent
0e59b3179e
commit
ffe1bc81d6
|
@ -15,7 +15,9 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
|||
* @author Xie Yang
|
||||
* @date 2022/10/02
|
||||
*/
|
||||
@RestControllerAdvice(basePackages = {"com.northtecom.visatrack.api.controller.api", "com.northtecom.visatrack.api.controller"})
|
||||
@RestControllerAdvice(basePackages = {"com.northtecom.visatrack.api.controller.api",
|
||||
"com.northtecom.visatrack.api.controller.auth",
|
||||
"com.northtecom.visatrack.api.controller.vo"})
|
||||
public class AutoApiResponseBodyAdvice implements ResponseBodyAdvice {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package com.northtecom.visatrack.api.controller;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.northtecom.visatrack.api.model.request.auth.WeChatVerificationRequest;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/08/13:30
|
||||
* @Description:
|
||||
* HomeController Endpoint to check service running and wechat verification response
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
@ -19,7 +19,19 @@ public class HomeController {
|
|||
|
||||
@GetMapping("/index")
|
||||
public String index() {
|
||||
log.info("call index");
|
||||
return "Hello World 121221!"+System.currentTimeMillis();
|
||||
log.debug("Index Api Called");
|
||||
return "Welcome To check.visafn.com - " + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@GetMapping("/wechat/verification")
|
||||
@Operation(summary = "Wechat Verification API", description = "Make sure the calling to this API come from WeChat")
|
||||
public String weChatVerification(WeChatVerificationRequest weChatVerificationRequest) throws JsonProcessingException {
|
||||
log.debug("Doing WeChat Verification");
|
||||
log.debug("signature - [{}]", weChatVerificationRequest.getSignature());
|
||||
log.debug("timestamp - [{}]", weChatVerificationRequest.getTimestamp());
|
||||
log.debug("nonce - [{}]", weChatVerificationRequest.getNonce());
|
||||
|
||||
return weChatVerificationRequest.getEchostr();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.northtecom.visatrack.api.controller;
|
||||
package com.northtecom.visatrack.api.controller.auth;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
@ -16,7 +16,6 @@ import com.northtecom.visatrack.api.util.WeChatUtils;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -31,7 +30,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
|
@ -2,11 +2,13 @@ package com.northtecom.visatrack.api.controller.auth;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.northtecom.visatrack.api.controller.vo.BlogSearchVo;
|
||||
import com.northtecom.visatrack.api.controller.vo.UserLoginResponse;
|
||||
import com.northtecom.visatrack.api.controller.vo.VisaTrackUserDetail;
|
||||
import com.northtecom.visatrack.api.data.entity.User;
|
||||
import com.northtecom.visatrack.api.model.entity.wechat.WeChatUser;
|
||||
import com.northtecom.visatrack.api.model.request.auth.WeChatTokenizeRequest;
|
||||
import com.northtecom.visatrack.api.model.request.auth.WeChatVerificationRequest;
|
||||
import com.northtecom.visatrack.api.service.impl.UserService;
|
||||
import com.northtecom.visatrack.api.service.impl.WeChatService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -64,10 +66,12 @@ public class WeChatController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/qrconnect")
|
||||
@ResponseBody
|
||||
@Operation(summary = "用户注册接口", description = "用户注册接口,用户注册以后会给用户发送一封邮件,邮件中包含了激活链接,用户点击激活链接以后,用户的账号才会被激活")
|
||||
public String getWeChatLoginQR() throws JsonProcessingException {
|
||||
public String getWeChatLoginQR(BlogSearchVo blogSearchVo) throws JsonProcessingException {
|
||||
log.debug("Get WeChat Login QR link");
|
||||
StringBuffer qrconnect = new StringBuffer();
|
||||
qrconnect.append("https://open.weixin.qq.com/connect/qrconnect?");
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.northtecom.visatrack.api.model.request.auth;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.northtecom.visatrack.api.controller.vo.BlogSearchVo;
|
||||
import com.northtecom.visatrack.api.controller.vo.UserLoginResponse;
|
||||
import com.northtecom.visatrack.api.controller.vo.VisaTrackUserDetail;
|
||||
import com.northtecom.visatrack.api.data.entity.User;
|
||||
import com.northtecom.visatrack.api.model.entity.wechat.WeChatUser;
|
||||
import com.northtecom.visatrack.api.service.impl.UserService;
|
||||
import com.northtecom.visatrack.api.service.impl.WeChatService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WeChatVerificationRequest {
|
||||
|
||||
private String signature;
|
||||
private Long timestamp;
|
||||
private String nonce;
|
||||
private String echostr;
|
||||
}
|
Loading…
Reference in New Issue