Update WeChatMsgForwarderController.java

pull/1/head
wangsiyuan 2024-04-17 14:20:19 +08:00
parent c18e126dfd
commit f5d120817d
1 changed files with 11 additions and 1 deletions

View File

@ -22,18 +22,28 @@ public class WeChatMsgForwarderController {
this.handleWeChatMsgService = handleWeChatMsgService;
}
/**
*
*
* @param accessToken 访
* @param weChatMsg
* @return
*/
@PostMapping("/wechat")
public ServerResponseEntity receiveMsg(@RequestHeader("accessToken") String accessToken,
@RequestBody @Valid WeChatMsg weChatMsg){
@RequestBody @Valid WeChatMsg weChatMsg){
logger.info("weChatMsg: {}",weChatMsg.toString());
// 检查accessToken是否为空为空则返回错误信息
if(accessToken == null){
logger.warn("Access token is missing or empty");
return ServerResponseEntity.fail("accessToken cannot be empty.");
}
// 检查weChatMsg消息体是否有效无效则返回错误信息
if (weChatMsg.isInvalid()) {
logger.debug("CallInfo has invalid fields.");
return ServerResponseEntity.fail("json body value error.");
}
// 调用服务处理微信消息
return handleWeChatMsgService.handleMsg(accessToken,weChatMsg);
}
}