Merge pull request #290 from PathfinderAx/master

[java]-[wechat-ferry-mvn]-适配SDK39.3.3版本
This commit is contained in:
Changhua 2024-12-23 20:49:11 +08:00 committed by GitHub
commit 01343d0c53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 915 additions and 251 deletions

View File

@ -0,0 +1,8 @@
## v39.3.3
### 2024-12-23
#### ⛰️ Features
- 适配SDK39.3.3版本
- wcf.proto文件部分字段类型修改

View File

@ -9,12 +9,13 @@
### 环境准备
| 名称 | 版本 | 备注 |
|-------|-----------|----|
| JDK | 1.8+ | √ |
| Maven | 3.8+ | √ |
| 微信 | 3.9.10.27 | √ |
| MySQL | 8.0+ | 备用 |
| 名称 | 版本 | 备注 |
|-----------------|-----------|----|
| JDK | 1.8+ | √ |
| Maven | 3.8+ | √ |
| 微信 | 3.9.11.25 | √ |
| WeChatFerry-SDK | 39.3.3 | √ |
| MySQL | 8.0+ | 备用 |
### 下载文件

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,28 +0,0 @@
package com.wechat.ferry.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
/**
* 配置类-配置错误页面转发首页
*
* @author chandler
* @date 2024-10-04 10:21
*/
@Slf4j
@Configuration
@Component
public class ErrorPageConfig implements ErrorPageRegistrar {
@Override
public void registerErrorPages(ErrorPageRegistry registry) {
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/index.html");
registry.addErrorPages(error404Page);
}
}

View File

