Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* Python
* HTTP
* NodeJS
* Java

</details>

Expand All @@ -79,6 +80,7 @@ pip install --upgrade wcferry
* [wcf-http](https://github.com/yuxiaoli/wcf-http)(基于 Python)

### Java
* [SpringBoot版](https://github.com/PathfinderAx/WeChatFerry)(基于SpringBoot+Maven:`为避免代码冲突,请先至此仓库提交PR后统一合并至主仓库`)
* [java](clients/java/wcferry/README.MD)

### NodeJS
Expand Down
7 changes: 7 additions & 0 deletions clients/java/wcf-bmc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ ___

v39.5.2版本目前会出现注入失败的情况,待排查修复,可先使用v39.5.1,只须替换dll版本即可

### 2025-05-19

- 1.配置文件位置变更,方便大家自行配置
- 2.日志优化

<br/>

### 2025-05-04

- 1.更新拍一拍接口入参
Expand Down
12 changes: 11 additions & 1 deletion clients/java/wcf-bmc/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
`声明:` 本项目是基于 clients/java/wcferry 项目改造,随着时间推进,项目结构和代码规范逐渐产生分离,使用此项目的人员可参考之前的项目
我们在开发时请尽量保持注释的完整性,便于阅读维护

* [仓库地址:https://github.com/PathfinderAx/WeChatFerry](https://github.com/PathfinderAx/WeChatFerry)(基于SpringBoot+Maven:`为避免代码冲突,请先至此仓库提交PR后统一合并至主仓库`)


## 快速使用

### 环境准备
Expand Down Expand Up @@ -47,7 +50,9 @@

### 修改配置文件

配置文件:src/main/resources/application.yml
配置文件:
- src/main/resources/application.yml
- src/main/resources/config/application-dev.yml

根据自己的dll目录位置修改配置文件

Expand Down Expand Up @@ -122,6 +127,7 @@ wcf-bmc
├─config 配置文件目录
│ ├─application.yml 配置文件
│ ├─application-dev.yml 开发环境配置文件
│ └─logback-spring.xml 日志配置文件
├─wcf-bmc-xx.x.x.x.jar 打包后的源码包
Expand Down Expand Up @@ -261,6 +267,10 @@ message RoomData

```

### 开发约定

* 1.控制层仅处理数据操作,异常请在业务层进行抛出,系统会自动捕获并返回给前端

### 提交规范

本模块希望大家使用统一提交格式,便于区分
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public class WeChatFerryProperties {
*/
private Boolean sdkDebugSwitch = false;

/**
* 文件下载保存位置
*/
private String fileSavePath;

/**
* 联系人类型-官方杂号,禁止与其他分类重复(格式:代码|名称)
* 使用时记得需要提取代码或者名称匹配
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.wechat.ferry.controller;

import com.alibaba.fastjson2.JSONObject;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -15,7 +14,7 @@
import com.wechat.ferry.entity.vo.request.WxPpWcfDatabaseSqlReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfDatabaseTableReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfDeleteGroupMemberReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfDownloadAttachReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfFileSaveReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfGroupMemberReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfInviteGroupMemberReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfPassFriendApplyReq;
Expand Down Expand Up @@ -43,12 +42,10 @@
import com.wechat.ferry.entity.vo.response.WxPpWcfSendXmlMsgResp;
import com.wechat.ferry.enums.ResponseCodeEnum;
import com.wechat.ferry.service.WeChatDllService;
import com.wechat.ferry.utils.PathUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

/**
* 控制层-微信DLL处理
Expand Down Expand Up @@ -263,67 +260,36 @@ public TResponse<Object> receiveTransfer(@Validated @RequestBody WxPpWcfReceiveT
}

/**
* 下载视频 add by wmz 2025-05-01
* 文件保存至本机
*
* @param request
* @return
* @throws Exception
*/
@ApiOperation(value = "下载视频", notes = "download_video")
@PostMapping(value = "/download/video")
public TResponse<Object> downloadVideo(@Validated @RequestBody WxPpWcfDownloadAttachReq request) throws Exception {
String path = weChatDllService.downloadVideo(request);
if (path != null) {
JSONObject pathJson = new JSONObject();
pathJson.put("path", path);
return TResponse.ok(ResponseCodeEnum.SUCCESS, pathJson);
}
return TResponse.ok(ResponseCodeEnum.FAILED);
}

/**
* 下载图片 add by wmz 2025-05-02
* @param request 请求入参
* @return 保存到本机的路径
*
* @param request
* @return
* @throws Exception
* @author zm
* @date 2025-05-01
*/
@ApiOperation(value = "下载图片", notes = "download_picture")
@PostMapping(value = "/download/picture")
public TResponse<Object> downloadPicture(@Validated @RequestBody WxPpWcfDownloadAttachReq request) throws Exception {
//check parameter
String dir = request.getDir();
if (!StringUtils.hasText(dir)) {
log.info("需要指定图片的路径dir");
return TResponse.fail("需要指定图片的路径dir");
}
boolean res = PathUtils.createDir(dir);
if (!res) {
return TResponse.fail("图片路径创建失败" + dir);
}

String path = weChatDllService.downloadPicture(request);
if (path != null) {
JSONObject pathJson = new JSONObject();
pathJson.put("path", path);
return TResponse.ok(ResponseCodeEnum.SUCCESS, pathJson);
}
return TResponse.ok(ResponseCodeEnum.FAILED);
@ApiOperation(value = "文件保存至本机", notes = "fileSaveToLocal")
@PostMapping(value = "/file/saveToLocal")
public TResponse<String> fileSaveToLocal(@Validated @RequestBody WxPpWcfFileSaveReq request) {
String path = weChatDllService.fileSaveToLocal(request);
return TResponse.ok(ResponseCodeEnum.SUCCESS, path);
}

/**
* 暂未实现 add by mz 2025-05-01
* 暂未实现 TODO
*
* @param request
* @param request 请求入参
* @return
* @throws Exception
*
*
* @author zm
* @date 2025-05-01
*/
@ApiOperation(value = "登陆二维码", notes = "loginQR")
@PostMapping(value = "/loginQR")
public TResponse<Object> loginQR(@Validated @RequestBody WxPpWcfDownloadAttachReq request) throws Exception {
String path = weChatDllService.loginQR();
@ApiOperation(value = "登陆二维码", notes = "loginQrCode")
@PostMapping(value = "/loginQrCode")
public TResponse<Object> loginQrCode(@Validated @RequestBody WxPpWcfFileSaveReq request) {
String path = weChatDllService.loginQrCode();
return TResponse.ok(ResponseCodeEnum.SUCCESS, path);
}


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.wechat.ferry.entity.vo.request;

import javax.validation.constraints.NotBlank;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
* 请求入参-文件保存
*
* @author wmz
* @date 2025-05-02
*/
@Data
@ApiModel(value = "wxPpWcfFileSaveReq", description = "个微WCF文件保存请求入参")
public class WxPpWcfFileSaveReq {

/**
* 消息编号
*/
@NotBlank(message = "消息编号不能为空")
@ApiModelProperty(value = "消息编号")
private Long msgId;

/**
* 消息中的extra
*/
@ApiModelProperty(value = "extra")
private String extra;

/**
* 缩略图的链接
*/
@ApiModelProperty(value = "缩略图的链接")
private String thumbnailUrl;

/**
* 文件保存路径
*/
@ApiModelProperty(value = "文件保存路径")
private String savePath;

/**
* 文件类型后缀
* 如:.png
*/
@ApiModelProperty(value = "文件类型后缀")
private String fileType;

/**
* 超时时间(秒)
*/
@ApiModelProperty(value = "超时时间(秒)")
private Integer timeout = 30;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public class WxPpWcfRevokeMsgReq {
* 消息编号
*/
@ApiModelProperty(value = "消息编号")
private String msgId;
private Long msgId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Response sendCmd(Request req) {
// modify by wmz 2025-05-03
cmdSocket.setSendTimeout(5000);
cmdSocket.setReceiveTimeout(5000);

ByteBuffer bb = ByteBuffer.wrap(req.toByteArray());
cmdSocket.send(bb);
ByteBuffer ret = ByteBuffer.allocate(BUFFER_SIZE);
Expand Down Expand Up @@ -180,13 +180,14 @@ private void listenMsg(String url) {
*
* @return 是否登录结果
*/
public Response getQrcode() {
public int getQrcode() {
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_REFRESH_QRCODE_VALUE).build();
Response rsp = sendCmd(req);
int ret = -1;
if (rsp != null) {
return rsp;
ret = rsp.getStatus();
}
return null;
return ret;
}

/**
Expand Down Expand Up @@ -601,7 +602,7 @@ public int refreshPyq(Integer id) {
* @param extra 消息中的 extra
* @return 结果状态码 0 为成功,其他失败
*/
public int downloadAttach(Integer id, String thumb, String extra) {
public int downloadAttach(Long id, String thumb, String extra) {
int ret = -1;
Wcf.AttachMsg attachMsg = Wcf.AttachMsg.newBuilder().setId(id).setThumb(thumb).setExtra(extra).build();
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_DOWNLOAD_ATTACH_VALUE).setAtt(attachMsg).build();
Expand Down Expand Up @@ -638,7 +639,7 @@ public Wcf.RpcContact getInfoByWxId(String wxid) {
* @param id 待撤回消息的 id
* @return 结果状态码 0 为成功,其他失败
*/
public int revokeMsg(Integer id) {
public int revokeMsg(Long id) {
int ret = -1;
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_REVOKE_MSG_VALUE).setUi64(id).build();
Response rsp = sendCmd(req);
Expand All @@ -659,12 +660,10 @@ public int revokeMsg(Integer id) {
* @param src 加密的图片路径
* @param dir 保存图片的目录
* @return 解密图片的保存路径
* @see WeChatDllServiceImpl decryptImage
*/
@Deprecated
public String decryptImage(String src, String dir) {
Wcf.DecPath build = Wcf.DecPath.newBuilder().setSrc(src).setDst(dir).build();
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_DECRYPT_IMAGE_VALUE).setDec(build).build();
Wcf.DecPath decPath = Wcf.DecPath.newBuilder().setSrc(src).setDst(dir).build();
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_DECRYPT_IMAGE_VALUE).setDec(decPath).build();
Response rsp = sendCmd(req);
if (rsp != null) {
return rsp.getStr();
Expand Down
Loading