@ -16,6 +16,7 @@ public class WxPpWcfSendEmojiMsgReq {
/**
* 资源路径-本地表情路径
* 需要确保图片路径正确建议使用绝对路径使用双斜杠\\
*/
@ApiModelProperty(value = "资源路径-本地表情路径")
private String resourcePath;

View File

@ -16,6 +16,7 @@ public class WxPpWcfSendImageMsgReq {
/**
* 资源路径-本地图片地址
* 需要确保图片路径正确建议使用绝对路径使用双斜杠\\
* `C:/Projs/WeChatRobot/TEQuant.jpeg`
* `https://raw.githubusercontent.com/lich0821/WeChatFerry/master/assets/TEQuant.jpg`
*/

View File

@ -0,0 +1,80 @@
package com.wechat.ferry.exception;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wechat.ferry.entity.IResponse;
import com.wechat.ferry.enums.ResponseCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 业务异常类
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class BizException extends RuntimeException {
/**
* 返回接口
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private final IResponse response;
/**
* 返回参数
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private transient Object[] arg;
/**
* 业务异常构造器
*
* @param msg 异常信息
* @date 2021/11/24 23:58
*/
public <T extends IResponse> BizException(String msg) {
super(msg);
this.response = ResponseCodeEnum.FAILED;
this.arg = null;
}
/**
* 业务异常构造器
*
* @param msg 异常信息
* @param args 异常参数
* @date 2021/11/24 23:58
*/
public <T extends IResponse> BizException(String msg, Object... args) {
super(msg);
this.response = ResponseCodeEnum.FAILED;
this.arg = args;
}
/**
* 业务异常构造器
*
* @param t 异常响应码
* @param args 异常参数
* @date 2021/11/24 23:59
*/
public <T extends IResponse> BizException(T t, Object... args) {
super(Arrays.toString(args));
this.response = t;
this.arg = args;
}
public <T extends IResponse> BizException(BizException e) {
this.response = e.getResponse();
this.arg = e.getArg();
}
public <T extends IResponse> BizException(ResponseCodeEnum t, String msg) {
super(msg);
this.response = t;
this.arg = null;
}
}

View File

@ -0,0 +1,79 @@
package com.wechat.ferry.exception;
import java.text.MessageFormat;
import javax.servlet.http.HttpServletRequest;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.wechat.ferry.entity.TResponse;
import com.wechat.ferry.enums.ResponseCodeEnum;
import lombok.extern.slf4j.Slf4j;
/**
* 全局统一异常
*
* @author Simith
* @date 2021/11/23 23:20
*/
@Slf4j
@Order(-1)
// 表示当前类为全局异常处理器
@RestControllerAdvice
public class GlobalExceptionHandler {
/**
* 通用异常-系统级别未知异常
*
* @param e 异常信息
* @return TResponse
* @author Simith
* @date 2021/11/23 23:22
*/
@ExceptionHandler(Exception.class)
public TResponse<Object> handleException(Exception e) {
log.error("全局异常信息 ex={}", e.getMessage(), e);
// 打印堆栈信息
e.printStackTrace();
String message = ResponseCodeEnum.FAILED.getMsg() + "" + e.getMessage();
return new TResponse<>(ResponseCodeEnum.FAILED, message);
}
/**
* 参数异常
*
* @author chandler
* @date 2023/4/3 23:26
* @param request 请求入参
* @param e 异常消息
* @return TResponse 返回体
*/
@ExceptionHandler(value = {MethodArgumentNotValidException.class})
public TResponse<Object> handleValidationException(HttpServletRequest request, MethodArgumentNotValidException e) {
log.error("[请求体参数校验不通过]", e);
String message = e.getBindingResult().getAllErrors().get(0).getDefaultMessage();
return new TResponse<>(ResponseCodeEnum.PARAM_ERROR, message);
}
/**
* 自定义错误异常
*
* @param e 异常信息
* @return TResponse
* @author Simith
* @date 2021/11/23 23:43
*/
@ExceptionHandler(BizException.class)
public TResponse<Object> handleBizException(BizException e) {
// 打印错误
e.printStackTrace();
// 获取错误码
String message = MessageFormat.format(e.getMessage(), e.getArg());
return new TResponse<>(ResponseCodeEnum.FAILED, message);
}
}

View File

@ -37,6 +37,7 @@ import lombok.extern.slf4j.Slf4j;
/**
* 处理层-微信客户端
* version39.3.3
*
* @author Changhua
* @date 2023-12-06 22:11
@ -334,6 +335,7 @@ public class WeChatSocketClient {
* @param receiver 消息接收者
* @return 发送结果状态码
*/
@Deprecated
public int sendEmotion(String path, String receiver) {
Wcf.PathMsg pathMsg = Wcf.PathMsg.newBuilder().setPath(path).setReceiver(receiver).build();
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_SEND_EMOTION_VALUE).setFile(pathMsg).build();

View File

@ -323,6 +323,7 @@ public class WeChatDllServiceImpl implements WeChatDllService {
}
vo.setGroupNickName(nickName);
vo.setState(String.valueOf(member.getState()));
// TODO 待补充
list.add(vo);
}
} catch (InvalidProtocolBufferException e) {
@ -384,6 +385,7 @@ public class WeChatDllServiceImpl implements WeChatDllService {
return null;
}
@Deprecated
@Override
public WxPpWcfSendEmojiMsgResp sendEmojiMsg(WxPpWcfSendEmojiMsgReq request) {
int state = wechatSocketClient.sendEmotion(request.getResourcePath(), request.getRecipient());

View File

@ -4,6 +4,7 @@ import java.util.Map;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

View File

@ -14,11 +14,6 @@ spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
# 打成jar包必须添加如下配置才能找到页面
thymeleaf:
mode: HTML
cache: false
prefix: classpath:/templates
# 日志配置
logging:

View File

@ -117,7 +117,7 @@ message XmlMsg
string receiver = 1; //
string content = 2; // xml
string path = 3; //
int32 type = 4; //
uint64 type = 4; //
}
message MsgTypes { map<int32, string> types = 1; }
@ -236,19 +236,22 @@ message ForwardMsg
}
// RoomData内部转换
message RoomData {
repeated RoomMember members = 1;
int32 field_2 = 2;
int32 field_3 = 3;
int32 field_4 = 4;
int32 room_capacity = 5;
int32 field_6 = 6;
int64 field_7 = 7;
int64 field_8 = 8;
message RoomData
{
message RoomMember {
string wxid = 1;
string name = 2;
int32 state = 3;
string wxid = 1;
optional string name = 2; //
int32 state = 3;
}
repeated RoomMember members = 1;
optional int32 field_2 = 2;
int32 field_3 = 3;
optional int32 field_4 = 4;
int32 capacity = 5;
optional string field_6 = 6;
int32 field_7 = 7;
int32 field_8 = 8;
repeated string admins = 9; //
}