feat: [wcf-bmc]-目录名称变更为wcf-bmc
This commit is contained in:
1 parent
2cb758da01
commit
718051f020
102 files changed
+2
-3
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
package com.wechat.ferry;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 启动类
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-09-21 12:19
|
||||
*/
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class WeChatFerryApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WeChatFerryApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.wechat.ferry.aggregation.facade;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 聚合模型类-联系人
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2023-06-08 22:39:53
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ChatRoomDo {
|
||||
}
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
package com.wechat.ferry.aggregation.facade;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.wechat.ferry.config.WeChatFerryProperties;
|
||||
import com.wechat.ferry.entity.po.wcf.Contact;
|
||||
import com.wechat.ferry.entity.proto.Wcf;
|
||||
import com.wechat.ferry.enums.DatabaseNameEnum;
|
||||
import com.wechat.ferry.enums.WxContactsMixedEnum;
|
||||
import com.wechat.ferry.enums.WxContactsOfficialEnum;
|
||||
import com.wechat.ferry.enums.WxContactsTypeEnum;
|
||||
import com.wechat.ferry.handle.WeChatSocketClient;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 聚合模型类-联系人
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2023-06-08 22:39:53
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ContactDo extends Contact {
|
||||
|
||||
/**
|
||||
* 微信内部识别号UID
|
||||
*/
|
||||
@ApiModelProperty(value = "微信内部识别号UID")
|
||||
private String weChatUid;
|
||||
|
||||
/**
|
||||
* 联系人类型
|
||||
*/
|
||||
@ApiModelProperty(value = "联系人类型")
|
||||
private String contactType;
|
||||
|
||||
/**
|
||||
* 展示名称
|
||||
* 有备注优先展示备注
|
||||
*/
|
||||
@ApiModelProperty(value = "展示名称")
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 根据自定义SQL查询联系人列表
|
||||
*
|
||||
* @param wechatSocketClient 通信客户端
|
||||
* @param weChatFerryProperties 配置文件
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-27 16:06
|
||||
*/
|
||||
public List<ContactDo> queryContactListBySql(WeChatSocketClient wechatSocketClient, WeChatFerryProperties weChatFerryProperties) {
|
||||
List<ContactDo> list = new ArrayList<>();
|
||||
// 查询联系人
|
||||
List<Wcf.DbRow> dbContactList = wechatSocketClient.querySql(DatabaseNameEnum.MICRO_MSG.getCode(),
|
||||
"SELECT UserName, Alias, DelFlag, Type, VerifyFlag, Remark, NickName, LabelIDList, DomainList, ChatRoomType, PYInitial, QuanPin, RemarkPYInitial, RemarkQuanPin, ChatRoomNotify FROM Contact;");
|
||||
if (!CollectionUtils.isEmpty(dbContactList)) {
|
||||
for (Wcf.DbRow dbRow : dbContactList) {
|
||||
List<Wcf.DbField> dbFieldList = dbRow.getFieldsList();
|
||||
if (!ObjectUtils.isEmpty(dbFieldList)) {
|
||||
ContactDo po = new ContactDo();
|
||||
for (Wcf.DbField dbField : dbFieldList) {
|
||||
String content = (String)wechatSocketClient.convertSqlVal(dbField.getType(), dbField.getContent());
|
||||
// 用户名
|
||||
if ("UserName".equals(dbField.getColumn())) {
|
||||
po.setUserName(content);
|
||||
po.setWeChatUid(content);
|
||||
// 设置类型
|
||||
String type = convertContactType(content, weChatFerryProperties);
|
||||
po.setContactType(type);
|
||||
}
|
||||
// 用户名
|
||||
if ("Alias".equals(dbField.getColumn())) {
|
||||
po.setAlias(content);
|
||||
}
|
||||
// 昵称
|
||||
if ("NickName".equals(dbField.getColumn())) {
|
||||
po.setNickname(content);
|
||||
}
|
||||
// 删除标志
|
||||
if ("DelFlag".equals(dbField.getColumn())) {
|
||||
po.setDelFlag(Integer.valueOf(content));
|
||||
}
|
||||
//
|
||||
if ("VerifyFlag".equals(dbField.getColumn())) {
|
||||
po.setVerifyFlag(Integer.valueOf(content));
|
||||
}
|
||||
//
|
||||
if ("Remark".equals(dbField.getColumn())) {
|
||||
po.setRemark(content);
|
||||
}
|
||||
//
|
||||
if ("LabelIDList".equals(dbField.getColumn())) {
|
||||
po.setLabelIdList(content);
|
||||
}
|
||||
//
|
||||
if ("DomainList".equals(dbField.getColumn())) {
|
||||
po.setDomainList(content);
|
||||
}
|
||||
//
|
||||
if ("ChatRoomType".equals(dbField.getColumn())) {
|
||||
po.setChatRoomType(Integer.valueOf(content));
|
||||
}
|
||||
}
|
||||
list.add(po);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换联系人类型
|
||||
* 类型判断,存在优先级的,官方杂号优先级高于微信公众号(如果定义重复了,常规禁止重复,手机端和电脑端分类不同)
|
||||
*
|
||||
* @param weChatUid 微信识别号
|
||||
* @param weChatFerryProperties 配置文件
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-27 15:56
|
||||
*/
|
||||
public static String convertContactType(String weChatUid, WeChatFerryProperties weChatFerryProperties) {
|
||||
String type = "";
|
||||
// 官方杂号集合
|
||||
Map<String, String> mixedNoMap = WxContactsMixedEnum.toCodeNameMap();
|
||||
mixedNoMap.putAll(convertContactsTypeProperties(weChatFerryProperties.getContactsTypeMixed()));
|
||||
// 公众号
|
||||
Map<String, String> officialMap = WxContactsOfficialEnum.toCodeNameMap();
|
||||
officialMap.putAll(convertContactsTypeProperties(weChatFerryProperties.getContactsTypeOfficial()));
|
||||
|
||||
// 类型判断,存在优先级的,官方杂号优先级高于微信公众号(如果定义重复了,常规禁止重复,手机端和电脑端分类不同)
|
||||
if (weChatUid.endsWith(WxContactsTypeEnum.WORK.getAffix())) {
|
||||
// 企微
|
||||
type = WxContactsTypeEnum.WORK.getCode();
|
||||
} else if (weChatUid.endsWith(WxContactsTypeEnum.GROUP.getAffix()) || weChatUid.endsWith("@im.chatroom")) {
|
||||
// 群聊 @im.chatroom 这种是很早之前的格式,单独例举
|
||||
type = WxContactsTypeEnum.GROUP.getCode();
|
||||
} else if (mixedNoMap.containsKey(weChatUid)) {
|
||||
// 官方杂号
|
||||
type = WxContactsTypeEnum.OFFICIAL_MIXED_NO.getCode();
|
||||
} else if (weChatUid.startsWith(WxContactsTypeEnum.OFFICIAL_ACCOUNT.getAffix())) {
|
||||
// 微信公众号
|
||||
type = WxContactsTypeEnum.OFFICIAL_ACCOUNT.getCode();
|
||||
} else if (officialMap.containsKey(weChatUid)) {
|
||||
type = WxContactsTypeEnum.OFFICIAL_ACCOUNT.getCode();
|
||||
} else {
|
||||
// 个微
|
||||
type = WxContactsTypeEnum.PERSON.getCode();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换联系人类型配置
|
||||
*
|
||||
* @param list 配置参数
|
||||
* @return map key:code val:name
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-24 16:55
|
||||
*/
|
||||
public static Map<String, String> convertContactsTypeProperties(List<String> list) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (String str : list) {
|
||||
String key = str;
|
||||
String val = str;
|
||||
// 存在名称则分割
|
||||
if (str.contains("|")) {
|
||||
int index = str.indexOf("|");
|
||||
key = str.substring(0, index);
|
||||
val = str.substring(index + 1);
|
||||
}
|
||||
map.put(key, val);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.wechat.ferry.config;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* 配置类-protobuf
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-09-26 21:35
|
||||
*/
|
||||
@Configuration
|
||||
public class ProtobufConfig {
|
||||
|
||||
/**
|
||||
* protobuf 序列化
|
||||
*/
|
||||
@Bean
|
||||
ProtobufHttpMessageConverter protobufHttpMessageConverter() {
|
||||
return new ProtobufHttpMessageConverter();
|
||||
}
|
||||
|
||||
/**
|
||||
* protobuf 反序列化
|
||||
*/
|
||||
@Bean
|
||||
RestTemplate restTemplate(ProtobufHttpMessageConverter protobufHttpMessageConverter) {
|
||||
return new RestTemplate(Collections.singletonList(protobufHttpMessageConverter));
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.wechat.ferry.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
/**
|
||||
* 配置类-swagger
|
||||
* http://localhost:9201/swagger-ui/index.html
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-09-24 22:13
|
||||
*/
|
||||
@EnableOpenApi
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket api() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).select()
|
||||
// 替换为您的Controller所在的包路径
|
||||
.apis(RequestHandlerSelectors.basePackage("com.wechat.ferry.controller"))
|
||||
// 地址
|
||||
.paths(PathSelectors.any()).build().apiInfo(apiInfo());
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
// 文档标题
|
||||
.title("WeChatFerry接口文档")
|
||||
// 文档路径
|
||||
.description("微信机器人底层框架接口文档")
|
||||
// 文档版本
|
||||
.version("1.0.0").build();
|
||||
}
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package com.wechat.ferry.config;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.wechat.ferry.handle.WeChatSocketClient;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 配置类-注入微信客户端
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-09-30 12:21
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class WeChatConfiguration {
|
||||
|
||||
@Resource
|
||||
private WeChatFerryProperties properties;
|
||||
|
||||
@Resource
|
||||
private ServerProperties serverProperties;
|
||||
|
||||
@Bean
|
||||
public WeChatSocketClient weChatSocketClient() {
|
||||
log.debug("[读取配置文件]-端口:{},地址:{}", properties.getSocketPort(), properties.getDllPath());
|
||||
// 连接远程 RPC
|
||||
// Client client = new Client("127.0.0.1", 10086);
|
||||
|
||||
// 本地启动 RPC
|
||||
WeChatSocketClient wechatSocketClient =
|
||||
new WeChatSocketClient(properties.getSocketPort(), properties.getSdkDebugSwitch(), properties.getDllPath());
|
||||
|
||||
// 是否已登录
|
||||
// log.info("isLogin: {}", client.isLogin());
|
||||
|
||||
// 登录账号 wxid
|
||||
// log.info("wxid: {}", client.getSelfWxid());
|
||||
|
||||
// 消息类型
|
||||
// log.info("message types: {}", client.getMsgTypes());
|
||||
|
||||
// 所有联系人(包括群聊、公众号、好友……)
|
||||
// client.printContacts(client.getContacts());
|
||||
|
||||
// 获取数据库
|
||||
// log.info("dbs: {}", wechatSocketClient.getDbNames());
|
||||
|
||||
// 获取数据库下的表
|
||||
String db = "MicroMsg.db";
|
||||
// log.info("tables in {}: {}", db, client.getDbTables(db));
|
||||
|
||||
// 发送文本消息,aters 是要 @ 的 wxid,多个用逗号分隔;消息里@的数量要与aters里的数量对应
|
||||
// client.sendText("Hello", "filehelper", "");
|
||||
// client.sendText("Hello @某人1 @某人2", "xxxxxxxx@chatroom", "wxid_xxxxxxxxxxxxx1,wxid_xxxxxxxxxxxxx2");
|
||||
|
||||
// 发送图片消息,图片必须要存在
|
||||
// client.sendImage("C:\\Projs\\WeChatFerry\\TEQuant.jpeg", "filehelper");
|
||||
|
||||
// 发送文件消息,文件必须要存在
|
||||
// client.sendFile("C:\\Projs\\WeChatFerry\\README.MD", "filehelper");
|
||||
|
||||
String xml =
|
||||
"<?xml version=\"1.0\"?><msg><appmsg appid=\"\" sdkver=\"0\"><title>叮当药房,24小时服务,28分钟送药到家!</title><des>叮当快药首家承诺范围内28分钟送药到家!叮当快药核心区域内7*24小时全天候服务,送药上门!叮当快药官网为您提供快捷便利,正品低价,安全放心的购药、送药服务体验。</des><action>view</action><type>33</type><showtype>0</showtype><content /><url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxc2edadc87077fa2a&type=upgrade&upgradetype=3#wechat_redirect</url><dataurl /><lowurl /><lowdataurl /><recorditem /><thumburl /><messageaction /><md5>7f6f49d301ebf47100199b8a4fcf4de4</md5><extinfo /><sourceusername>gh_c2b88a38c424@app</sourceusername><sourcedisplayname>叮当快药 药店送药到家夜间买药</sourcedisplayname><commenturl /><appattach><totallen>0</totallen><attachid /><emoticonmd5></emoticonmd5><fileext>jpg</fileext><filekey>da0e08f5c7259d03da150d5e7ca6d950</filekey><cdnthumburl>3057020100044b30490201000204e4c0232702032f4ef20204a6bace6f02046401f62d042430326337303430352d333734332d343362652d623335322d6233333566623266376334620204012400030201000405004c537600</cdnthumburl><aeskey>0db26456caf243fbd4efb99058a01d66</aeskey><cdnthumbaeskey>0db26456caf243fbd4efb99058a01d66</cdnthumbaeskey><encryver>1</encryver><cdnthumblength>61558</cdnthumblength><cdnthumbheight>100</cdnthumbheight><cdnthumbwidth>100</cdnthumbwidth></appattach><weappinfo><pagepath>pages/index/index.html</pagepath><username>gh_c2b88a38c424@app</username><appid>wxc2edadc87077fa2a</appid><version>197</version><type>2</type><weappiconurl>http://wx.qlogo.cn/mmhead/Q3auHgzwzM4727n0NQ0ZIPQPlfp15m1WLsnrXbo1kLhFGcolgLyc0A/96</weappiconurl><appservicetype>0</appservicetype><shareId>1_wxc2edadc87077fa2a_29177e9a9b918cb9e75964f80bb8f32e_1677849476_0</shareId></weappinfo><websearch /></appmsg><fromusername>wxid_eob5qfcrv4zd22</fromusername><scene>0</scene><appinfo><version>1</version><appname /></appinfo><commenturl /></msg>";
|
||||
// client.sendXml("filehelper", xml, "", 0x21);
|
||||
|
||||
// 发送表情消息,gif 必须要存在
|
||||
// client.sendEmotion("C:\\Projs\\WeChatFerry\\emo.gif", "filehelper");
|
||||
|
||||
// 使用本机打印
|
||||
String url = "http://localhost:" + serverProperties.getPort() + "/wechat/msg/receive";
|
||||
// 接收消息,并调用 printWxMsg 处理
|
||||
wechatSocketClient.enableRecvMsg(100);
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
while (wechatSocketClient.getIsReceivingMsg()) {
|
||||
// 只打印
|
||||
// wechatSocketClient.printWxMsg(wechatSocketClient.getMsg());
|
||||
// 转发到boot项目进行消息处理
|
||||
wechatSocketClient.localCallbackAnalyzeMsg(wechatSocketClient.getMsg(), url);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
// client.diableRecvMsg(); // 需要停止时调用
|
||||
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
wechatSocketClient.keepRunning();
|
||||
}
|
||||
}).start();
|
||||
|
||||
return wechatSocketClient;
|
||||
}
|
||||
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.wechat.ferry.config;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 配置文件-WeChatFerry的配置文件
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-09-21 21:35
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "wechat.ferry")
|
||||
public class WeChatFerryProperties {
|
||||
|
||||
/**
|
||||
* dll文件位置
|
||||
*/
|
||||
private String dllPath;
|
||||
|
||||
/**
|
||||
* socket端口
|
||||
*/
|
||||
private Integer socketPort;
|
||||
|
||||
/**
|
||||
* SDK是否调试模式
|
||||
*/
|
||||
private Boolean sdkDebugSwitch = false;
|
||||
|
||||
/**
|
||||
* 联系人类型-官方杂号,禁止与其他分类重复(格式:代码|名称)
|
||||
* 使用时记得需要提取代码或者名称匹配
|
||||
*/
|
||||
private List<String> contactsTypeMixed;
|
||||
|
||||
/**
|
||||
* 联系人类型-公众号,禁止与其他分类重复(格式:代码|名称)
|
||||
* 使用时记得需要提取代码或者名称匹配
|
||||
*/
|
||||
private List<String> contactsTypeOfficial;
|
||||
|
||||
/**
|
||||
* 消息处理的群开关
|
||||
*/
|
||||
private Boolean openMsgGroupSwitch = false;
|
||||
|
||||
/**
|
||||
* 需要开启消息处理的群
|
||||
* 格式:key:群编号 val:开启的功能号,对应ReceiveMsgChannelEnum枚举中的code
|
||||
* 53257911728@chatroom: 1,2
|
||||
*/
|
||||
private Map<String, String> openMsgGroups;
|
||||
|
||||
/**
|
||||
* 接收消息回调开关
|
||||
*/
|
||||
private Boolean receiveMsgCallbackSwitch = false;
|
||||
|
||||
/**
|
||||
* 接收消息回调地址
|
||||
*/
|
||||
private List<String> receiveMsgCallbackUrls;
|
||||
|
||||
/**
|
||||
* 发送消息回调标识 1-关闭 2-全部回调 3-发送成功才回调
|
||||
*/
|
||||
private String sendMsgCallbackFlag = "1";
|
||||
|
||||
/**
|
||||
* 发送消息回调地址
|
||||
*/
|
||||
private List<String> sendMsgCallbackUrls;
|
||||
|
||||
/**
|
||||
* 调用第三方服务客户端成功状态码
|
||||
*/
|
||||
private Map<String, String> thirdPartyOkCodes;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.wechat.ferry.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 配置类-配置项目首页
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 10:30
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
// 将根路径 "/" 的请求重定向到 "/index.html"
|
||||
registry.addViewController("/").setViewName("forward:/index.html");
|
||||
WebMvcConfigurer.super.addViewControllers(registry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// 添加资源处理器,用于映射静态资源路径
|
||||
registry.addResourceHandler("/**")
|
||||
// 添加资路径
|
||||
.addResourceLocations("classpath:/templates/");
|
||||
WebMvcConfigurer.super.addResourceHandlers(registry);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
package com.wechat.ferry.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.wechat.ferry.entity.TResponse;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfAddFriendGroupMemberReq;
|
||||
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.WxPpWcfGroupMemberReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfInviteGroupMemberReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfPassFriendApplyReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfPatOnePatMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfReceiveTransferReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfRevokeMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendEmojiMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendFileMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendImageMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendRichTextMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendTextMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendXmlMsgReq;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfContactsResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfDatabaseRowResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfDatabaseTableResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfGroupMemberResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfLoginInfoResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfMsgTypeResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendEmojiMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendFileMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendImageMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendPatOnePatMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendRichTextMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendTextMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendXmlMsgResp;
|
||||
import com.wechat.ferry.enums.ResponseCodeEnum;
|
||||
import com.wechat.ferry.service.WeChatDllService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 控制层-微信DLL处理
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 15:48
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wechat/cgi/wcf")
|
||||
@Api(tags = "微信消息处理-接口")
|
||||
public class WeChatDllController {
|
||||
|
||||
private WeChatDllService weChatDllService;
|
||||
|
||||
@Autowired
|
||||
public void setWeChatDllService(WeChatDllService weChatDllService) {
|
||||
this.weChatDllService = weChatDllService;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询登录状态", notes = "loginStatus")
|
||||
@PostMapping(value = "/loginStatus")
|
||||
public TResponse<Object> loginStatus() {
|
||||
Boolean status = weChatDllService.loginStatus();
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, status);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取登录微信内部识别号UID", notes = "queryLoginWeChatUid")
|
||||
@PostMapping(value = "/loginWeChatUid")
|
||||
public TResponse<Object> queryLoginWeChatUid() {
|
||||
String weChatUid = weChatDllService.queryLoginWeChatUid();
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, weChatUid);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取登录微信信息", notes = "queryLoginWeChatInfo")
|
||||
@PostMapping(value = "/loginWeChatInfo")
|
||||
public TResponse<WxPpWcfLoginInfoResp> queryLoginWeChatInfo() {
|
||||
WxPpWcfLoginInfoResp resp = weChatDllService.queryLoginWeChatInfo();
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取消息类型列表", notes = "queryMsgTypeList")
|
||||
@PostMapping(value = "/list/msgType")
|
||||
public TResponse<List<WxPpWcfMsgTypeResp>> queryMsgTypeList() {
|
||||
List<WxPpWcfMsgTypeResp> list = weChatDllService.queryMsgTypeList();
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取联系人列表", notes = "queryContactsList")
|
||||
@PostMapping(value = "/list/contacts")
|
||||
public TResponse<List<WxPpWcfContactsResp>> queryContactsList() {
|
||||
List<WxPpWcfContactsResp> list = weChatDllService.queryContactsList();
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取数据库表名称列表", notes = "queryDbTableNameList")
|
||||
@PostMapping(value = "/list/dbTableName")
|
||||
public TResponse<List<String>> queryDbTableNameList() {
|
||||
List<String> list = weChatDllService.queryDbTableNameList();
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取指定数据库中的表列表", notes = "queryDbTableList")
|
||||
@PostMapping(value = "/list/dbTable")
|
||||
public TResponse<List<WxPpWcfDatabaseTableResp>> queryDbTableList(@Validated @RequestBody WxPpWcfDatabaseTableReq request) {
|
||||
List<WxPpWcfDatabaseTableResp> list = weChatDllService.queryDbTableList(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "执行数据库查询SQL", notes = "execDbQuerySql")
|
||||
@PostMapping(value = "/exec/dbQuerySql")
|
||||
public TResponse<List<WxPpWcfDatabaseRowResp>> execDbQuerySql(@Validated @RequestBody WxPpWcfDatabaseSqlReq request) {
|
||||
List<WxPpWcfDatabaseRowResp> list = weChatDllService.execDbQuerySql(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送消息汇总入口", notes = "sendMsgMaster")
|
||||
@PostMapping(value = "/send/msgMaster")
|
||||
public TResponse<WxPpWcfSendTextMsgResp> sendMsgMaster(@Validated @RequestBody String jsonString) {
|
||||
// todo
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送文本消息", notes = "sendTextMsg")
|
||||
@PostMapping(value = "/send/textMsg")
|
||||
public TResponse<WxPpWcfSendTextMsgResp> sendTextMsg(@Validated @RequestBody WxPpWcfSendTextMsgReq request) {
|
||||
WxPpWcfSendTextMsgResp resp = weChatDllService.sendTextMsg(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送富文本消息", notes = "sendRichTextMsg")
|
||||
@PostMapping(value = "/send/richTextMsg")
|
||||
public TResponse<WxPpWcfSendRichTextMsgResp> sendRichTextMsg(@Validated @RequestBody WxPpWcfSendRichTextMsgReq request) {
|
||||
WxPpWcfSendRichTextMsgResp resp = weChatDllService.sendRichTextMsg(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送XML消息", notes = "sendXmlMsg")
|
||||
@PostMapping(value = "/send/xmlMsg")
|
||||
public TResponse<WxPpWcfSendXmlMsgResp> sendXmlMsg(@Validated @RequestBody WxPpWcfSendXmlMsgReq request) {
|
||||
WxPpWcfSendXmlMsgResp resp = weChatDllService.sendXmlMsg(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送图片消息", notes = "sendImageMsg")
|
||||
@PostMapping(value = "/send/imageMsg")
|
||||
public TResponse<WxPpWcfSendImageMsgResp> sendImageMsg(@Validated @RequestBody WxPpWcfSendImageMsgReq request) {
|
||||
WxPpWcfSendImageMsgResp resp = weChatDllService.sendImageMsg(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送表情消息", notes = "sendEmojiMsg")
|
||||
@PostMapping(value = "/send/emojiMsg")
|
||||
public TResponse<WxPpWcfSendEmojiMsgResp> sendEmojiMsg(@Validated @RequestBody WxPpWcfSendEmojiMsgReq request) {
|
||||
WxPpWcfSendEmojiMsgResp resp = weChatDllService.sendEmojiMsg(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送文件消息", notes = "sendFileMsg")
|
||||
@PostMapping(value = "/send/fileMsg")
|
||||
public TResponse<WxPpWcfSendFileMsgResp> sendFileMsg(@Validated @RequestBody WxPpWcfSendFileMsgReq request) {
|
||||
WxPpWcfSendFileMsgResp resp = weChatDllService.sendFileMsg(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "拍一拍群友", notes = "patOnePat")
|
||||
@PostMapping(value = "/patOnePat")
|
||||
public TResponse<WxPpWcfSendPatOnePatMsgResp> patOnePat(@Validated @RequestBody WxPpWcfPatOnePatMsgReq request) {
|
||||
WxPpWcfSendPatOnePatMsgResp resp = weChatDllService.patOnePat(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "获取语音消息", notes = "queryMsgTypeList")
|
||||
// @PostMapping(value = "/list/voiceMsg")
|
||||
// public TResponse<Object> queryVoiceMsg() {
|
||||
// return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
// }
|
||||
|
||||
@ApiOperation(value = "撤回消息", notes = "revokeMsg")
|
||||
@PostMapping(value = "/revokeMsg")
|
||||
public TResponse<Object> revokeMsg(@Validated @RequestBody WxPpWcfRevokeMsgReq request) {
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "转发消息", notes = "queryMsgTypeList")
|
||||
// @PostMapping(value = "/list/msgType")
|
||||
// public TResponse<Object> queryMsgTypeList() {
|
||||
// return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "开启接收消息", notes = "queryMsgTypeList")
|
||||
// @PostMapping(value = "/list/msgType")
|
||||
// public TResponse<Object> queryMsgTypeList() {
|
||||
// return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "关闭接收消息", notes = "queryMsgTypeList")
|
||||
// @PostMapping(value = "/list/msgType")
|
||||
// public TResponse<Object> queryMsgTypeList() {
|
||||
// return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
// }
|
||||
//
|
||||
|
||||
@ApiOperation(value = "通过好友申请", notes = "passFriendApply")
|
||||
@PostMapping(value = "/passFriendApply")
|
||||
public TResponse<Object> passFriendApply(@Validated @RequestBody WxPpWcfPassFriendApplyReq request) {
|
||||
weChatDllService.passFriendApply(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加群成员为微信好友", notes = "addFriendGroupMember")
|
||||
@PostMapping(value = "/addFriend/groupMember")
|
||||
public TResponse<Object> addFriendGroupMember(@Validated @RequestBody WxPpWcfAddFriendGroupMemberReq request) {
|
||||
weChatDllService.addFriendGroupMember(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询群成员列表", notes = "queryGroupMemberList")
|
||||
@PostMapping(value = "/groupMember/list")
|
||||
public TResponse<List<WxPpWcfGroupMemberResp>> queryGroupMemberList(@Validated @RequestBody WxPpWcfGroupMemberReq request) {
|
||||
List<WxPpWcfGroupMemberResp> list = weChatDllService.queryGroupMemberList(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "邀请群成员", notes = "inviteGroupMember")
|
||||
@PostMapping(value = "/groupMember/invite")
|
||||
public TResponse<Object> inviteGroupMember(@Validated @RequestBody WxPpWcfInviteGroupMemberReq request) {
|
||||
weChatDllService.inviteGroupMember(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除群成员", notes = "deleteGroupMember")
|
||||
@PostMapping(value = "/groupMember/delete")
|
||||
public TResponse<Object> deleteGroupMember(@Validated @RequestBody WxPpWcfDeleteGroupMemberReq request) {
|
||||
weChatDllService.deleteGroupMember(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询朋友圈", notes = "queryFriendCircle")
|
||||
@PostMapping(value = "/friendCircle")
|
||||
public TResponse<Object> queryFriendCircle() {
|
||||
weChatDllService.queryFriendCircle();
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收转账", notes = "receiveTransfer")
|
||||
@PostMapping(value = "/receiveTransfer")
|
||||
public TResponse<Object> receiveTransfer(@Validated @RequestBody WxPpWcfReceiveTransferReq request) {
|
||||
weChatDllService.receiveTransfer(request);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "下载图片、视频、文件", notes = "queryMsgTypeList")
|
||||
// @PostMapping(value = "/list/msgType")
|
||||
// public TResponse<Object> queryMsgTypeList() {
|
||||
// return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "解密图片", notes = "queryMsgTypeList")
|
||||
// @PostMapping(value = "/list/msgType")
|
||||
// public TResponse<Object> queryMsgTypeList() {
|
||||
// return TResponse.ok(ResponseCodeEnum.SUCCESS, list);
|
||||
// }
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.wechat.ferry.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.wechat.ferry.entity.TResponse;
|
||||
import com.wechat.ferry.enums.ResponseCodeEnum;
|
||||
import com.wechat.ferry.service.WeChatMsgService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 控制层-微信消息处理
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 14:25
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wechat/msg")
|
||||
@Api(tags = "微信消息处理-接口")
|
||||
public class WeChatMsgController {
|
||||
|
||||
private WeChatMsgService weChatMsgService;
|
||||
|
||||
@Autowired
|
||||
public void setWeChatMsgService(WeChatMsgService weChatMsgService) {
|
||||
this.weChatMsgService = weChatMsgService;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收微信消息", notes = "receiveMsg")
|
||||
@PostMapping(value = "/receive")
|
||||
public TResponse<Object> receiveMsg(@RequestBody String jsonString) {
|
||||
weChatMsgService.receiveMsg(jsonString);
|
||||
return TResponse.ok(ResponseCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.wechat.ferry.entity;
|
||||
|
||||
/**
|
||||
* 返回类接口
|
||||
*/
|
||||
public interface IResponse {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
String getCode();
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
String getMsg();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.wechat.ferry.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.wechat.ferry.enums.ResponseCodeEnum;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 返回类封装
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class TResponse<T> {
|
||||
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
@ApiModelProperty(value = "状态码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
@ApiModelProperty(value = "返回信息")
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 响应时间
|
||||
*/
|
||||
@ApiModelProperty(value = "响应时间")
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 响应数据
|
||||
*/
|
||||
@ApiModelProperty(value = "响应数据")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* 返回类
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2023/4/5 11:31
|
||||
* @param t 返回码类
|
||||
* @param data 返回数据
|
||||
* @return TResponse对象
|
||||
*/
|
||||
public TResponse(IResponse t, T data) {
|
||||
this(t);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回类
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2023/4/5 11:31
|
||||
* @param t 返回码类
|
||||
* @param msg 返回信息
|
||||
* @return TResponse对象
|
||||
*/
|
||||
public TResponse(IResponse t, String msg) {
|
||||
this.code = t.getCode();
|
||||
this.msg = msg;
|
||||
this.time = LocalDateTime.now().format(FORMATTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回类
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2023/4/5 11:31
|
||||
* @param t 返回码类
|
||||
* @param msg 返回信息
|
||||
* @return TResponse对象
|
||||
*/
|
||||
public TResponse(IResponse t, T data, String msg) {
|
||||
this(t, data);
|
||||
// 重写返回信息-替换默认的信息
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public TResponse(IResponse t) {
|
||||
this.code = t.getCode();
|
||||
this.msg = t.getMsg();
|
||||
this.time = LocalDateTime.now().format(FORMATTER);
|
||||
}
|
||||
|
||||
public static <T> TResponse<T> ok(IResponse t) {
|
||||
return new TResponse<>(t);
|
||||
}
|
||||
|
||||
public static <T> TResponse<T> ok(IResponse t, T data) {
|
||||
return new TResponse<>(t, data);
|
||||
}
|
||||
|
||||
public static <T> TResponse<T> fail(String msg) {
|
||||
return new TResponse<>(ResponseCodeEnum.FAILED, msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package com.wechat.ferry.entity.dto;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* DTO-个微信消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-09-26 19:56
|
||||
*/
|
||||
@Data
|
||||
public class WxPpMsgDTO {
|
||||
|
||||
/**
|
||||
* 是否自己发送的
|
||||
*/
|
||||
@ApiModelProperty(value = "是否自己发送的")
|
||||
private Boolean isSelf;
|
||||
|
||||
/**
|
||||
* 是否群消息
|
||||
*/
|
||||
@ApiModelProperty(value = "是否群消息")
|
||||
private Boolean isGroup;
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
@ApiModelProperty(value = "消息id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@ApiModelProperty(value = "消息类型")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@ApiModelProperty(value = "消息类型")
|
||||
private Integer ts;
|
||||
|
||||
/**
|
||||
* 群id(如果是群消息的话)
|
||||
*/
|
||||
@ApiModelProperty(value = "群id(如果是群消息的话)")
|
||||
private String roomId;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
@ApiModelProperty(value = "消息内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 转为JSON的内容
|
||||
* 对应DLL中的content原始内容
|
||||
*/
|
||||
@ApiModelProperty(value = "转为JSON的内容")
|
||||
private JSONObject jsonContent;
|
||||
|
||||
/**
|
||||
* 引用内容
|
||||
* 对应DLL中的content原始内容
|
||||
*/
|
||||
@JsonIgnore
|
||||
@ApiModelProperty(value = "消息内容XML")
|
||||
private String quoteContent;
|
||||
|
||||
/**
|
||||
* 消息发送者
|
||||
*/
|
||||
@ApiModelProperty(value = "消息发送者")
|
||||
private String sender;
|
||||
|
||||
/**
|
||||
* 签名
|
||||
*/
|
||||
@ApiModelProperty(value = "签名")
|
||||
private String sign;
|
||||
|
||||
/**
|
||||
* 缩略图
|
||||
*/
|
||||
@ApiModelProperty(value = "缩略图")
|
||||
private String thumb;
|
||||
|
||||
/**
|
||||
* 附加内容
|
||||
*/
|
||||
@ApiModelProperty(value = "附加内容")
|
||||
private String extra;
|
||||
|
||||
/**
|
||||
* 消息xml
|
||||
*/
|
||||
@ApiModelProperty(value = "消息xml")
|
||||
private String xml;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.wechat.ferry.entity.po.wcf;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 实体类-群信息表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-27 10:01
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "ChatRoom", description = "群信息表")
|
||||
public class ChatRoom {
|
||||
|
||||
/**
|
||||
* 群名称
|
||||
*/
|
||||
@ApiModelProperty(value = "群名称")
|
||||
private String chatRoomName;
|
||||
|
||||
/**
|
||||
* 用户名称列表
|
||||
*/
|
||||
@ApiModelProperty(value = "用户名称列表")
|
||||
private String userNameList;
|
||||
|
||||
/**
|
||||
* 显示名称列表
|
||||
*/
|
||||
@ApiModelProperty(value = "显示名称列表")
|
||||
private String displayNameList;
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.wechat.ferry.entity.po.wcf;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 实体类-群详细信息表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-27 10:03
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "ChatRoomInfo", description = "群详细信息表")
|
||||
public class ChatRoomInfo {
|
||||
|
||||
/**
|
||||
* 群名称
|
||||
*/
|
||||
@ApiModelProperty(value = "群名称")
|
||||
private String chatRoomName;
|
||||
|
||||
/**
|
||||
* 群公告
|
||||
*/
|
||||
@ApiModelProperty(value = "群公告")
|
||||
private String announcement;
|
||||
|
||||
/**
|
||||
* 公告编辑者
|
||||
*/
|
||||
@ApiModelProperty(value = "公告编辑者")
|
||||
private String announcementEditor;
|
||||
|
||||
/**
|
||||
* 公告发布时间
|
||||
*/
|
||||
@ApiModelProperty(value = "公告发布时间")
|
||||
private String announcementPublishTime;
|
||||
|
||||
/**
|
||||
* 群状态
|
||||
*/
|
||||
@ApiModelProperty(value = "群状态")
|
||||
private Integer chatRoomStatus;
|
||||
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.wechat.ferry.entity.po.wcf;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 实体类-联系人表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-27 09:47
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "Contact对象", description = "联系人表")
|
||||
public class Contact {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 别名
|
||||
*/
|
||||
@ApiModelProperty(value = "别名")
|
||||
private String alias;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@ApiModelProperty(value = "昵称")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 删除标志
|
||||
*/
|
||||
@ApiModelProperty(value = "删除标志")
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 验证标志
|
||||
*/
|
||||
@ApiModelProperty(value = "验证标志")
|
||||
private Integer verifyFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 标签ID列表
|
||||
*/
|
||||
@ApiModelProperty(value = "标签ID列表")
|
||||
private String labelIdList;
|
||||
|
||||
/**
|
||||
* 域名列表
|
||||
*/
|
||||
@ApiModelProperty(value = "域名列表")
|
||||
private String domainList;
|
||||
|
||||
/**
|
||||
* 群类型
|
||||
*/
|
||||
@ApiModelProperty(value = "群类型")
|
||||
private Integer chatRoomType;
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.wechat.ferry.entity.po.wcf;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 实体类-联系人头像信息表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-27 09:59
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "ContactHeadImgUrl对象", description = "联系人头像信息表")
|
||||
public class ContactHeadImgUrl {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 小头像URL
|
||||
*/
|
||||
@ApiModelProperty(value = "小头像URL")
|
||||
private String smallHeadIngUrl;
|
||||
|
||||
/**
|
||||
* 大头像URL
|
||||
*/
|
||||
@ApiModelProperty(value = "大头像URL")
|
||||
private String bigHeadIngUrl;
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.wechat.ferry.entity.po.wcf;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 实体类-撤回消息存储表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-27 10:08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "RevokeMsgStorage对象", description = "撤回消息存储表")
|
||||
public class RevokeMsgStorage {
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Integer createTime;
|
||||
|
||||
/**
|
||||
* 消息服务ID
|
||||
*/
|
||||
@ApiModelProperty(value = "消息服务ID")
|
||||
private Integer msgSvrId;
|
||||
|
||||
/**
|
||||
* 撤回服务ID
|
||||
*/
|
||||
@ApiModelProperty(value = "撤回服务ID")
|
||||
private Integer revokeSvrId;
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
+3
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请求入参-添加群成员为好友
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 09:53
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfAddFriendGroupMemberReq", description = "个微WCF添加群成员为好友请求入参")
|
||||
public class WxPpWcfAddFriendGroupMemberReq {
|
||||
|
||||
/**
|
||||
* 群编号
|
||||
*/
|
||||
@NotBlank(message = "群编号不能为空")
|
||||
@ApiModelProperty(value = "群编号")
|
||||
private String groupNo;
|
||||
|
||||
/**
|
||||
* 待添加的群成员列表
|
||||
*/
|
||||
@ApiModelProperty(value = "待添加的群成员列表")
|
||||
private List<String> groupMembers;
|
||||
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求入参-查询-个微WCF数据库SQL查询
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 17:10
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfDatabaseSqlReq", description = "个微WCF数据库SQL查询请求入参")
|
||||
public class WxPpWcfDatabaseSqlReq {
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@NotBlank(message = "数据库名称不能为空")
|
||||
@ApiModelProperty(value = "数据库名称")
|
||||
private String databaseName;
|
||||
|
||||
/**
|
||||
* SQL语句
|
||||
*/
|
||||
@NotBlank(message = "SQL语句不能为空")
|
||||
@ApiModelProperty(value = "SQL语句")
|
||||
private String sqlText;
|
||||
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求入参-查询-个微WCF数据库表查询
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 17:55
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfDatabaseTableReq", description = "个微WCF数据库表查询请求入参")
|
||||
public class WxPpWcfDatabaseTableReq {
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@NotBlank(message = "数据库名称不能为空")
|
||||
@ApiModelProperty(value = "数据库名称")
|
||||
private String databaseName;
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.wechat.ferry.entity.vo.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF删除群成员
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 10:01
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfDeleteGroupMemberReq", description = "个微WCF删除群成员请求入参")
|
||||
public class WxPpWcfDeleteGroupMemberReq {
|
||||
|
||||
/**
|
||||
* 群编号
|
||||
*/
|
||||
@NotBlank(message = "群编号不能为空")
|
||||
@ApiModelProperty(value = "群编号")
|
||||
private String groupNo;
|
||||
|
||||
/**
|
||||
* 待删除的群成员列表
|
||||
*/
|
||||
@ApiModelProperty(value = "待删除的群成员列表")
|
||||
private List<String> groupMembers;
|
||||
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF查询群成员
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 20:55
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfGroupMemberReq", description = "个微WCF查询群成员请求入参")
|
||||
public class WxPpWcfGroupMemberReq {
|
||||
|
||||
/**
|
||||
* 群编号
|
||||
*/
|
||||
@NotBlank(message = "群编号不能为空")
|
||||
@ApiModelProperty(value = "群编号")
|
||||
private String groupNo;
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.wechat.ferry.entity.vo.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF邀请群成员
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 09:51
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfInviteGroupMemberReq", description = "个微WCF邀请群成员请求入参")
|
||||
public class WxPpWcfInviteGroupMemberReq {
|
||||
|
||||
/**
|
||||
* 群编号
|
||||
*/
|
||||
@NotBlank(message = "群编号不能为空")
|
||||
@ApiModelProperty(value = "群编号")
|
||||
private String groupNo;
|
||||
|
||||
/**
|
||||
* 待邀请的群成员列表
|
||||
*/
|
||||
@ApiModelProperty(value = "待邀请的群成员列表")
|
||||
private List<String> groupMembers;
|
||||
|
||||
}
|
||||
clients/java/wcf-bmc/src/main/java/com/wechat/ferry/entity/vo/request/WxPpWcfPassFriendApplyReq.java
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
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 chandler
|
||||
* @date 2024-12-25 09:30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfPassFriendApplyReq", description = "个微WCF通过好友申请请求入参")
|
||||
public class WxPpWcfPassFriendApplyReq {
|
||||
|
||||
/**
|
||||
* 申请人
|
||||
* v3 xml.attrib["encryptusername"]
|
||||
* 加密用户名 (好友申请消息里 v3 开头的字符串)
|
||||
*/
|
||||
@NotBlank(message = "申请人不能为空")
|
||||
@ApiModelProperty(value = "申请人")
|
||||
private String applicant;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
* v4 xml.attrib["ticket"]
|
||||
* Ticket (好友申请消息里 v4 开头的字符串)
|
||||
* 一般指自己,别人申请添加,自己审核是否通过
|
||||
*/
|
||||
@NotBlank(message = "审核人不能为空")
|
||||
@ApiModelProperty(value = "审核人")
|
||||
private String reviewer;
|
||||
|
||||
/**
|
||||
* 场景
|
||||
* 申请方式 (好友申请消息里的 scene); 为了兼容旧接口,默认为扫码添加 (30)
|
||||
*/
|
||||
@ApiModelProperty(value = "场景")
|
||||
private String scene;
|
||||
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF发送拍一拍消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-06 15:50
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfPatOnePatMsgReq", description = "个微WCF发送拍一拍消息请求入参")
|
||||
public class WxPpWcfPatOnePatMsgReq {
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@NotBlank(message = "消息接收人不能为空")
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
/**
|
||||
* 要拍的人的wxid
|
||||
*/
|
||||
@NotBlank(message = "要拍的人的wxid不能为空")
|
||||
@ApiModelProperty(value = "要拍的人的wxid")
|
||||
private String patUser;
|
||||
|
||||
}
|
||||
clients/java/wcf-bmc/src/main/java/com/wechat/ferry/entity/vo/request/WxPpWcfReceiveTransferReq.java
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
package com.wechat.ferry.entity.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF接收转账
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 13:46
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfReceiveTransferReq", description = "个微WCF接收转账请求入参")
|
||||
public class WxPpWcfReceiveTransferReq {
|
||||
|
||||
/**
|
||||
* 转账人
|
||||
*/
|
||||
@ApiModelProperty(value = "转账人")
|
||||
private String weChatUid;
|
||||
|
||||
/**
|
||||
* 转账编号 transferId
|
||||
*/
|
||||
@ApiModelProperty(value = "转账编号")
|
||||
private String transferId;
|
||||
|
||||
/**
|
||||
* 交易编号 Transaction id
|
||||
*/
|
||||
@ApiModelProperty(value = "交易编号")
|
||||
private String transactionId;
|
||||
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
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 chandler
|
||||
* @date 2024-12-25 12:00
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfRevokeMsgReq", description = "个微WCF撤回消息请求入参")
|
||||
public class WxPpWcfRevokeMsgReq {
|
||||
|
||||
/**
|
||||
* 消息编号
|
||||
*/
|
||||
@ApiModelProperty(value = "场景")
|
||||
private String msgId;
|
||||
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF发送表情消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 23:14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendEmojiMsgReq", description = "个微WCF发送表情消息请求入参")
|
||||
public class WxPpWcfSendEmojiMsgReq {
|
||||
|
||||
/**
|
||||
* 资源路径-本地表情路径
|
||||
* 需要确保图片路径正确,建议使用绝对路径(使用双斜杠\\)
|
||||
*/
|
||||
@NotBlank(message = "资源路径不能为空")
|
||||
@ApiModelProperty(value = "资源路径-本地表情路径")
|
||||
private String resourcePath;
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@NotBlank(message = "消息接收人不能为空")
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF发送文件消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 23:08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendFileMsgReq", description = "个微WCF发送文件消息请求入参")
|
||||
public class WxPpWcfSendFileMsgReq {
|
||||
|
||||
/**
|
||||
* 资源路径-本地文件路径
|
||||
*/
|
||||
@NotBlank(message = "资源路径不能为空")
|
||||
@ApiModelProperty(value = "资源路径-本地文件路径")
|
||||
private String resourcePath;
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@NotBlank(message = "消息接收人不能为空")
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
}
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF发送图片消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 15:55
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendImageMsgReq", description = "个微WCF发送图片消息请求入参")
|
||||
public class WxPpWcfSendImageMsgReq {
|
||||
|
||||
/**
|
||||
* 资源路径-本地图片地址
|
||||
* 需要确保图片路径正确,建议使用绝对路径(使用双斜杠\\)
|
||||
* 如:`C:/Projs/WeChatRobot/TEQuant.jpeg`
|
||||
* 或 `https://raw.githubusercontent.com/lich0821/WeChatFerry/master/assets/TEQuant.jpg`
|
||||
*/
|
||||
@NotBlank(message = "资源路径不能为空")
|
||||
@ApiModelProperty(value = "资源路径-本地图片地址")
|
||||
private String resourcePath;
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@NotBlank(message = "消息接收人不能为空")
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
}
|
||||
clients/java/wcf-bmc/src/main/java/com/wechat/ferry/entity/vo/request/WxPpWcfSendRichTextMsgReq.java
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
package com.wechat.ferry.entity.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF发送富文本消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-06 15:40
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendRichTextMsgReq", description = "个微WCF发送富文本消息请求入参")
|
||||
public class WxPpWcfSendRichTextMsgReq {
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@NotBlank(message = "消息接收人不能为空")
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
/**
|
||||
* 左下显示的名字
|
||||
*/
|
||||
@ApiModelProperty(value = "左下显示的名字")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 填公众号id 可以显示对应的头像(gh_ 开头的)
|
||||
*/
|
||||
@ApiModelProperty(value = "资源路径-封面图片路径")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 标题,最多两行
|
||||
*/
|
||||
@ApiModelProperty(value = "标题,最多两行")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 摘要,三行
|
||||
*/
|
||||
@ApiModelProperty(value = "摘要,三行")
|
||||
private String digest;
|
||||
|
||||
/**
|
||||
* 点击后跳转的链接
|
||||
*/
|
||||
@ApiModelProperty(value = "点击后跳转的链接")
|
||||
private String jumpUrl;
|
||||
|
||||
/**
|
||||
* 缩略图的链接
|
||||
*/
|
||||
@ApiModelProperty(value = "缩略图的链接")
|
||||
private String thumbnailUrl;
|
||||
|
||||
}
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
package com.wechat.ferry.entity.vo.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF发送文本消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 20:33
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendTextMsgReq", description = "个微WCF发送文本消息请求入参")
|
||||
public class WxPpWcfSendTextMsgReq {
|
||||
|
||||
/**
|
||||
* 消息文本
|
||||
* 消息内容(如果是 @ 消息则需要有跟 @ 的人数量相同的 @)
|
||||
* 换行使用 `\\\\n` (单杠)
|
||||
*/
|
||||
@NotBlank(message = "消息文本不能为空")
|
||||
@ApiModelProperty(value = "消息文本")
|
||||
private String msgText;
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@NotBlank(message = "消息接收人不能为空")
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
/**
|
||||
* 要艾特的用户
|
||||
* 群聊时要 @ 的人(私聊时为空字符串),多个用逗号分隔。
|
||||
* 艾特所有人用 notify@all(必须是群主或者管理员才有权限)
|
||||
*/
|
||||
@ApiModelProperty(value = "要艾特的用户")
|
||||
private List<String> atUsers;
|
||||
|
||||
/**
|
||||
* 是否艾特全体
|
||||
* 默认为false
|
||||
*/
|
||||
@ApiModelProperty(value = "是否艾特全体")
|
||||
private Boolean isAtAll = false;
|
||||
|
||||
}
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
package com.wechat.ferry.entity.vo.request;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求入参-个微WCF发送XML消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 23:11
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendXmlMsgReq", description = "个微WCF发送XML消息请求入参")
|
||||
public class WxPpWcfSendXmlMsgReq {
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@NotBlank(message = "消息接收人不能为空")
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
/**
|
||||
* XML报文内容
|
||||
*/
|
||||
@NotBlank(message = "XML报文内容不能为空")
|
||||
@ApiModelProperty(value = "XML报文内容")
|
||||
private String xmlContent;
|
||||
|
||||
/**
|
||||
* 资源路径-封面图片路径
|
||||
*/
|
||||
@ApiModelProperty(value = "资源路径-封面图片路径")
|
||||
private String resourcePath;
|
||||
|
||||
/**
|
||||
* XML类型,如:21 为小程序
|
||||
*/
|
||||
@NotNull(message = "XML类型不能为空")
|
||||
@ApiModelProperty(value = "XML类型")
|
||||
private String xmlType;
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
Vendored
+102
@@ -0,0 +1,102 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF联系人
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/02 17:01
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfContactsResp", description = "个微WCF联系人查询请求出参")
|
||||
public class WxPpWcfContactsResp {
|
||||
|
||||
/**
|
||||
* 微信内部识别号UID
|
||||
* 原始微信账号ID,以"wxid_"开头,初始默认的微信ID=微信号。
|
||||
*/
|
||||
@ApiModelProperty(value = "微信内部识别号UID")
|
||||
private String weChatUid;
|
||||
|
||||
/**
|
||||
* 微信号
|
||||
*/
|
||||
@ApiModelProperty(value = "微信号")
|
||||
private String weChatNo;
|
||||
|
||||
/**
|
||||
* 微信昵称
|
||||
*/
|
||||
@ApiModelProperty(value = "微信昵称")
|
||||
private String weChatNickname;
|
||||
|
||||
/**
|
||||
* 联系人备注
|
||||
*/
|
||||
@ApiModelProperty(value = "联系人备注")
|
||||
private String weChatRemark;
|
||||
|
||||
/**
|
||||
* 国家
|
||||
*/
|
||||
@ApiModelProperty(value = "国家")
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* 国家拼音
|
||||
*/
|
||||
@ApiModelProperty(value = "国家拼音")
|
||||
private String countryPinyin;
|
||||
|
||||
/**
|
||||
* 省/州
|
||||
*/
|
||||
@ApiModelProperty(value = "省/州")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 省/州拼音
|
||||
*/
|
||||
@ApiModelProperty(value = "省/州拼音")
|
||||
private String provincePinyin;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
@ApiModelProperty(value = "城市")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 城市拼音
|
||||
*/
|
||||
@ApiModelProperty(value = "城市拼音")
|
||||
private String cityPinyin;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@ApiModelProperty(value = "性别")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 性别-翻译
|
||||
*/
|
||||
@ApiModelProperty(value = "性别-翻译")
|
||||
private String sexLabel;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@ApiModelProperty(value = "类型")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 类型-翻译
|
||||
*/
|
||||
@ApiModelProperty(value = "类型-翻译")
|
||||
private String typeLabel;
|
||||
|
||||
}
|
||||
clients/java/wcf-bmc/src/main/java/com/wechat/ferry/entity/vo/response/WxPpWcfDatabaseFieldResp.java
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF数据库字段
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/02 17:15
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfDatabaseFieldResp", description = "个微WCF数据库字段查询请求出参")
|
||||
public class WxPpWcfDatabaseFieldResp {
|
||||
|
||||
/**
|
||||
* 字段类型
|
||||
*/
|
||||
@ApiModelProperty(value = "字段类型")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字段
|
||||
*/
|
||||
@ApiModelProperty(value = "字段")
|
||||
private String column;
|
||||
|
||||
/**
|
||||
* 字段值
|
||||
*/
|
||||
@ApiModelProperty(value = "字段值")
|
||||
private Object value;
|
||||
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF数据库记录
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/02 17:14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfDatabaseRowResp", description = "个微WCF数据库记录查询请求出参")
|
||||
public class WxPpWcfDatabaseRowResp {
|
||||
|
||||
/**
|
||||
* 字段列表
|
||||
*/
|
||||
@ApiModelProperty(value = "字段列表")
|
||||
private List<WxPpWcfDatabaseFieldResp> fieldList;
|
||||
|
||||
}
|
||||
clients/java/wcf-bmc/src/main/java/com/wechat/ferry/entity/vo/response/WxPpWcfDatabaseTableResp.java
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF数据库表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/12/24 13:40
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfDatabaseRowResp", description = "个微WCF数据库表查询请求出参")
|
||||
public class WxPpWcfDatabaseTableResp {
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@ApiModelProperty(value = "表名")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* SQL
|
||||
*/
|
||||
@ApiModelProperty(value = "SQL")
|
||||
private String sql;
|
||||
|
||||
}
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF查询群成员
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/01 21:26
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfGroupMemberResp", description = "个微WCF群成员查询请求出参")
|
||||
public class WxPpWcfGroupMemberResp {
|
||||
|
||||
/**
|
||||
* 微信内部识别号UID
|
||||
* 原始微信账号ID,以"wxid_"开头,初始默认的微信ID=微信号。
|
||||
*/
|
||||
@ApiModelProperty(value = "微信内部识别号UID")
|
||||
private String weChatUid;
|
||||
|
||||
/**
|
||||
* 群内昵称
|
||||
*/
|
||||
@ApiModelProperty(value = "群内昵称")
|
||||
private String groupNickName;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 是否自己
|
||||
*/
|
||||
@ApiModelProperty(value = "是否自己")
|
||||
private Boolean whetherSelf;
|
||||
|
||||
/**
|
||||
* 是否企微
|
||||
*/
|
||||
@ApiModelProperty(value = "是否企微")
|
||||
private Boolean whetherWork;
|
||||
|
||||
}
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-登录WCF个微信息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/05 22:53
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfLoginInfoResp", description = "登录WCF个微信息查询请求出参")
|
||||
public class WxPpWcfLoginInfoResp {
|
||||
|
||||
/**
|
||||
* 微信内部识别号UID
|
||||
* 原始微信账号ID,以"wxid_"开头,初始默认的微信ID=微信号。
|
||||
*/
|
||||
@ApiModelProperty(value = "微信内部识别号UID")
|
||||
private String weChatUid;
|
||||
|
||||
/**
|
||||
* 微信昵称
|
||||
*/
|
||||
@ApiModelProperty(value = "微信昵称")
|
||||
private String weChatNickname;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 文件/图片等父路径
|
||||
*/
|
||||
@ApiModelProperty(value = "文件/图片等父路径")
|
||||
private String homePath;
|
||||
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF消息类型
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/01 21:26
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfMsgTypeResp", description = "个微WCF消息类型查询请求出参")
|
||||
public class WxPpWcfMsgTypeResp {
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
@ApiModelProperty(value = "类型编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF发送GIF消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/04 23:13
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendEmojiMsgResp", description = "个微WCF发送GIF消息请求出参")
|
||||
public class WxPpWcfSendEmojiMsgResp {
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
@ApiModelProperty(value = "类型编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF发送文件消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/04 23:07
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendFileMsgResp", description = "个微WCF发送文件消息请求出参")
|
||||
public class WxPpWcfSendFileMsgResp {
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
@ApiModelProperty(value = "类型编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF发送图像消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/03 10:17
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendImageMsgResp", description = "个微WCF发送图像消息请求出参")
|
||||
public class WxPpWcfSendImageMsgResp {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
@ApiModelProperty(value = "状态码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
@ApiModelProperty(value = "返回信息")
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
@ApiModelProperty(value = "图片地址")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 消息接收人
|
||||
* 消息接收人,私聊为 wxid(wxid_xxxxxxxxxxxxxx)
|
||||
* 群聊为 roomid(xxxxxxxxxx@chatroom)
|
||||
*/
|
||||
@ApiModelProperty(value = "消息接收人")
|
||||
private String recipient;
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF发送拍一拍消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/06 15:52
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendPatOnePatMsgResp", description = "个微WCF发送拍一拍消息请求出参")
|
||||
public class WxPpWcfSendPatOnePatMsgResp {
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
@ApiModelProperty(value = "类型编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF发送富文本消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/06 15:46
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendRichTextMsgResp", description = "个微WCF发送富文本消息请求出参")
|
||||
public class WxPpWcfSendRichTextMsgResp {
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
@ApiModelProperty(value = "类型编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF发送文本消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/03 10:17
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendTextMsgResp", description = "个微WCF发送文本消息请求出参")
|
||||
public class WxPpWcfSendTextMsgResp {
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
@ApiModelProperty(value = "类型编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.entity.vo.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求出参-个微WCF发送XML消息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/04 23:11
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "wxPpWcfSendXmlMsgResp", description = "个微WCF发送XML消息请求出参")
|
||||
public class WxPpWcfSendXmlMsgResp {
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
@ApiModelProperty(value = "类型编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-数据库名称
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/12/24 15:10
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DatabaseNameEnum {
|
||||
|
||||
/**
|
||||
* MicroMsg-
|
||||
*/
|
||||
MICRO_MSG("MicroMsg.db", ""),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, DatabaseNameEnum> codeMap = Arrays.stream(values()).collect(Collectors.toMap(DatabaseNameEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static DatabaseNameEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-消息回调开关
|
||||
* 1-关闭 2-全部回调 3-发送成功才回调
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/01 15:42
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum MsgCallbackTypeEnum {
|
||||
|
||||
/**
|
||||
* 1-关闭
|
||||
*/
|
||||
CLOSE("1", "关闭"),
|
||||
|
||||
/**
|
||||
* 2-全部回调
|
||||
*/
|
||||
ALL("2", "全部回调"),
|
||||
|
||||
/**
|
||||
* 3-发送成功才回调
|
||||
*/
|
||||
SUCCESS("3", "发送成功才回调"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, MsgCallbackTypeEnum> codeMap =
|
||||
Arrays.stream(values()).collect(Collectors.toMap(MsgCallbackTypeEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static MsgCallbackTypeEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-消息事件类型
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/12/27 18:09
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum MsgEventTypeEnum {
|
||||
|
||||
/**
|
||||
* 1-注入成功
|
||||
*/
|
||||
INJECT("1", "注入成功"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, MsgEventTypeEnum> codeMap = Arrays.stream(values()).collect(Collectors.toMap(MsgEventTypeEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static MsgEventTypeEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-接收消息处理渠道
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/12/25 14:15
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ReceiveMsgChannelEnum {
|
||||
|
||||
/**
|
||||
* 1-签到
|
||||
*/
|
||||
SIGN_IN("1", "签到"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, ReceiveMsgChannelEnum> codeMap =
|
||||
Arrays.stream(values()).collect(Collectors.toMap(ReceiveMsgChannelEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static ReceiveMsgChannelEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import com.wechat.ferry.entity.IResponse;
|
||||
|
||||
/**
|
||||
* 枚举-返回类状态码
|
||||
*/
|
||||
public enum ResponseCodeEnum implements IResponse {
|
||||
|
||||
/**
|
||||
* 成功-200
|
||||
*/
|
||||
SUCCESS("200", "请求成功"),
|
||||
|
||||
/**
|
||||
* 参数错误-400
|
||||
*/
|
||||
PARAM_ERROR("400", "参数错误"),
|
||||
|
||||
/**
|
||||
* 401-身份验证失败
|
||||
*/
|
||||
NO_AUTH("401", "身份验证失败"),
|
||||
|
||||
/**
|
||||
* 403-您无权访问此资源
|
||||
*/
|
||||
UNAUTHORIZED("403", "您无权访问此资源"),
|
||||
|
||||
/**
|
||||
* 404-未找到该资源
|
||||
*/
|
||||
NOT_FOUND("404", "未找到该资源"),
|
||||
|
||||
/**
|
||||
* 失败-500
|
||||
*/
|
||||
FAILED("500", "请求失败"),
|
||||
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String msg;
|
||||
|
||||
ResponseCodeEnum(String code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name() + "{" + code + '|' + msg + "}";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-性别
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/01 15:42
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SexEnum {
|
||||
|
||||
/**
|
||||
* 0-未知
|
||||
*/
|
||||
UNKNOWN("0", "未知"),
|
||||
|
||||
/**
|
||||
* 1-男
|
||||
*/
|
||||
BOY("1", "男"),
|
||||
|
||||
/**
|
||||
* 2-女
|
||||
*/
|
||||
GIRL("2", "女"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, SexEnum> codeMap = Arrays.stream(values()).collect(Collectors.toMap(SexEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static SexEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-表名称
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/12/24 15:24
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TableNameEnum {
|
||||
|
||||
/**
|
||||
* CONTACT-联系人
|
||||
*/
|
||||
CONTACT("Contact", "联系人", ""),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null, ""),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
private final String db;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, TableNameEnum> codeMap = Arrays.stream(values()).collect(Collectors.toMap(TableNameEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static TableNameEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-WCF消息类型
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/01 15:55
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WcfMsgTypeEnum {
|
||||
|
||||
/**
|
||||
* 0-朋友圈消息
|
||||
*/
|
||||
FRIEND_CIRCLE_MSG("0", "朋友圈消息"),
|
||||
|
||||
/**
|
||||
* 1-文字
|
||||
*/
|
||||
TEXT("1", "文字"),
|
||||
|
||||
/**
|
||||
* 3-图片
|
||||
*/
|
||||
PICTURE("3", "图片"),
|
||||
|
||||
/**
|
||||
* 34-语音
|
||||
*/
|
||||
VOICE("34", "语音"),
|
||||
|
||||
/**
|
||||
* 37-好友确认
|
||||
*/
|
||||
FRIEND_CONFIRM("37", "好友确认"),
|
||||
|
||||
/**
|
||||
* 40-可能认识的朋友消息-POSSIBLEFRIEND_MSG
|
||||
*/
|
||||
POSSIBLE_FRIEND_MSG("40", "可能认识的朋友"),
|
||||
|
||||
/**
|
||||
* 42-名片
|
||||
*/
|
||||
VISITING_CARD("42", "名片"),
|
||||
|
||||
/**
|
||||
* 43-视频
|
||||
*/
|
||||
VIDEO("43", "视频"),
|
||||
|
||||
/**
|
||||
* 47-石头剪刀布 | 表情图片
|
||||
*/
|
||||
EMOJI_IMAGE("47", "石头剪刀布 | 表情图片"),
|
||||
|
||||
/**
|
||||
* 48-位置
|
||||
*/
|
||||
POSITION("48", "位置"),
|
||||
|
||||
/**
|
||||
* 49-共享实时位置、文件、转账、链接
|
||||
*/
|
||||
SHARE("49", "共享实时位置、文件、转账、链接"),
|
||||
|
||||
/**
|
||||
* 50-语音电话消息-VOIPMSG
|
||||
*/
|
||||
VOIP_MSG("50", "语音电话消息"),
|
||||
|
||||
/**
|
||||
* 51-微信初始化
|
||||
*/
|
||||
WECHAT_INIT("51", "微信初始化"),
|
||||
|
||||
/**
|
||||
* 52-语音电话通知-VOIPNOTIFY
|
||||
*/
|
||||
VOIP_NOTIFY("52", "语音电话通知"),
|
||||
|
||||
/**
|
||||
* 53-语音电话邀请-VOIPINVITE
|
||||
*/
|
||||
VOIP_INVITE("53", "语音电话邀请"),
|
||||
|
||||
/**
|
||||
* 62-小视频
|
||||
*/
|
||||
SMALL_VIDEO("62", "小视频"),
|
||||
|
||||
/**
|
||||
* 66-微信红包
|
||||
*/
|
||||
WECHAT_RED_ENVELOPE("66", "微信红包"),
|
||||
|
||||
/**
|
||||
* 9999-系统通知-SYSNOTICE
|
||||
*/
|
||||
SYS_NOTICE("9999", "系统通知"),
|
||||
|
||||
/**
|
||||
* 10000-红包、系统消息
|
||||
*/
|
||||
RED_ENVELOPE_SYS_NOTICE("10000", "红包、系统消息"),
|
||||
|
||||
/**
|
||||
* 10002-撤回消息
|
||||
*/
|
||||
WITHDRAW_MSG("10002", "撤回消息"),
|
||||
|
||||
/**
|
||||
* 1048625-搜狗表情
|
||||
*/
|
||||
SO_GOU_EMOJI("1048625", "搜狗表情"),
|
||||
|
||||
/**
|
||||
* 16777265-链接
|
||||
*/
|
||||
LINK("16777265", "链接"),
|
||||
|
||||
/**
|
||||
* 436207665-微信红包
|
||||
*/
|
||||
RED_ENVELOPE("436207665", "微信红包"),
|
||||
|
||||
/**
|
||||
* 536936497-红包封面
|
||||
*/
|
||||
RED_ENVELOPE_COVER("536936497", "红包封面"),
|
||||
|
||||
/**
|
||||
* 754974769-视频号视频
|
||||
*/
|
||||
VIDEO_NUMBER_VIDEO("754974769", "视频号视频"),
|
||||
|
||||
/**
|
||||
* 771751985-视频号名片
|
||||
*/
|
||||
VIDEO_NUMBER_CARD("771751985", "视频号名片"),
|
||||
|
||||
/**
|
||||
* 822083633-引用消息
|
||||
*/
|
||||
QUOTE_MSG("822083633", "引用消息"),
|
||||
|
||||
/**
|
||||
* 922746929-拍一拍
|
||||
*/
|
||||
PAT_ONE_PAT("922746929", "拍一拍"),
|
||||
|
||||
/**
|
||||
* 973078577-视频号直播
|
||||
*/
|
||||
VIDEO_NUMBER_LIVE("973078577", "视频号直播"),
|
||||
|
||||
/**
|
||||
* 974127153-商品链接
|
||||
*/
|
||||
PRODUCT_LINK("974127153", "商品链接"),
|
||||
|
||||
/**
|
||||
* 975175729-视频号直播-TODO
|
||||
*/
|
||||
UNKNOWN("975175729", "视频号直播"),
|
||||
|
||||
/**
|
||||
* 1040187441-音乐链接
|
||||
*/
|
||||
MUSIC_LINK("1040187441", "音乐链接"),
|
||||
|
||||
/**
|
||||
* 1090519089-文件
|
||||
*/
|
||||
FILE("1090519089", "文件"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-是否
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2023/3/14 10:21
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WhetherEnum {
|
||||
|
||||
/**
|
||||
* 1-Y-是
|
||||
*/
|
||||
YES("1", "是", "Y", true),
|
||||
|
||||
/**
|
||||
* 2-N-否
|
||||
*/
|
||||
NO("2", "否", "N", false),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null, null, null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
private final String key;
|
||||
private final Boolean bool;
|
||||
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-微信联系人-官方杂号
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/12/24 16:01
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WxContactsMixedEnum {
|
||||
|
||||
/**
|
||||
* fmessage-朋友推荐消息
|
||||
*/
|
||||
F_MESSAGE("fmessage", "朋友推荐消息"),
|
||||
|
||||
/**
|
||||
* medianote-语音记事本
|
||||
*/
|
||||
MEDIA_NOTE("medianote", "语音记事本"),
|
||||
|
||||
/**
|
||||
* floatbottle-漂流瓶
|
||||
*/
|
||||
FLOAT_BOTTLE("floatbottle", "漂流瓶"),
|
||||
|
||||
/**
|
||||
* filehelper-文件传输助手
|
||||
*/
|
||||
FILE_HELPER("filehelper", "文件传输助手"),
|
||||
|
||||
/**
|
||||
* newsapp-新闻
|
||||
*/
|
||||
NEWS_APP("newsapp", "新闻"),
|
||||
|
||||
/**
|
||||
* newsapp-微信团队
|
||||
*/
|
||||
WEI_XIN("weixin", "微信团队"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, WxContactsMixedEnum> codeMap =
|
||||
Arrays.stream(values()).collect(Collectors.toMap(WxContactsMixedEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static WxContactsMixedEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* map集合 key:code val:名称
|
||||
*/
|
||||
public static Map<String, String> toCodeNameMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (WxContactsMixedEnum val : WxContactsMixedEnum.values()) {
|
||||
if (!ObjectUtils.isEmpty(val.getCode())) {
|
||||
map.put(val.getCode(), val.getName());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-微信联系人-公众号
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/12/24 16:36
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WxContactsOfficialEnum {
|
||||
|
||||
/**
|
||||
* wxid_2876568766325-应用宝-yingyongbao
|
||||
*/
|
||||
YING_YONG_BAO("wxid_2876568766325", "应用宝"),
|
||||
|
||||
/**
|
||||
* wxid_2965349653612-i黑马-iheima
|
||||
*/
|
||||
I_HEI_MA("wxid_2965349653612", "i黑马"),
|
||||
|
||||
/**
|
||||
* wxid_4302923029011-丁香医生-DingXiangYiSheng
|
||||
*/
|
||||
DING_XIANG_YI_SHENG("wxid_4302923029011", "丁香医生"),
|
||||
|
||||
/**
|
||||
* mphelper-公众平台安全助手
|
||||
*/
|
||||
MP_HELPER("mphelper", "公众平台安全助手"),
|
||||
|
||||
/**
|
||||
* weixinguanhaozhushou-微信公众平台-weixingongzhong
|
||||
*/
|
||||
WEI_XIN_GONG_ZHONG("weixinguanhaozhushou", "微信公众平台"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, WxContactsOfficialEnum> codeMap =
|
||||
Arrays.stream(values()).collect(Collectors.toMap(WxContactsOfficialEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static WxContactsOfficialEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* map集合 key:code val:名称
|
||||
*/
|
||||
public static Map<String, String> toCodeNameMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (WxContactsOfficialEnum val : WxContactsOfficialEnum.values()) {
|
||||
if (!ObjectUtils.isEmpty(val.getCode())) {
|
||||
map.put(val.getCode(), val.getName());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-微信联系人类型
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/02 18:35
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WxContactsTypeEnum {
|
||||
|
||||
/**
|
||||
* 1-个微
|
||||
*/
|
||||
PERSON("1", "个微", ""),
|
||||
|
||||
/**
|
||||
* 2-企微
|
||||
*/
|
||||
WORK("2", "企微", "@openim"),
|
||||
|
||||
/**
|
||||
* 3-群组
|
||||
*/
|
||||
GROUP("3", "群组", "@chatroom"),
|
||||
|
||||
/**
|
||||
* 4-官方杂号
|
||||
*/
|
||||
OFFICIAL_MIXED_NO("4", "官方杂号", null),
|
||||
|
||||
/**
|
||||
* 5-公众号
|
||||
*/
|
||||
OFFICIAL_ACCOUNT("5", "公众号", "gh_"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null, null),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
private final String affix;
|
||||
|
||||
/**
|
||||
* map集合 key:code val:枚举
|
||||
*/
|
||||
public static final Map<String, WxContactsTypeEnum> codeMap =
|
||||
Arrays.stream(values()).collect(Collectors.toMap(WxContactsTypeEnum::getCode, v -> v));
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static WxContactsTypeEnum getCodeMap(String code) {
|
||||
return codeMap.getOrDefault(code, UN_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.wechat.ferry.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举-本服务定义消息类型
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024/10/01 15:55
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WxPpMsgTypeEnum {
|
||||
|
||||
/**
|
||||
* 0-未知
|
||||
*/
|
||||
UNKNOWN("0", "未知", "文本"),
|
||||
|
||||
/**
|
||||
* 1-文本
|
||||
*/
|
||||
TEXT("1", "文本", "文本"),
|
||||
|
||||
/**
|
||||
* 2-表情符号
|
||||
*/
|
||||
EMOJI("2", "表情符号", "1"),
|
||||
|
||||
/**
|
||||
* 3-表情包(表情图片)
|
||||
*/
|
||||
EMOJI_IMAGE("3", "表情包(表情图片)", "47"),
|
||||
|
||||
/**
|
||||
* 4-引用消息
|
||||
*/
|
||||
QUOTE("4", "引用消息", "49"),
|
||||
|
||||
/**
|
||||
* 未匹配上
|
||||
*/
|
||||
UN_MATCH("", null, "文本"),
|
||||
|
||||
// 结束
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
private final String dllCode;
|
||||
|
||||
}
|
||||
+80
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+434
@@ -0,0 +1,434 @@
|
||||
package com.wechat.ferry.handle;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.sun.jna.Native;
|
||||
import com.wechat.ferry.entity.dto.WxPpMsgDTO;
|
||||
import com.wechat.ferry.entity.proto.Wcf.DbQuery;
|
||||
import com.wechat.ferry.entity.proto.Wcf.DbRow;
|
||||
import com.wechat.ferry.entity.proto.Wcf.DecPath;
|
||||
import com.wechat.ferry.entity.proto.Wcf.Functions;
|
||||
import com.wechat.ferry.entity.proto.Wcf.Request;
|
||||
import com.wechat.ferry.entity.proto.Wcf.Response;
|
||||
import com.wechat.ferry.entity.proto.Wcf.WxMsg;
|
||||
import com.wechat.ferry.exception.BizException;
|
||||
import com.wechat.ferry.service.SDK;
|
||||
import com.wechat.ferry.utils.HttpClientUtil;
|
||||
import com.wechat.ferry.utils.XmlJsonConvertUtil;
|
||||
|
||||
import io.sisu.nng.Socket;
|
||||
import io.sisu.nng.pair.Pair1Socket;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 处理层-微信客户端
|
||||
*
|
||||
* @author Changhua
|
||||
* @date 2023-12-06 22:11
|
||||
*/
|
||||
@Slf4j
|
||||
public class WeChatSocketClient {
|
||||
|
||||
/**
|
||||
* 消息缓冲区大小,16M
|
||||
*/
|
||||
private static final Integer BUFFER_SIZE = 16 * 1024 * 1024;
|
||||
|
||||
/**
|
||||
* 默认IP
|
||||
*/
|
||||
private static final String DEFAULT_HOST = "127.0.0.1";
|
||||
|
||||
/**
|
||||
* 请求地址
|
||||
*/
|
||||
private static final String CMD_URL = "tcp://%s:%s";
|
||||
|
||||
private Socket cmdSocket = null;
|
||||
private Socket msgSocket = null;
|
||||
|
||||
/**
|
||||
* 是否收到消息
|
||||
*/
|
||||
private boolean isReceivingMsg = false;
|
||||
|
||||
/**
|
||||
* 是否为本地端口
|
||||
*/
|
||||
private boolean isLocalHostPort = false;
|
||||
|
||||
/**
|
||||
* 消息返回
|
||||
*/
|
||||
private BlockingQueue<WxMsg> msgQ;
|
||||
|
||||
private final String host;
|
||||
|
||||
private final Integer port;
|
||||
|
||||
public WeChatSocketClient(Integer port, String dllPath) {
|
||||
this(DEFAULT_HOST, port, false, dllPath);
|
||||
}
|
||||
|
||||
public WeChatSocketClient(Integer port, boolean debug, String dllPath) {
|
||||
this(DEFAULT_HOST, port, debug, dllPath);
|
||||
}
|
||||
|
||||
public WeChatSocketClient(String host, Integer port, boolean debug, String dllPath) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
|
||||
SDK INSTANCE = Native.load(dllPath, SDK.class);
|
||||
int status = INSTANCE.WxInitSDK(debug, port);
|
||||
if (status != 0) {
|
||||
log.error("启动 RPC 失败: {}", status);
|
||||
System.exit(-1);
|
||||
}
|
||||
connectRPC(String.format(CMD_URL, host, port), INSTANCE);
|
||||
if (DEFAULT_HOST.equals(host) || "localhost".equalsIgnoreCase(host)) {
|
||||
isLocalHostPort = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void connectRPC(String url, SDK INSTANCE) {
|
||||
try {
|
||||
cmdSocket = new Pair1Socket();
|
||||
cmdSocket.dial(url);
|
||||
while (!isLogin()) {
|
||||
// 直到登录成功
|
||||
waitMs(1000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("连接 RPC 失败: ", e);
|
||||
System.exit(-1);
|
||||
}
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
log.info("关闭...");
|
||||
diableRecvMsg();
|
||||
if (isLocalHostPort) {
|
||||
INSTANCE.WxDestroySDK();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public Response sendCmd(Request req) {
|
||||
try {
|
||||
// 设置发送 20 秒超时
|
||||
cmdSocket.setSendTimeout(20000);
|
||||
ByteBuffer bb = ByteBuffer.wrap(req.toByteArray());
|
||||
cmdSocket.send(bb);
|
||||
ByteBuffer ret = ByteBuffer.allocate(BUFFER_SIZE);
|
||||
long size = cmdSocket.receive(ret, true);
|
||||
return Response.parseFrom(Arrays.copyOfRange(ret.array(), 0, (int)size));
|
||||
} catch (Exception e) {
|
||||
if ("Timed out".equals(e.getMessage())) {
|
||||
log.error("请求超时: ", e);
|
||||
throw new BizException("请求超时:1.接口耗时太长,2.服务与客户端失去联系,请重启本服务!详细异常信息:" + e.getMessage());
|
||||
} else {
|
||||
log.error("命令调用失败: ", e);
|
||||
throw new BizException("命令调用失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void listenMsg(String url) {
|
||||
try {
|
||||
msgSocket = new Pair1Socket();
|
||||
msgSocket.dial(url);
|
||||
// 设置接收 5 秒超时
|
||||
msgSocket.setReceiveTimeout(5000);
|
||||
} catch (Exception e) {
|
||||
log.error("创建消息 RPC 失败", e);
|
||||
return;
|
||||
}
|
||||
ByteBuffer bb = ByteBuffer.allocate(BUFFER_SIZE);
|
||||
while (isReceivingMsg) {
|
||||
try {
|
||||
long size = msgSocket.receive(bb, true);
|
||||
WxMsg wxMsg = Response.parseFrom(Arrays.copyOfRange(bb.array(), 0, (int)size)).getWxmsg();
|
||||
msgQ.put(wxMsg);
|
||||
} catch (Exception e) {
|
||||
// 多半是超时,忽略吧
|
||||
}
|
||||
}
|
||||
try {
|
||||
msgSocket.close();
|
||||
} catch (Exception e) {
|
||||
log.error("关闭连接失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前微信客户端是否登录微信号
|
||||
*
|
||||
* @return 是否登录结果
|
||||
*/
|
||||
public boolean isLogin() {
|
||||
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_IS_LOGIN_VALUE).build();
|
||||
Response rsp = sendCmd(req);
|
||||
if (rsp != null) {
|
||||
return rsp.getStatus() == 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql执行结果
|
||||
*
|
||||
* @param db 数据库名
|
||||
* @param sql 执行的sql语句
|
||||
* @return 数据记录列表
|
||||
*/
|
||||
public List<DbRow> querySql(String db, String sql) {
|
||||
DbQuery dbQuery = DbQuery.newBuilder().setSql(sql).setDb(db).build();
|
||||
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_EXEC_DB_QUERY_VALUE).setQuery(dbQuery).build();
|
||||
Response rsp = sendCmd(req);
|
||||
if (rsp != null) {
|
||||
return rsp.getRows().getRowsList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密图片
|
||||
*
|
||||
* @param srcPath 加密的图片路径
|
||||
* @param dstPath 解密的图片路径
|
||||
* @return 是否成功
|
||||
*/
|
||||
public boolean decryptImage(String srcPath, String dstPath) {
|
||||
int ret = -1;
|
||||
DecPath build = DecPath.newBuilder().setSrc(srcPath).setDst(dstPath).build();
|
||||
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_DECRYPT_IMAGE_VALUE).setDec(build).build();
|
||||
Response rsp = sendCmd(req);
|
||||
if (rsp != null) {
|
||||
ret = rsp.getStatus();
|
||||
}
|
||||
return ret == 1;
|
||||
}
|
||||
|
||||
public boolean getIsReceivingMsg() {
|
||||
return isReceivingMsg;
|
||||
}
|
||||
|
||||
public WxMsg getMsg() {
|
||||
try {
|
||||
return msgQ.take();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是艾特自己的消息
|
||||
*
|
||||
* @param wxMsgXml XML消息
|
||||
* @param wxMsgContent 消息内容
|
||||
* @param selfWxId 自己的微信id
|
||||
* @return 是否
|
||||
*/
|
||||
public boolean isAtMeMsg(String wxMsgXml, String wxMsgContent, String selfWxId) {
|
||||
String format = String.format("<atuserlist><![CDATA[%s]]></atuserlist>", selfWxId);
|
||||
boolean isAtAll = wxMsgContent.startsWith("@所有人") || wxMsgContent.startsWith("@all");
|
||||
if (wxMsgXml.contains(format) && !isAtAll) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void enableRecvMsg(int qSize) {
|
||||
if (isReceivingMsg) {
|
||||
return;
|
||||
}
|
||||
|
||||
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_ENABLE_RECV_TXT_VALUE).build();
|
||||
Response rsp = sendCmd(req);
|
||||
if (rsp == null) {
|
||||
log.error("启动消息接收失败");
|
||||
isReceivingMsg = false;
|
||||
return;
|
||||
}
|
||||
|
||||
isReceivingMsg = true;
|
||||
msgQ = new ArrayBlockingQueue<>(qSize);
|
||||
String msgUrl = "tcp://" + this.host + ":" + (this.port + 1);
|
||||
Thread thread = new Thread(() -> listenMsg(msgUrl));
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public int diableRecvMsg() {
|
||||
if (!isReceivingMsg) {
|
||||
return 1;
|
||||
}
|
||||
int ret = -1;
|
||||
Request req = Request.newBuilder().setFuncValue(Functions.FUNC_DISABLE_RECV_TXT_VALUE).build();
|
||||
Response rsp = sendCmd(req);
|
||||
if (rsp != null) {
|
||||
ret = rsp.getStatus();
|
||||
if (ret == 0) {
|
||||
isReceivingMsg = false;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void waitMs(int ms) {
|
||||
try {
|
||||
Thread.sleep(ms);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public void printWxMsg(WxMsg msg) {
|
||||
WxPpMsgDTO dto = new WxPpMsgDTO();
|
||||
dto.setIsSelf(msg.getIsSelf());
|
||||
dto.setIsGroup(msg.getIsGroup());
|
||||
dto.setId(msg.getId());
|
||||
dto.setType(msg.getType());
|
||||
dto.setTs(msg.getTs());
|
||||
dto.setRoomId(msg.getRoomid());
|
||||
dto.setContent(msg.getContent());
|
||||
dto.setSender(msg.getSender());
|
||||
dto.setSign(msg.getSign());
|
||||
dto.setThumb(msg.getThumb());
|
||||
dto.setExtra(msg.getExtra());
|
||||
dto.setXml(msg.getXml().replace("\n", "").replace("\t", ""));
|
||||
|
||||
String jsonString = JSONObject.toJSONString(dto);
|
||||
log.info("收到消息: {}", jsonString);
|
||||
}
|
||||
|
||||
public String bytesToHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void keepRunning() {
|
||||
while (true) {
|
||||
waitMs(1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本机回调解析消息
|
||||
*
|
||||
* @param msg 消息内容
|
||||
* @param url 回调地址
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-05 12:50
|
||||
*/
|
||||
public void localCallbackAnalyzeMsg(WxMsg msg, String url) {
|
||||
String xml = msg.getXml();
|
||||
xml = xml.replaceAll(">[\\s\\p{Zs}]*<", "><");
|
||||
String content = msg.getContent();
|
||||
content = content.replaceAll(">[\\s\\p{Zs}]*<", "><");
|
||||
|
||||
WxPpMsgDTO dto = new WxPpMsgDTO();
|
||||
dto.setIsSelf(msg.getIsSelf());
|
||||
dto.setIsGroup(msg.getIsGroup());
|
||||
dto.setId(msg.getId());
|
||||
dto.setType(msg.getType());
|
||||
dto.setTs(msg.getTs());
|
||||
dto.setRoomId(msg.getRoomid());
|
||||
dto.setSender(msg.getSender());
|
||||
dto.setSign(msg.getSign());
|
||||
dto.setThumb(msg.getThumb());
|
||||
dto.setExtra(msg.getExtra());
|
||||
dto.setXml(xml);
|
||||
// 根据消息类型判断 引用-49
|
||||
if (!ObjectUtils.isEmpty(msg.getContent()) && "49".equals("" + msg.getType())) {
|
||||
try {
|
||||
dto.setQuoteContent(content);
|
||||
JSONObject json = XmlJsonConvertUtil.xml2Json(content);
|
||||
// 获取第一层级的JSONObject
|
||||
JSONObject level1 = json.getJSONObject("msg");
|
||||
if (!ObjectUtils.isEmpty(level1)) {
|
||||
// 获取第二层级的JSONObject
|
||||
JSONObject level2 = level1.getJSONObject("appmsg");
|
||||
if (!ObjectUtils.isEmpty(level2)) {
|
||||
// 获取field字段的值
|
||||
String fieldValue = level2.getString("title");
|
||||
dto.setContent(fieldValue);
|
||||
}
|
||||
}
|
||||
dto.setJsonContent(json);
|
||||
} catch (Exception e) {
|
||||
log.error("XML提取报错:", e);
|
||||
// 报错就使用原值
|
||||
dto.setContent(content);
|
||||
}
|
||||
} else {
|
||||
dto.setContent(content);
|
||||
}
|
||||
|
||||
String jsonString = JSONObject.toJSONString(dto);
|
||||
try {
|
||||
String responseStr = HttpClientUtil.doPostJson(url, jsonString);
|
||||
if (!JSONObject.parseObject(responseStr).getString("code").equals("200")) {
|
||||
log.error("本机消息回调失败!-URL:{}", url);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("本机消息回调接口报错:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SQL类型
|
||||
*
|
||||
* @param type 转换类型
|
||||
* @return 函数
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-05 12:54
|
||||
*/
|
||||
public Function<byte[], Object> getSqlType(int type) {
|
||||
Map<Integer, Function<byte[], Object>> sqlTypeMap = new HashMap<>();
|
||||
// 初始化SQL_TYPES 根据类型执行不同的Func
|
||||
sqlTypeMap.put(1, bytes -> new String(bytes, StandardCharsets.UTF_8));
|
||||
sqlTypeMap.put(2, bytes -> ByteBuffer.wrap(bytes).getFloat());
|
||||
sqlTypeMap.put(3, bytes -> new String(bytes, StandardCharsets.UTF_8));
|
||||
sqlTypeMap.put(4, bytes -> bytes);
|
||||
sqlTypeMap.put(5, bytes -> null);
|
||||
return sqlTypeMap.get(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL转换类型
|
||||
*
|
||||
* @param type 转换类型
|
||||
* @param content 待转换内容
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-05 12:54
|
||||
*/
|
||||
public Object convertSqlVal(int type, ByteString content) {
|
||||
// 根据每一列的类型转换
|
||||
Function<byte[], Object> converter = getSqlType(type);
|
||||
if (converter != null) {
|
||||
return converter.apply(content.toByteArray());
|
||||
} else {
|
||||
log.warn("[SQL转换类型]-未知的SQL类型: {}", type);
|
||||
return content.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.wechat.ferry.service;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
|
||||
/**
|
||||
* SDK.dll的接口类
|
||||
*
|
||||
* @author xinggq
|
||||
* @date 2024-07-10 15:21
|
||||
*/
|
||||
public interface SDK extends Library {
|
||||
|
||||
/**
|
||||
* 初始化SDK
|
||||
*
|
||||
* @param debug 开发模式
|
||||
* @param port 端口
|
||||
* @return 状态值
|
||||
*/
|
||||
int WxInitSDK(boolean debug, int port);
|
||||
|
||||
/**
|
||||
* 退出SDK
|
||||
*
|
||||
* @return 状态值
|
||||
*/
|
||||
int WxDestroySDK();
|
||||
|
||||
}
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
package com.wechat.ferry.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfAddFriendGroupMemberReq;
|
||||
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.WxPpWcfGroupMemberReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfInviteGroupMemberReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfPassFriendApplyReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfPatOnePatMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfReceiveTransferReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfRevokeMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendEmojiMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendFileMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendImageMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendRichTextMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendTextMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendXmlMsgReq;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfContactsResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfDatabaseRowResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfDatabaseTableResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfGroupMemberResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfLoginInfoResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfMsgTypeResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendEmojiMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendFileMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendImageMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendPatOnePatMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendRichTextMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendTextMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendXmlMsgResp;
|
||||
|
||||
/**
|
||||
* 业务接口-对接原本DLL的接口
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 15:57
|
||||
*/
|
||||
public interface WeChatDllService {
|
||||
|
||||
/**
|
||||
* 当前微信客户端是否登录微信号
|
||||
*
|
||||
* @return true-已登录 false-未登录
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 21:20
|
||||
*/
|
||||
Boolean loginStatus();
|
||||
|
||||
/**
|
||||
* 获取登录微信内部识别号UID
|
||||
* 获得微信客户端登录的微信ID
|
||||
*
|
||||
* @return 微信内部识别号UID
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 21:22
|
||||
*/
|
||||
String queryLoginWeChatUid();
|
||||
|
||||
/**
|
||||
* 获取登录微信信息
|
||||
*
|
||||
* @return 当前登录微信信息
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-05 22:54
|
||||
*/
|
||||
WxPpWcfLoginInfoResp queryLoginWeChatInfo();
|
||||
|
||||
/**
|
||||
* 获取消息类型列表
|
||||
*
|
||||
* @return 消息类型列表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 21:22
|
||||
*/
|
||||
List<WxPpWcfMsgTypeResp> queryMsgTypeList();
|
||||
|
||||
/**
|
||||
* 获取联系人列表
|
||||
*
|
||||
* @return 联系人列表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 16:59
|
||||
*/
|
||||
List<WxPpWcfContactsResp> queryContactsList();
|
||||
|
||||
/**
|
||||
* 获取数据库表名称列表
|
||||
*
|
||||
* @return 数据库名称列表
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 17:53
|
||||
*/
|
||||
List<String> queryDbTableNameList();
|
||||
|
||||
/**
|
||||
* 获取指定数据库中的所有表
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 数据库记录
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 17:52
|
||||
*/
|
||||
List<WxPpWcfDatabaseTableResp> queryDbTableList(WxPpWcfDatabaseTableReq request);
|
||||
|
||||
/**
|
||||
* 执行数据库查询SQL
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 数据库记录
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 17:52
|
||||
*/
|
||||
List<WxPpWcfDatabaseRowResp> execDbQuerySql(WxPpWcfDatabaseSqlReq request);
|
||||
|
||||
/**
|
||||
* 发送文本消息(可 @)
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 消息发送返回
|
||||
*
|
||||
* @example sendText(" Hello @ 某人1 @ 某人2 ", " xxxxxxxx @ chatroom ", "wxid_xxxxxxxxxxxxx1,wxid_xxxxxxxxxxxxx2");
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 20:40
|
||||
*/
|
||||
WxPpWcfSendTextMsgResp sendTextMsg(WxPpWcfSendTextMsgReq request);
|
||||
|
||||
/**
|
||||
* 发送富文本消息
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 消息发送返回
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-06 15:48
|
||||
*/
|
||||
WxPpWcfSendRichTextMsgResp sendRichTextMsg(WxPpWcfSendRichTextMsgReq request);
|
||||
|
||||
/**
|
||||
* 发送XML消息
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 消息发送返回
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 23:15
|
||||
*/
|
||||
WxPpWcfSendXmlMsgResp sendXmlMsg(WxPpWcfSendXmlMsgReq request);
|
||||
|
||||
/**
|
||||
* 发送图片消息
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 消息发送返回
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 23:06
|
||||
*/
|
||||
WxPpWcfSendImageMsgResp sendImageMsg(WxPpWcfSendImageMsgReq request);
|
||||
|
||||
/**
|
||||
* 发送表情消息
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 消息发送返回
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 23:29
|
||||
*/
|
||||
WxPpWcfSendEmojiMsgResp sendEmojiMsg(WxPpWcfSendEmojiMsgReq request);
|
||||
|
||||
/**
|
||||
* 发送文件消息
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 消息发送返回
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-04 23:15
|
||||
*/
|
||||
WxPpWcfSendFileMsgResp sendFileMsg(WxPpWcfSendFileMsgReq request);
|
||||
|
||||
/**
|
||||
* 拍一拍
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 消息发送返回
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-06 15:54
|
||||
*/
|
||||
WxPpWcfSendPatOnePatMsgResp patOnePat(WxPpWcfPatOnePatMsgReq request);
|
||||
|
||||
/**
|
||||
* 撤回消息
|
||||
*
|
||||
* @return 结果状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 11:59
|
||||
*/
|
||||
String revokeMsg(WxPpWcfRevokeMsgReq request);
|
||||
|
||||
/**
|
||||
* 通过好友申请
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 结果状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 09:38
|
||||
*/
|
||||
String passFriendApply(WxPpWcfPassFriendApplyReq request);
|
||||
|
||||
/**
|
||||
* 添加群成员为微信好友
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 结果状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 09:38
|
||||
*/
|
||||
String addFriendGroupMember(WxPpWcfAddFriendGroupMemberReq request);
|
||||
|
||||
/**
|
||||
* 查询群成员列表
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 数据库记录
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-02 20:59
|
||||
*/
|
||||
List<WxPpWcfGroupMemberResp> queryGroupMemberList(WxPpWcfGroupMemberReq request);
|
||||
|
||||
/**
|
||||
* 邀请群成员
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 结果状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 10:02
|
||||
*/
|
||||
String inviteGroupMember(WxPpWcfInviteGroupMemberReq request);
|
||||
|
||||
/**
|
||||
* 删除群成员
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 结果状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 10:03
|
||||
*/
|
||||
String deleteGroupMember(WxPpWcfDeleteGroupMemberReq request);
|
||||
|
||||
/**
|
||||
* 查询朋友圈
|
||||
*
|
||||
* @return 结果状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 11:11
|
||||
*/
|
||||
String queryFriendCircle();
|
||||
|
||||
/**
|
||||
* 接收转账
|
||||
*
|
||||
* @param request 请求入参
|
||||
* @return 结果状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 13:48
|
||||
*/
|
||||
String receiveTransfer(WxPpWcfReceiveTransferReq request);
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.wechat.ferry.service;
|
||||
|
||||
/**
|
||||
* 业务接口-消息处理
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 14:30
|
||||
*/
|
||||
public interface WeChatMsgService {
|
||||
|
||||
/**
|
||||
* 接收消息
|
||||
*
|
||||
* @param jsonString json数据
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 14:33
|
||||
*/
|
||||
void receiveMsg(String jsonString);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
+749
@@ -0,0 +1,749 @@
|
||||
package com.wechat.ferry.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.wechat.ferry.aggregation.facade.ContactDo;
|
||||
import com.wechat.ferry.config.WeChatFerryProperties;
|
||||
import com.wechat.ferry.entity.proto.Wcf;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfAddFriendGroupMemberReq;
|
||||
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.WxPpWcfGroupMemberReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfInviteGroupMemberReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfPassFriendApplyReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfPatOnePatMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfReceiveTransferReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfRevokeMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendEmojiMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendFileMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendImageMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendRichTextMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendTextMsgReq;
|
||||
import com.wechat.ferry.entity.vo.request.WxPpWcfSendXmlMsgReq;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfContactsResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfDatabaseFieldResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfDatabaseRowResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfDatabaseTableResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfGroupMemberResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfLoginInfoResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfMsgTypeResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendEmojiMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendFileMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendImageMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendPatOnePatMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendRichTextMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendTextMsgResp;
|
||||
import com.wechat.ferry.entity.vo.response.WxPpWcfSendXmlMsgResp;
|
||||
import com.wechat.ferry.enums.DatabaseNameEnum;
|
||||
import com.wechat.ferry.enums.MsgCallbackTypeEnum;
|
||||
import com.wechat.ferry.enums.SexEnum;
|
||||
import com.wechat.ferry.enums.WxContactsTypeEnum;
|
||||
import com.wechat.ferry.exception.BizException;
|
||||
import com.wechat.ferry.handle.WeChatSocketClient;
|
||||
import com.wechat.ferry.service.WeChatDllService;
|
||||
import com.wechat.ferry.utils.HttpClientUtil;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 业务实现层-对接原本DLL的接口
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 15:58
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WeChatDllServiceImpl implements WeChatDllService {
|
||||
|
||||
private WeChatSocketClient wechatSocketClient;
|
||||
|
||||
@Autowired
|
||||
public void setWechatSocketClient(WeChatSocketClient wechatSocketClient) {
|
||||
this.wechatSocketClient = wechatSocketClient;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private WeChatFerryProperties weChatFerryProperties;
|
||||
|
||||
@Override
|
||||
public Boolean loginStatus() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
Boolean status = wechatSocketClient.isLogin();
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[登录状态]-耗时:{}ms,status:{}", (endTime - startTime), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryLoginWeChatUid() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
String weChatUid = "";
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_GET_SELF_WXID_VALUE).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
if (!ObjectUtils.isEmpty(rsp)) {
|
||||
weChatUid = rsp.getStr();
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[登录微信UID]-耗时:{}ms, weChatUid:{}", (endTime - startTime), weChatUid);
|
||||
return weChatUid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfLoginInfoResp queryLoginWeChatInfo() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
WxPpWcfLoginInfoResp resp = new WxPpWcfLoginInfoResp();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_GET_USER_INFO_VALUE).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
if (!ObjectUtils.isEmpty(rsp) && !ObjectUtils.isEmpty(rsp.getUi())) {
|
||||
Wcf.UserInfo userInfo = rsp.getUi();
|
||||
resp.setWeChatUid(userInfo.getWxid());
|
||||
resp.setWeChatNickname(userInfo.getName());
|
||||
resp.setPhone(userInfo.getMobile());
|
||||
resp.setHomePath(userInfo.getHome());
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[获取登录微信信息]-耗时:{}ms,登录信息:{}", (endTime - startTime), resp);
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxPpWcfMsgTypeResp> queryMsgTypeList() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
List<WxPpWcfMsgTypeResp> list = new ArrayList<>();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_GET_MSG_TYPES_VALUE).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
if (!ObjectUtils.isEmpty(rsp)) {
|
||||
Map<Integer, String> msgTypeMap = rsp.getTypes().getTypesMap();
|
||||
WxPpWcfMsgTypeResp resp;
|
||||
for (Map.Entry<Integer, String> entry : msgTypeMap.entrySet()) {
|
||||
resp = new WxPpWcfMsgTypeResp();
|
||||
resp.setId(entry.getKey());
|
||||
resp.setName(entry.getValue());
|
||||
list.add(resp);
|
||||
}
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[所有消息类型]-共查到:{}条,耗时:{}ms", list.size(), (endTime - startTime));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxPpWcfContactsResp> queryContactsList() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
List<WxPpWcfContactsResp> list = new ArrayList<>();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_GET_CONTACTS_VALUE).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
if (!ObjectUtils.isEmpty(rsp) && !ObjectUtils.isEmpty(rsp.getContacts()) && !CollectionUtils.isEmpty(rsp.getContacts().getContactsList())) {
|
||||
List<Wcf.RpcContact> rpcContactList = rsp.getContacts().getContactsList();
|
||||
for (Wcf.RpcContact rpcContact : rpcContactList) {
|
||||
WxPpWcfContactsResp vo = new WxPpWcfContactsResp();
|
||||
vo.setWeChatUid(rpcContact.getWxid());
|
||||
vo.setWeChatNo(rpcContact.getCode());
|
||||
vo.setWeChatRemark(rpcContact.getRemark());
|
||||
vo.setWeChatNickname(rpcContact.getName());
|
||||
if (!ObjectUtils.isEmpty(rpcContact.getCountry())) {
|
||||
vo.setCountryPinyin(rpcContact.getCountry());
|
||||
if ("CN".equals(rpcContact.getCountry())) {
|
||||
vo.setCountry("中国");
|
||||
}
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(rpcContact.getProvince())) {
|
||||
vo.setProvincePinyin(rpcContact.getProvince());
|
||||
vo.setProvince(null);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(rpcContact.getCity())) {
|
||||
vo.setCityPinyin(rpcContact.getCity());
|
||||
vo.setCity(null);
|
||||
}
|
||||
// 性别处理
|
||||
if (!ObjectUtils.isEmpty(rpcContact.getGender())) {
|
||||
vo.setSex(SexEnum.getCodeMap(String.valueOf(rpcContact.getGender())).getCode());
|
||||
vo.setSexLabel(SexEnum.getCodeMap(String.valueOf(rpcContact.getGender())).getName());
|
||||
}
|
||||
// 微信类型
|
||||
if (!ObjectUtils.isEmpty(rpcContact.getWxid())) {
|
||||
String type = ContactDo.convertContactType(rpcContact.getWxid(), weChatFerryProperties);
|
||||
vo.setType(type);
|
||||
vo.setTypeLabel(WxContactsTypeEnum.getCodeMap(rpcContact.getWxid()).getName());
|
||||
}
|
||||
list.add(vo);
|
||||
}
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[联系人]-共查到:{}条,耗时:{}ms", list.size(), (endTime - startTime));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryDbTableNameList() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
List<String> list = new ArrayList<>();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_GET_DB_NAMES_VALUE).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
if (!ObjectUtils.isEmpty(rsp) && !ObjectUtils.isEmpty(rsp.getDbs()) && !CollectionUtils.isEmpty(rsp.getDbs().getNamesList())) {
|
||||
list = rsp.getDbs().getNamesList();
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[数据库名称列表]-共查到:{}条,耗时:{}ms", list.size(), (endTime - startTime));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxPpWcfDatabaseTableResp> queryDbTableList(WxPpWcfDatabaseTableReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[查询]-[数据库表列表]-request:{}", request);
|
||||
List<WxPpWcfDatabaseTableResp> list = new ArrayList<>();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_GET_DB_TABLES_VALUE).setStr(request.getDatabaseName()).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
if (!ObjectUtils.isEmpty(rsp) && !ObjectUtils.isEmpty(rsp.getTables()) && !CollectionUtils.isEmpty(rsp.getTables().getTablesList())) {
|
||||
WxPpWcfDatabaseTableResp resp;
|
||||
for (Wcf.DbTable tbl : rsp.getTables().getTablesList()) {
|
||||
resp = new WxPpWcfDatabaseTableResp();
|
||||
resp.setTableName(tbl.getName());
|
||||
resp.setSql(tbl.getSql());
|
||||
list.add(resp);
|
||||
}
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[数据库表列表]-共查到:{}条,耗时:{}ms", list.size(), (endTime - startTime));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxPpWcfDatabaseRowResp> execDbQuerySql(WxPpWcfDatabaseSqlReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
List<WxPpWcfDatabaseRowResp> list = new ArrayList<>();
|
||||
List<Wcf.DbRow> wcfList = wechatSocketClient.querySql(request.getDatabaseName(), request.getSqlText());
|
||||
if (!CollectionUtils.isEmpty(wcfList)) {
|
||||
for (Wcf.DbRow dbRow : wcfList) {
|
||||
WxPpWcfDatabaseRowResp rowVo = new WxPpWcfDatabaseRowResp();
|
||||
List<WxPpWcfDatabaseFieldResp> fieldVoList = new ArrayList<>();
|
||||
for (Wcf.DbField dbField : dbRow.getFieldsList()) {
|
||||
WxPpWcfDatabaseFieldResp fieldVo = new WxPpWcfDatabaseFieldResp();
|
||||
Object value;
|
||||
if (ObjectUtils.isEmpty(dbField.getType())) {
|
||||
log.warn("未知的SQL类型: {}", dbField.getType());
|
||||
value = dbField.getContent().toByteArray();
|
||||
} else {
|
||||
value = wechatSocketClient.convertSqlVal(dbField.getType(), dbField.getContent());
|
||||
}
|
||||
fieldVo.setType(String.valueOf(dbField.getType()));
|
||||
fieldVo.setColumn(dbField.getColumn());
|
||||
fieldVo.setValue(value);
|
||||
fieldVoList.add(fieldVo);
|
||||
}
|
||||
rowVo.setFieldList(fieldVoList);
|
||||
list.add(rowVo);
|
||||
}
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[执行数据库查询SQL]-共查到:{}条,耗时:{}ms", list.size(), (endTime - startTime));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfSendTextMsgResp sendTextMsg(WxPpWcfSendTextMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[发送消息]-[文本消息]-入参打印:{}", request);
|
||||
String atUser = "";
|
||||
if (request.getIsAtAll()) {
|
||||
// 艾特全体,仅管理员有效
|
||||
atUser = "@all";
|
||||
} else {
|
||||
// 处理艾特的人员
|
||||
if (!CollectionUtils.isEmpty(request.getAtUsers())) {
|
||||
atUser = String.join(",", request.getAtUsers());
|
||||
}
|
||||
}
|
||||
Wcf.TextMsg textMsg = Wcf.TextMsg.newBuilder().setMsg(request.getMsgText()).setReceiver(request.getRecipient()).setAters(atUser).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_SEND_TXT_VALUE).setTxt(textMsg).build();
|
||||
log.debug("sendText: {}", wechatSocketClient.bytesToHex(req.toByteArray()));
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
// 0 为成功,其他失败
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[发送消息]-[文本消息]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfSendRichTextMsgResp sendRichTextMsg(WxPpWcfSendRichTextMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[发送消息]-[富文本消息]-入参打印:{}", request);
|
||||
Wcf.RichText richTextMsg = Wcf.RichText.newBuilder().setName(request.getName()).setAccount(request.getAccount()).setTitle(request.getTitle())
|
||||
.setDigest(request.getDigest()).setUrl(request.getJumpUrl()).setThumburl(request.getThumbnailUrl()).setReceiver(request.getRecipient())
|
||||
.build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_SEND_RICH_TXT_VALUE).setRt(richTextMsg).build();
|
||||
log.debug("sendRichText: {}", wechatSocketClient.bytesToHex(req.toByteArray()));
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[发送消息]-[富文本消息]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfSendXmlMsgResp sendXmlMsg(WxPpWcfSendXmlMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[发送消息]-[XML消息]-入参打印:{}", request);
|
||||
int xmlType = 0x21;
|
||||
if ("21".equals(request.getXmlType())) {
|
||||
// 小程序
|
||||
xmlType = 0x21;
|
||||
} else {
|
||||
xmlType = Integer.parseInt(request.getXmlType());
|
||||
}
|
||||
Wcf.XmlMsg xmlMsg = Wcf.XmlMsg.newBuilder().setContent(request.getXmlContent()).setReceiver(request.getRecipient())
|
||||
.setPath(request.getResourcePath()).setType(xmlType).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_SEND_XML_VALUE).setXml(xmlMsg).build();
|
||||
log.debug("sendXml: {}", wechatSocketClient.bytesToHex(req.toByteArray()));
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[发送消息]-[XML消息]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfSendImageMsgResp sendImageMsg(WxPpWcfSendImageMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[发送消息]-[图片消息]-入参打印:{}", request);
|
||||
WxPpWcfSendImageMsgResp resp = new WxPpWcfSendImageMsgResp();
|
||||
Wcf.PathMsg pathMsg = Wcf.PathMsg.newBuilder().setPath(request.getResourcePath()).setReceiver(request.getRecipient()).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_SEND_IMG_VALUE).setFile(pathMsg).build();
|
||||
log.debug("sendImage: {}", wechatSocketClient.bytesToHex(req.toByteArray()));
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[发送消息]-[图片消息]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfSendEmojiMsgResp sendEmojiMsg(WxPpWcfSendEmojiMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[发送消息]-[表情消息]-入参打印:{}", request);
|
||||
Wcf.PathMsg pathMsg = Wcf.PathMsg.newBuilder().setPath(request.getResourcePath()).setReceiver(request.getRecipient()).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_SEND_EMOTION_VALUE).setFile(pathMsg).build();
|
||||
log.debug("sendEmotion: {}", wechatSocketClient.bytesToHex(req.toByteArray()));
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[发送消息]-[表情消息]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfSendFileMsgResp sendFileMsg(WxPpWcfSendFileMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[发送消息]-[文件消息]-入参打印:{}", request);
|
||||
Wcf.PathMsg pathMsg = Wcf.PathMsg.newBuilder().setPath(request.getResourcePath()).setReceiver(request.getRecipient()).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_SEND_FILE_VALUE).setFile(pathMsg).build();
|
||||
log.debug("sendFile: {}", wechatSocketClient.bytesToHex(req.toByteArray()));
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[发送消息]-[文件消息]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPpWcfSendPatOnePatMsgResp patOnePat(WxPpWcfPatOnePatMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[发送消息]-[拍一拍消息]-入参打印:{}", request);
|
||||
Wcf.PatMsg patMsg = Wcf.PatMsg.newBuilder().setRoomid(request.getRecipient()).setWxid(request.getPatUser()).build();
|
||||
Wcf.Request wcfReq = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_SEND_PAT_MSG_VALUE).setPm(patMsg).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(wcfReq);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[发送消息]-[拍一拍消息]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String revokeMsg(WxPpWcfRevokeMsgReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[撤回消息]-[消息撤回]-入参打印:{}", request);
|
||||
long msgId = Long.parseLong(request.getMsgId());
|
||||
Wcf.Request wcfReq = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_REVOKE_MSG_VALUE).setUi64(msgId).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(wcfReq);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
// 回调处理
|
||||
String stringJson = JSON.toJSONString(request);
|
||||
sendMsgCallback(stringJson, state);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[撤回消息]-[消息撤回]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String passFriendApply(WxPpWcfPassFriendApplyReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[好友申请]-[通过好友申请]-入参打印:{}", request);
|
||||
Wcf.Verification verification = Wcf.Verification.newBuilder().setV3(request.getApplicant()).setV4(request.getReviewer()).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_ACCEPT_FRIEND_VALUE).setV(verification).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[好友申请]-[通过好友申请]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addFriendGroupMember(WxPpWcfAddFriendGroupMemberReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[添加好友]-[添加群成员为好友]-入参打印:{}", request);
|
||||
if (CollectionUtils.isEmpty(request.getGroupMembers())) {
|
||||
log.error("[添加好友]-[添加群成员为好友]-待添加人员为空,本次操作取消");
|
||||
return "";
|
||||
}
|
||||
String groupMembersStr = String.join(",", request.getGroupMembers());
|
||||
Wcf.MemberMgmt memberMgmt = Wcf.MemberMgmt.newBuilder().setRoomid(request.getGroupNo()).setWxids(groupMembersStr).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_ADD_ROOM_MEMBERS_VALUE).setM(memberMgmt).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[添加好友]-[添加群成员为好友]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxPpWcfGroupMemberResp> queryGroupMemberList(WxPpWcfGroupMemberReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
List<WxPpWcfGroupMemberResp> list = new ArrayList<>();
|
||||
String weChatUid = queryLoginWeChatUid();
|
||||
// 查询群成员
|
||||
List<Wcf.DbRow> wcfList = new ArrayList<>();
|
||||
if (!ObjectUtils.isEmpty(request.getGroupNo())) {
|
||||
wcfList = wechatSocketClient.querySql(DatabaseNameEnum.MICRO_MSG.getCode(),
|
||||
"SELECT RoomData FROM ChatRoom WHERE ChatRoomName = '" + request.getGroupNo() + "';");
|
||||
}
|
||||
// 查询联系人
|
||||
List<Wcf.DbRow> dbList = wechatSocketClient.querySql(DatabaseNameEnum.MICRO_MSG.getCode(), "SELECT UserName, NickName, Type FROM Contact;");
|
||||
Map<String, String> dbMap = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(dbList)) {
|
||||
for (Wcf.DbRow dbRow : dbList) {
|
||||
List<Wcf.DbField> dbFieldList = dbRow.getFieldsList();
|
||||
if (!ObjectUtils.isEmpty(dbFieldList)) {
|
||||
WxPpWcfGroupMemberResp vo = new WxPpWcfGroupMemberResp();
|
||||
for (Wcf.DbField dbField : dbFieldList) {
|
||||
if ("UserName".equals(dbField.getColumn())) {
|
||||
vo = new WxPpWcfGroupMemberResp();
|
||||
String content = (String)wechatSocketClient.convertSqlVal(dbField.getType(), dbField.getContent());
|
||||
vo.setWeChatUid(content);
|
||||
}
|
||||
if ("NickName".equals(dbField.getColumn())) {
|
||||
String content = (String)wechatSocketClient.convertSqlVal(dbField.getType(), dbField.getContent());
|
||||
vo.setGroupNickName(content);
|
||||
dbMap.put(vo.getWeChatUid(), vo.getGroupNickName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询群名称
|
||||
if (!CollectionUtils.isEmpty(wcfList)) {
|
||||
for (Wcf.DbRow dbRow : wcfList) {
|
||||
List<Wcf.DbField> dbFieldList = dbRow.getFieldsList();
|
||||
if (!ObjectUtils.isEmpty(dbFieldList)) {
|
||||
WxPpWcfGroupMemberResp vo = new WxPpWcfGroupMemberResp();
|
||||
for (Wcf.DbField dbField : dbFieldList) {
|
||||
if ("RoomData".equals(dbField.getColumn())) {
|
||||
try {
|
||||
byte[] roomDataBytes = dbField.getContent().toByteArray();
|
||||
Wcf.RoomData roomData = Wcf.RoomData.parseFrom(roomDataBytes);
|
||||
for (Wcf.RoomData.RoomMember member : roomData.getMembersList()) {
|
||||
vo = new WxPpWcfGroupMemberResp();
|
||||
vo.setWeChatUid(member.getWxid());
|
||||
// 是否为自己微信
|
||||
vo.setWhetherSelf(weChatUid.equals(member.getWxid()));
|
||||
// 是否为企微
|
||||
vo.setWhetherWork(member.getWxid().endsWith(WxContactsTypeEnum.WORK.getAffix()));
|
||||
String nickName = member.getName();
|
||||
if (ObjectUtils.isEmpty(nickName)) {
|
||||
// 如果没有设置群昵称则默认为微信名称
|
||||
nickName = dbMap.get(member.getWxid());
|
||||
}
|
||||
vo.setGroupNickName(nickName);
|
||||
vo.setState(String.valueOf(member.getState()));
|
||||
list.add(vo);
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
log.error("异常:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[查询群成员]-共查到:{}条,耗时:{}ms", list.size(), (endTime - startTime));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inviteGroupMember(WxPpWcfInviteGroupMemberReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[群成员]-[邀请群成员加入]-入参打印:{}", request);
|
||||
if (CollectionUtils.isEmpty(request.getGroupMembers())) {
|
||||
log.error("[群成员]-[邀请群成员加入]-待邀请进群的人员为空,本次操作取消");
|
||||
return "";
|
||||
}
|
||||
String groupMembersStr = String.join(",", request.getGroupMembers());
|
||||
Wcf.MemberMgmt memberMgmt = Wcf.MemberMgmt.newBuilder().setRoomid(request.getGroupNo()).setWxids(groupMembersStr).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_INV_ROOM_MEMBERS_VALUE).setM(memberMgmt).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[群成员]-[邀请群成员加入]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deleteGroupMember(WxPpWcfDeleteGroupMemberReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[群成员]-[删除群成员]-入参打印:{}", request);
|
||||
if (CollectionUtils.isEmpty(request.getGroupMembers())) {
|
||||
log.error("[群成员]-[删除群成员]-待删除的人员为空,本次操作取消");
|
||||
return "";
|
||||
}
|
||||
String groupMembersStr = String.join(",", request.getGroupMembers());
|
||||
Wcf.MemberMgmt memberMgmt = Wcf.MemberMgmt.newBuilder().setRoomid(request.getGroupNo()).setWxids(groupMembersStr).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_DEL_ROOM_MEMBERS_VALUE).setM(memberMgmt).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[群成员]-[删除群成员]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryFriendCircle() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[查询]-[刷新朋友圈]-开始");
|
||||
// id 开始 id,0 为最新页 (string based uint64)
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_REFRESH_PYQ_VALUE).setUi64(0).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[查询]-[刷新朋友圈]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String receiveTransfer(WxPpWcfReceiveTransferReq request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 公共校验
|
||||
checkClientStatus();
|
||||
log.info("[转账]-[接收转账]-开始");
|
||||
Wcf.Transfer transfer =
|
||||
Wcf.Transfer.newBuilder().setWxid(request.getWeChatUid()).setTfid(request.getTransferId()).setTaid(request.getTransferId()).build();
|
||||
Wcf.Request req = Wcf.Request.newBuilder().setFuncValue(Wcf.Functions.FUNC_RECV_TRANSFER_VALUE).setTf(transfer).build();
|
||||
Wcf.Response rsp = wechatSocketClient.sendCmd(req);
|
||||
int state = judgeWcfCmdState(rsp);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("[转账]-[接收转账]-处理结束,耗时:{}ms", (endTime - startTime));
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息回调
|
||||
*
|
||||
* @param jsonString json数据
|
||||
* @param state cmd调用状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-10 23:10
|
||||
*/
|
||||
private void sendMsgCallback(String jsonString, Integer state) {
|
||||
// 根据配置文件决定是否回调
|
||||
if (MsgCallbackTypeEnum.CLOSE.getCode().equals(weChatFerryProperties.getSendMsgCallbackFlag())
|
||||
|| (MsgCallbackTypeEnum.SUCCESS.getCode().equals(weChatFerryProperties.getSendMsgCallbackFlag()) && 0 != state)) {
|
||||
// 如果是关闭 或者 配置为成功才回调但发送状态为失败 的情况则取消发送
|
||||
return;
|
||||
}
|
||||
// 开启回调,且回调地址不为空
|
||||
if (!CollectionUtils.isEmpty(weChatFerryProperties.getSendMsgCallbackUrls())) {
|
||||
for (String receiveMsgFwdUrl : weChatFerryProperties.getSendMsgCallbackUrls()) {
|
||||
if (!receiveMsgFwdUrl.startsWith("http")) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
String responseStr = HttpClientUtil.doPostJson(receiveMsgFwdUrl, jsonString);
|
||||
if (judgeSuccess(responseStr)) {
|
||||
log.error("[发送消息]-消息回调至外部接口,获取响应状态失败!-URL:{}", receiveMsgFwdUrl);
|
||||
}
|
||||
log.debug("[发送消息]-[回调接收到的消息]-回调消息至:{}", receiveMsgFwdUrl);
|
||||
} catch (Exception e) {
|
||||
log.error("[发送消息]-消息回调接口[{}]服务异常:", receiveMsgFwdUrl, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断调用第三方服务客户端成功状态码
|
||||
*
|
||||
* @param responseStr 响应参数
|
||||
* @return 状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-10 00:10
|
||||
*/
|
||||
private Boolean judgeSuccess(String responseStr) {
|
||||
// 默认为通过
|
||||
boolean passFlag = false;
|
||||
if (!ObjectUtils.isEmpty(responseStr)) {
|
||||
JSONObject jSONObject = JSONObject.parseObject(responseStr);
|
||||
if (!ObjectUtils.isEmpty(jSONObject) && !CollectionUtils.isEmpty(weChatFerryProperties.getThirdPartyOkCodes())) {
|
||||
Map<String, String> codeMap = weChatFerryProperties.getThirdPartyOkCodes();
|
||||
for (Map.Entry<String, String> entry : codeMap.entrySet()) {
|
||||
if (!ObjectUtils.isEmpty(jSONObject.get(entry.getKey())) && jSONObject.get(entry.getKey()).equals(entry.getValue())) {
|
||||
passFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return passFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断WCF的CMD调用状态
|
||||
* 有值 为成功,其他失败
|
||||
*
|
||||
* @param rsp 响应参数
|
||||
* @return 状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-23 21:53
|
||||
*/
|
||||
private int judgeWcfCmdState(Wcf.Response rsp) {
|
||||
// 有值 为成功,其他失败
|
||||
int state = -1;
|
||||
if (rsp != null) {
|
||||
state = rsp.getStatus();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换联系人类型配置
|
||||
*
|
||||
* @param list 配置参数
|
||||
* @return map key:code val:name
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-24 16:55
|
||||
*/
|
||||
private Map<String, String> convertContactsTypeProperties(List<String> list) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (String str : list) {
|
||||
String key = str;
|
||||
String val = str;
|
||||
// 存在名称则分割
|
||||
if (str.contains("|")) {
|
||||
int index = str.indexOf("|");
|
||||
key = str.substring(0, index);
|
||||
val = str.substring(index + 1);
|
||||
}
|
||||
map.put(key, val);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求前检测客户端状态
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2025-01-04 18:34
|
||||
*/
|
||||
private void checkClientStatus() {
|
||||
if (!wechatSocketClient.isLogin()) {
|
||||
throw new BizException("微信客户端未登录或状态异常,请人工关闭本服务之后,退出微信客户端在重启本服务!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package com.wechat.ferry.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.wechat.ferry.config.WeChatFerryProperties;
|
||||
import com.wechat.ferry.entity.dto.WxPpMsgDTO;
|
||||
import com.wechat.ferry.service.WeChatMsgService;
|
||||
import com.wechat.ferry.strategy.msg.receive.ReceiveMsgFactory;
|
||||
import com.wechat.ferry.strategy.msg.receive.ReceiveMsgStrategy;
|
||||
import com.wechat.ferry.utils.HttpClientUtil;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 业务实现层-消息处理
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-10-01 14:35
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WeChatMsgServiceImpl implements WeChatMsgService {
|
||||
|
||||
@Resource
|
||||
private WeChatFerryProperties weChatFerryProperties;
|
||||
|
||||
@Override
|
||||
public void receiveMsg(String jsonString) {
|
||||
// 转发接口处理
|
||||
receiveMsgCallback(jsonString);
|
||||
// 转为JSON对象
|
||||
WxPpMsgDTO dto = JSON.parseObject(jsonString, WxPpMsgDTO.class);
|
||||
// 有开启的群聊配置
|
||||
if (weChatFerryProperties.getOpenMsgGroupSwitch() && !weChatFerryProperties.getOpenMsgGroups().isEmpty()) {
|
||||
Map<String, List<String>> openMsgGroupMap = new HashMap<>();
|
||||
String allFnNoStr = "";
|
||||
List<String> allFnNoList = new ArrayList<>();
|
||||
if (weChatFerryProperties.getOpenMsgGroups().containsKey("ALL")) {
|
||||
allFnNoStr = weChatFerryProperties.getOpenMsgGroups().get("ALL");
|
||||
// 分割字符串并去除空格及空元素
|
||||
allFnNoList = Arrays.stream(allFnNoStr.split(","))
|
||||
// 去掉前后空格
|
||||
.map(String::trim)
|
||||
// 过滤掉空字符串
|
||||
.filter(s -> !s.isEmpty())
|
||||
// 去重
|
||||
.distinct().collect(Collectors.toList());
|
||||
openMsgGroupMap.put("ALL", allFnNoList);
|
||||
}
|
||||
|
||||
// 遍历
|
||||
for (String key : weChatFerryProperties.getOpenMsgGroups().keySet()) {
|
||||
List<String> valList = new ArrayList<>();
|
||||
if (!"ALL".equals(key)) {
|
||||
String str = weChatFerryProperties.getOpenMsgGroups().get(key);
|
||||
String[] arr = str.split(",");
|
||||
for (String s : arr) {
|
||||
// 去重,且ALL中不包含
|
||||
if (!valList.contains(s) && !allFnNoList.contains(s)) {
|
||||
valList.add(s);
|
||||
}
|
||||
}
|
||||
openMsgGroupMap.put(key, valList);
|
||||
}
|
||||
}
|
||||
|
||||
// 指定处理的群聊
|
||||
if (!openMsgGroupMap.isEmpty()) {
|
||||
List<String> fnNoList = new ArrayList<>();
|
||||
// 先执行所有群都需要执行的
|
||||
if (openMsgGroupMap.containsKey("ALL")) {
|
||||
fnNoList = openMsgGroupMap.get("ALL");
|
||||
}
|
||||
// 加入个性化的
|
||||
if (openMsgGroupMap.containsKey(dto.getRoomId())) {
|
||||
fnNoList.addAll(openMsgGroupMap.get(dto.getRoomId()));
|
||||
}
|
||||
// 需要执行的策略
|
||||
if (!CollectionUtils.isEmpty(fnNoList)) {
|
||||
for (String no : fnNoList) {
|
||||
// 根据功能号获取对应的策略
|
||||
ReceiveMsgStrategy receiveMsgStrategy = ReceiveMsgFactory.getStrategy(no);
|
||||
receiveMsgStrategy.doHandle(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("[收到消息]-[消息内容]-打印:{}", dto);
|
||||
}
|
||||
|
||||
private void receiveMsgCallback(String jsonString) {
|
||||
// 开启回调,且回调地址不为空
|
||||
if (weChatFerryProperties.getReceiveMsgCallbackSwitch() && !CollectionUtils.isEmpty(weChatFerryProperties.getReceiveMsgCallbackUrls())) {
|
||||
for (String receiveMsgFwdUrl : weChatFerryProperties.getReceiveMsgCallbackUrls()) {
|
||||
if (!receiveMsgFwdUrl.startsWith("http")) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
String responseStr = HttpClientUtil.doPostJson(receiveMsgFwdUrl, jsonString);
|
||||
if (judgeSuccess(responseStr)) {
|
||||
log.error("[接收消息]-消息回调至外部接口,获取响应状态失败!-URL:{}", receiveMsgFwdUrl);
|
||||
}
|
||||
log.debug("[接收消息]-[回调接收到的消息]-回调消息至:{}", receiveMsgFwdUrl);
|
||||
} catch (Exception e) {
|
||||
log.error("[接收消息]-消息回调接口[{}]服务异常:", receiveMsgFwdUrl, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean judgeSuccess(String responseStr) {
|
||||
// 默认为通过
|
||||
boolean passFlag = false;
|
||||
if (!ObjectUtils.isEmpty(responseStr)) {
|
||||
JSONObject jSONObject = JSONObject.parseObject(responseStr);
|
||||
if (!ObjectUtils.isEmpty(jSONObject) && !CollectionUtils.isEmpty(weChatFerryProperties.getThirdPartyOkCodes())) {
|
||||
Map<String, String> codeMap = weChatFerryProperties.getThirdPartyOkCodes();
|
||||
for (Map.Entry<String, String> entry : codeMap.entrySet()) {
|
||||
if (!ObjectUtils.isEmpty(jSONObject.get(entry.getKey())) && jSONObject.get(entry.getKey()).equals(entry.getValue())) {
|
||||
passFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return passFlag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
Vendored
+84
@@ -0,0 +1,84 @@
|
||||
package com.wechat.ferry.strategy.msg.receive;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.wechat.ferry.enums.ReceiveMsgChannelEnum;
|
||||
import com.wechat.ferry.exception.BizException;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 策略Context-消息处理-接收消息
|
||||
* 可以切换策略的Context(这里实际是Factory)类
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 14:08
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ReceiveMsgFactory implements InitializingBean {
|
||||
|
||||
private static final Map<String, ReceiveMsgStrategy> strategyContainerMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* spring的上下文
|
||||
*/
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* 实现InitializingBean的方法会在启动的时候执行afterPropertiesSet()方法
|
||||
* 将Strategy的类都按照定义好的规则(fetchKey),放入Map中
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// 初始化时把所有的策略bean放进ioc,用于使用的时候获取
|
||||
Map<String, ReceiveMsgStrategy> strategyMap = applicationContext.getBeansOfType(ReceiveMsgStrategy.class);
|
||||
strategyMap.forEach((k, v) -> {
|
||||
String type = v.getStrategyType();
|
||||
log.debug("[策略Context]-[MessageNoticeSendFactory]-策略类型加载:{}", type);
|
||||
strategyContainerMap.putIfAbsent(type, v);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据策略类型获取不同处理策略类
|
||||
*
|
||||
* @param strategyType 策略类型
|
||||
* @return 策略类
|
||||
*/
|
||||
public static ReceiveMsgStrategy getStrategy(String strategyType) {
|
||||
log.debug("[策略Context]-[ReceiveMsgStrategy]-当前策略类型:{}", strategyType);
|
||||
// 策略类对应的枚举
|
||||
if (!ReceiveMsgChannelEnum.codeMap.containsKey(strategyType)) {
|
||||
// 当前的渠道类型未匹配到
|
||||
log.error("入参中的策略类型:{}不在枚举(ReceiveMsgChannelEnum)定义范围内,请检查数据合法性!", strategyType);
|
||||
// TODO 正常所有的策略都应该在枚举中定义,但考虑到有些人是把项目集成到自己系统中,部分自己的策略类未在枚举中定义,所以这里不抛异常,但是我们建议开启
|
||||
// throw new BizException("当前策略未在枚举中定义,请先在枚举中指定");
|
||||
}
|
||||
ReceiveMsgStrategy handler = strategyContainerMap.get(strategyType);
|
||||
if (handler == null) {
|
||||
log.error("[策略Context]-[MessageNoticeSendFactory]-策略类型:{}-未找到合适的处理器!", strategyType);
|
||||
throw new BizException("未找到合适的处理器!");
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部策略
|
||||
* 用于需要全部执行的情况
|
||||
*
|
||||
* @return 所有的策略类
|
||||
*/
|
||||
public static Map<String, ReceiveMsgStrategy> getAllStrategyContainers() {
|
||||
return strategyContainerMap;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
package com.wechat.ferry.strategy.msg.receive;
|
||||
|
||||
import com.wechat.ferry.entity.dto.WxPpMsgDTO;
|
||||
|
||||
/**
|
||||
* 策略接口-消息处理-接收消息处理
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 14:07
|
||||
*/
|
||||
public interface ReceiveMsgStrategy {
|
||||
|
||||
/**
|
||||
* 获取策略的类型
|
||||
*
|
||||
* @return 返回代表策略类型的字符串
|
||||
*/
|
||||
String getStrategyType();
|
||||
|
||||
/**
|
||||
* 具体的处理
|
||||
*
|
||||
* @return 如果是多字段,可以转为JSON字符串返回,已适配不同的返回数据
|
||||
*/
|
||||
String doHandle(WxPpMsgDTO dto);
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.wechat.ferry.strategy.msg.receive.impl;
|
||||
|
||||
import com.wechat.ferry.entity.dto.WxPpMsgDTO;
|
||||
import com.wechat.ferry.enums.ReceiveMsgChannelEnum;
|
||||
import com.wechat.ferry.strategy.msg.receive.ReceiveMsgStrategy;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 策略实现类-接收消息-签到处理
|
||||
*
|
||||
* @author chandler
|
||||
* @date 2024-12-25 14:19
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SignInMsgStrategyImpl implements ReceiveMsgStrategy {
|
||||
|
||||
@Override
|
||||
public String getStrategyType() {
|
||||
log.debug("[接收消息]-[签到处理]-匹配到:{}-{}-策略", ReceiveMsgChannelEnum.SIGN_IN.getCode(), ReceiveMsgChannelEnum.SIGN_IN.getName());
|
||||
return ReceiveMsgChannelEnum.SIGN_IN.getCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doHandle(WxPpMsgDTO dto) {
|
||||
// TODO 这里写具体的操作
|
||||
// 当前是使用的所有策略类全部执行 所以这里需要控制哪种类型才处理
|
||||
log.info("签到处理");
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
package com.wechat.ferry.task;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.wechat.ferry.aggregation.facade.ContactDo;
|
||||
import com.wechat.ferry.config.WeChatFerryProperties;
|
||||
import com.wechat.ferry.enums.WxContactsTypeEnum;
|
||||
import com.wechat.ferry.handle.WeChatSocketClient;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ContactGroupMonitorTask {
|
||||
|
||||
private WeChatSocketClient wechatSocketClient;
|
||||
|
||||
@Autowired
|
||||
public void setWechatSocketClient(WeChatSocketClient wechatSocketClient) {
|
||||
this.wechatSocketClient = wechatSocketClient;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private WeChatFerryProperties weChatFerryProperties;
|
||||
|
||||
/**
|
||||
* 全部联系人信息集合 key:微信标识-weChatUid val:联系人信息
|
||||
*/
|
||||
private final Map<String, ContactDo> allContactDoMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 个微联系人信息集合 key:微信标识-weChatUid val:联系人信息
|
||||
*/
|
||||
private final Map<String, String> ppContactDoMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 企微联系人信息集合 key:微信标识-weChatUid val:联系人信息
|
||||
*/
|
||||
private final Map<String, String> cpContactDoMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 群组信息集合 key:群ID val:群名称
|
||||
*/
|
||||
private final Map<String, String> groupMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 群成员信息集合 key:群ID val:微信标识-weChatUid
|
||||
*/
|
||||
private final Map<String, Map<String, String>> groupMemberMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 初始化状态
|
||||
*/
|
||||
private Boolean initStatus = false;
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void scheduled() {
|
||||
if (true) {
|
||||
// 目前查询的所有的联系人,未判断群组是否已退出等状态,故该功能暂不启用,仅提供一个小样例
|
||||
return;
|
||||
}
|
||||
ContactDo contactDo = new ContactDo();
|
||||
// 查询联系人
|
||||
List<ContactDo> contactList = contactDo.queryContactListBySql(wechatSocketClient, weChatFerryProperties);
|
||||
log.info("[定时任务]-[联系人群组监控]-{}", contactList.size());
|
||||
// 调用联系人监控处理
|
||||
contactMonitor(contactList);
|
||||
log.info("[定时任务]-[联系人群组监控]-结束");
|
||||
}
|
||||
|
||||
// 联系人监控
|
||||
private void contactMonitor(List<ContactDo> contactList) {
|
||||
// 新增个微联系人
|
||||
List<String> addPpContactList = new ArrayList<>();
|
||||
// 删除个微联系人
|
||||
List<String> deletePpContactList = new ArrayList<>();
|
||||
// 新增企微联系人
|
||||
List<String> addCpContactList = new ArrayList<>();
|
||||
// 删除企微联系人
|
||||
List<String> deleteCpContactList = new ArrayList<>();
|
||||
// 新增群组
|
||||
List<String> addGroupList = new ArrayList<>();
|
||||
// 退出群组
|
||||
List<String> deleteGroupList = new ArrayList<>();
|
||||
// 本次个微联系人标识列表
|
||||
List<String> nowPpContactIdList = new ArrayList<>();
|
||||
// 本次企微联系人标识列表
|
||||
List<String> nowCpContactIdList = new ArrayList<>();
|
||||
// 本次群组标识列表
|
||||
List<String> nowGroupIdList = new ArrayList<>();
|
||||
|
||||
// 开始匹配
|
||||
if (!CollectionUtils.isEmpty(contactList)) {
|
||||
// 判断全部联系人是否为空
|
||||
if (allContactDoMap.isEmpty()) {
|
||||
for (ContactDo contactDo : contactList) {
|
||||
// 首次初始化
|
||||
allContactDoMap.put(contactDo.getWeChatUid(), contactDo);
|
||||
if (WxContactsTypeEnum.PERSON.getCode().equals(contactDo.getContactType())) {
|
||||
// 个微-初始化
|
||||
ppContactDoMap.put(contactDo.getWeChatUid(), contactDo.getNickname());
|
||||
} else if (WxContactsTypeEnum.WORK.getCode().equals(contactDo.getContactType())) {
|
||||
// 企业微信-初始化
|
||||
cpContactDoMap.put(contactDo.getWeChatUid(), contactDo.getNickname());
|
||||
} else if (WxContactsTypeEnum.GROUP.getCode().equals(contactDo.getContactType())) {
|
||||
// 群组-初始化
|
||||
groupMap.put(contactDo.getWeChatUid(), contactDo.getNickname());
|
||||
}
|
||||
}
|
||||
log.info("[定时任务]-[联系人监控]-首次初始化成功");
|
||||
} else {
|
||||
// 检测新增联系人
|
||||
for (ContactDo contactDo : contactList) {
|
||||
if (WxContactsTypeEnum.PERSON.getCode().equals(contactDo.getContactType())) {
|
||||
// 个微
|
||||
nowPpContactIdList.add(contactDo.getWeChatUid());
|
||||
if (!ppContactDoMap.containsKey(contactDo.getWeChatUid())) {
|
||||
// 个微-新增
|
||||
addPpContactList.add(contactDo.getWeChatUid());
|
||||
ppContactDoMap.put(contactDo.getWeChatUid(), contactDo.getNickname());
|
||||
}
|
||||
} else if (WxContactsTypeEnum.WORK.getCode().equals(contactDo.getContactType())) {
|
||||
// 企业微信
|
||||
nowCpContactIdList.add(contactDo.getWeChatUid());
|
||||
if (!cpContactDoMap.containsKey(contactDo.getWeChatUid())) {
|
||||
// 企业微信-新增
|
||||
addCpContactList.add(contactDo.getWeChatUid());
|
||||
cpContactDoMap.put(contactDo.getWeChatUid(), contactDo.getNickname());
|
||||
}
|
||||
} else if (WxContactsTypeEnum.GROUP.getCode().equals(contactDo.getContactType())) {
|
||||
// 群组
|
||||
nowGroupIdList.add(contactDo.getWeChatUid());
|
||||
if (!groupMap.containsKey(contactDo.getWeChatUid())) {
|
||||
// 群组-新增
|
||||
addGroupList.add(contactDo.getWeChatUid());
|
||||
groupMap.put(contactDo.getWeChatUid(), contactDo.getNickname());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化完成
|
||||
if (initStatus) {
|
||||
// 个微
|
||||
for (Map.Entry<String, String> entry : ppContactDoMap.entrySet()) {
|
||||
if (!nowPpContactIdList.contains(entry.getKey())) {
|
||||
// 个微-删除
|
||||
deletePpContactList.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
// 企微
|
||||
for (Map.Entry<String, String> entry : cpContactDoMap.entrySet()) {
|
||||
if (!nowCpContactIdList.contains(entry.getKey())) {
|
||||
// 企微-删除
|
||||
deleteCpContactList.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
// 群组
|
||||
for (Map.Entry<String, String> entry : groupMap.entrySet()) {
|
||||
if (!nowGroupIdList.contains(entry.getKey())) {
|
||||
// 群组-删除
|
||||
deleteGroupList.add(entry.getKey());
|
||||
log.info("\"{}\"离开了群聊");
|
||||
}
|
||||
}
|
||||
log.info("[定时任务]-[联系人监控]-个微新增:{},个微删除:{},企微新增:{},企微删除:{},群组新增:{},群组删除:{}", addPpContactList, deletePpContactList, addCpContactList,
|
||||
deleteCpContactList, addGroupList, deleteGroupList);
|
||||
}
|
||||
}
|
||||
initStatus = true;
|
||||
}
|
||||
|
||||
// 监控群成员
|
||||
private void groupMemberMonitor() {
|
||||
if (!groupMap.isEmpty()) {
|
||||
List<String> groupIdList = new ArrayList<>(groupMap.keySet());
|
||||
for (String groupId : groupIdList) {
|
||||
// 查询
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
package com.wechat.ferry.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* HTTP请求类
|
||||
*/
|
||||
@Slf4j
|
||||
@SuppressWarnings("all")
|
||||
public class HttpClientUtil {
|
||||
|
||||
/**
|
||||
* 带参数的get请求
|
||||
*
|
||||
* @param url
|
||||
* @param param
|
||||
* @return String
|
||||
*/
|
||||
public static String doGet(String url, Map<String, String> param) {
|
||||
// 创建Httpclient对象
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
|
||||
String resultString = "";
|
||||
CloseableHttpResponse response = null;
|
||||
try {
|
||||
// 创建uri
|
||||
URIBuilder builder = new URIBuilder(url);
|
||||
if (param != null) {
|
||||
for (String key : param.keySet()) {
|
||||
builder.addParameter(key, param.get(key));
|
||||
}
|
||||
}
|
||||
URI uri = builder.build();
|
||||
// 创建http GET请求
|
||||
HttpGet httpGet = new HttpGet(uri);
|
||||
// 执行请求
|
||||
response = httpclient.execute(httpGet);
|
||||
// 判断返回状态是否为200
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
httpclient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return resultString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不带参数的get请求
|
||||
*
|
||||
* @param url
|
||||
* @return String
|
||||
*/
|
||||
public static String doGet(String url) {
|
||||
return doGet(url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带参数的post请求
|
||||
*
|
||||
* @param url
|
||||
* @param param
|
||||
* @return String
|
||||
*/
|
||||
public static String doPost(String url, Map<String, String> param) {
|
||||
// 创建Httpclient对象
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
CloseableHttpResponse response = null;
|
||||
String resultString = "";
|
||||
try {
|
||||
// 创建Http Post请求
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
// 创建参数列表
|
||||
if (param != null) {
|
||||
List<NameValuePair> paramList = new ArrayList<>();
|
||||
for (String key : param.keySet()) {
|
||||
paramList.add(new BasicNameValuePair(key, param.get(key)));
|
||||
}
|
||||
// 模拟表单
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
|
||||
httpPost.setEntity(entity);
|
||||
}
|
||||
// 执行http请求
|
||||
response = httpClient.execute(httpPost);
|
||||
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return resultString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不带参数的post请求
|
||||
*
|
||||
* @param url
|
||||
* @return String
|
||||
*/
|
||||
public static String doPost(String url) {
|
||||
return doPost(url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 传送json类型的post请求
|
||||
*
|
||||
* @param url
|
||||
* @param json
|
||||
* @return String
|
||||
*/
|
||||
public static String doPostJson(String url, String json) {
|
||||
// 创建Httpclient对象
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
CloseableHttpResponse response = null;
|
||||
String resultString = "";
|
||||
try {
|
||||
// 创建Http Post请求
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
// 创建请求内容
|
||||
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
|
||||
httpPost.setEntity(entity);
|
||||
// 执行http请求
|
||||
response = httpClient.execute(httpPost);
|
||||
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return resultString;
|
||||
}
|
||||
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
package com.wechat.ferry.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class XmlJsonConvertUtil {
|
||||
|
||||
private static final String DEFAULT_ATTRIBUTE_PREFIX = "_";
|
||||
private static final String DEFAULT_VALUE_PREFIX = "_text";
|
||||
|
||||
public static String readFile(String path) throws Exception {
|
||||
File file = new File(path);
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
FileChannel fc = fis.getChannel();
|
||||
ByteBuffer bb = ByteBuffer.allocate(new Long(file.length()).intValue());
|
||||
// fc向buffer中读入数据
|
||||
fc.read(bb);
|
||||
bb.flip();
|
||||
String str = new String(bb.array(), StandardCharsets.UTF_8);
|
||||
fc.close();
|
||||
fis.close();
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* xml转json
|
||||
*
|
||||
* @param xmlStr
|
||||
* @return
|
||||
* @throws DocumentException
|
||||
*/
|
||||
public static JSONObject xml2Json(String xmlStr) {
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
Document doc = DocumentHelper.parseText(xmlStr);
|
||||
dom4j2Json(doc.getRootElement(), json);
|
||||
|
||||
// 存放根节点
|
||||
if (!ObjectUtils.isEmpty(json)) {
|
||||
Element rootElement = doc.getRootElement();
|
||||
JSONObject wrapperJson = new JSONObject();
|
||||
wrapperJson.put(rootElement.getName(), json);
|
||||
json = wrapperJson;
|
||||
}
|
||||
} catch (DocumentException e) {
|
||||
log.error("转换失败:", e);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* xml转json
|
||||
*
|
||||
* @param element
|
||||
* @param json
|
||||
*/
|
||||
public static void dom4j2Json(Element element, JSONObject json) {
|
||||
// 如果是属性
|
||||
for (Object o : element.attributes()) {
|
||||
Attribute attr = (Attribute)o;
|
||||
if (!isEmpty(attr.getValue())) {
|
||||
json.put(DEFAULT_ATTRIBUTE_PREFIX + attr.getName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
List<Element> chdEl = element.elements();
|
||||
if (chdEl.isEmpty() && !isEmpty(element.getText())) {
|
||||
// 如果没有子元素,只有一个值
|
||||
json.put(element.getName(), element.getText());
|
||||
}
|
||||
|
||||
for (Element e : chdEl) {
|
||||
// 有子元素
|
||||
if (!e.elements().isEmpty()) {
|
||||
// 子元素也有子元素
|
||||
JSONObject chdjson = new JSONObject();
|
||||
dom4j2Json(e, chdjson);
|
||||
Object o = json.get(e.getName());
|
||||
if (o != null) {
|
||||
JSONArray jsona = null;
|
||||
if (o instanceof JSONObject) {
|
||||
// 如果此元素已存在,则转为jsonArray
|
||||
JSONObject jsono = (JSONObject)o;
|
||||
json.remove(e.getName());
|
||||
jsona = new JSONArray();
|
||||
jsona.add(jsono);
|
||||
jsona.add(chdjson);
|
||||
}
|
||||
if (o instanceof JSONArray) {
|
||||
jsona = (JSONArray)o;
|
||||
jsona.add(chdjson);
|
||||
}
|
||||
json.put(e.getName(), jsona);
|
||||
} else {
|
||||
if (!chdjson.isEmpty()) {
|
||||
json.put(e.getName(), chdjson);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// 子元素没有子元素
|
||||
for (Object o : element.attributes()) {
|
||||
Attribute attr = (Attribute)o;
|
||||
if (!isEmpty(attr.getValue())) {
|
||||
json.put(DEFAULT_ATTRIBUTE_PREFIX + attr.getName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
// 判断是否包含属性
|
||||
// if (!CollectionUtils.isEmpty(e.attributes())) {
|
||||
// for (Object o : e.attributes()) {
|
||||
// Attribute attr = (Attribute)o;
|
||||
// if (!isEmpty(attr.getValue())) {
|
||||
// json.put(DEFAULT_ATTRIBUTE_PREFIX + attr.getName(), attr.getValue());
|
||||
// }
|
||||
// if (!e.getText().isEmpty()) {
|
||||
// json.put(DEFAULT_VALUE_PREFIX, e.getText());
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
if (!e.getText().isEmpty()) {
|
||||
json.put(e.getName(), e.getText());
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String str) {
|
||||
if (str == null || str.trim().isEmpty() || "null".equals(str)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String xml = "<msg><appmsg appid=\"\" sdkver=\"0\"><title>就是个网页哇</title><des /><username /></appmsg></msg>";
|
||||
|
||||
log.info("xml格式化前:{}", xml);
|
||||
xml = xml.replaceAll(">[\\s\\p{Zs}]*<", "><");
|
||||
log.info("xml格式化后:{}", xml);
|
||||
JSONObject json = xml2Json(xml);
|
||||
System.out.println("xml2Json:" + json.toJSONString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
# 配置文件
|
||||
|
||||
# 服务端配置
|
||||
server:
|
||||
# 端口设置
|
||||
port: 9201
|
||||
|
||||
spring:
|
||||
# 配置应用信息
|
||||
application:
|
||||
# 应用名
|
||||
name: wcf-bmc
|
||||
# swagger适配
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
|
||||
# 本服务参数
|
||||
wechat:
|
||||
ferry:
|
||||
# DLL文件位置
|
||||
dll-path: E:\WeChatFerry\clients\java\wcf-bmc\dll\sdk.dll
|
||||
# socket端口
|
||||
socket-port: 10086
|
||||
# SDK是否调试模式
|
||||
sdk-debug-switch: false
|
||||
# 联系人类型-官方杂号,禁止与其他分类重复(格式:代码|名称)
|
||||
contacts-type-mixed:
|
||||
- filehelper|文件传输助手
|
||||
# 联系人类型-公众号,禁止与其他分类重复(格式:代码|名称)
|
||||
contacts-type-official:
|
||||
- weixinguanhaozhushou|微信公众平台
|
||||
# 接收消息回调开关
|
||||
open-msg-group-switch: false
|
||||
# 需要开启消息处理的群
|
||||
open-msg-groups:
|
||||
# key:群编号 val:开启的功能号,对应ReceiveMsgChannelEnum枚举中的code
|
||||
ALL: '1'
|
||||
53257911730@chatroom: '1,2'
|
||||
# 接收消息回调开关
|
||||
receive-msg-callback-switch: false
|
||||
# 接收消息回调地址
|
||||
receive-msg-callback-urls:
|
||||
- http://localhost:9001/msg
|
||||
# 发送消息回调标识 1-关闭 2-全部回调 3-发送成功才回调
|
||||
send-msg-callback-flag: '1'
|
||||
# 发送消息回调地址
|
||||
send-msg-callback-urls:
|
||||
- http://localhost:9001/msg
|
||||
# 调用第三方服务客户端成功状态码
|
||||
third-party-ok-codes:
|
||||
# key:状态码字段 val:状态码值
|
||||
code: '200'
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration debug="false" scan="false">
|
||||
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
|
||||
<property name="log.path" value="logs/${spring.application.name}"/>
|
||||
<property name="log.name" value="${spring.application.name}"/>
|
||||
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- Console log output -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file debug output -->
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 追加方式记录日志 -->
|
||||
<append>true</append>
|
||||
<!-- 日志文件的格式 -->
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file error output -->
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 追加方式记录日志 -->
|
||||
<append>true</append>
|
||||
<!-- 日志文件的格式 -->
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
<!-- 此日志文件只记录error级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!--
|
||||
DEBUG:输出调试信息;指出细粒度信息事件对调试应用程序是非常有帮助的。
|
||||
INFO: 输出提示信息;消息在粗粒度级别上突出强调应用程序的运行过程。
|
||||
WARN: 输出警告信息;表明会出现潜在错误的情形。
|
||||
ERROR:输出错误信息;指出虽然发生错误事件,但仍然不影响系统的继续运行。
|
||||
FATAL: 输出致命错误;指出每个严重的错误事件将会导致应用程序的退出。
|
||||
ALL level:打开所有日志记录开关;是最低等级的,用于打开所有日志记录。
|
||||
OFF level:关闭所有日志记录开关;是最高等级的,用于关闭所有日志记录。
|
||||
日志级别(按照范围从小到大排序):OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL
|
||||
范围大的会包含范围小的,例如日志设置为INFO级别的话则FATAL、ERROR、WARN、INFO的日志开关都是打开的,而DEBUG的日志开关将是关闭的。
|
||||
-->
|
||||
<!--
|
||||
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、以及指定<appender>。
|
||||
<logger>仅有一个name属性,
|
||||
一个可选的level和一个可选的addtivity属性。
|
||||
name:用来指定受此logger约束的某一个包或者具体的某一个类。
|
||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
|
||||
如果未设置此属性,那么当前logger将会继承上级的级别。
|
||||
-->
|
||||
|
||||
<!-- 日志监听器 屏蔽 -->
|
||||
<logger name="org.springframework.boot.autoconfigure.logging" level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
<!-- httpclient 屏蔽 -->
|
||||
<logger name="org.apache" level="OFF">
|
||||
<appender-ref ref="error"/>
|
||||
</logger>
|
||||
<logger name="httpclient" level="OFF">
|
||||
<appender-ref ref="error"/>
|
||||
</logger>
|
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="debug"/>
|
||||
<appender-ref ref="error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
@@ -0,0 +1,259 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package wcf;
|
||||
option java_package = "com.wechat.ferry.entity.proto";
|
||||
|
||||
enum Functions {
|
||||
FUNC_RESERVED = 0x00;
|
||||
FUNC_IS_LOGIN = 0x01;
|
||||
FUNC_GET_SELF_WXID = 0x10;
|
||||
FUNC_GET_MSG_TYPES = 0x11;
|
||||
FUNC_GET_CONTACTS = 0x12;
|
||||
FUNC_GET_DB_NAMES = 0x13;
|
||||
FUNC_GET_DB_TABLES = 0x14;
|
||||
FUNC_GET_USER_INFO = 0x15;
|
||||
FUNC_GET_AUDIO_MSG = 0x16;
|
||||
FUNC_SEND_TXT = 0x20;
|
||||
FUNC_SEND_IMG = 0x21;
|
||||
FUNC_SEND_FILE = 0x22;
|
||||
FUNC_SEND_XML = 0x23;
|
||||
FUNC_SEND_EMOTION = 0x24;
|
||||
FUNC_SEND_RICH_TXT = 0x25;
|
||||
FUNC_SEND_PAT_MSG = 0x26;
|
||||
FUNC_FORWARD_MSG = 0x27;
|
||||
FUNC_ENABLE_RECV_TXT = 0x30;
|
||||
FUNC_DISABLE_RECV_TXT = 0x40;
|
||||
FUNC_EXEC_DB_QUERY = 0x50;
|
||||
FUNC_ACCEPT_FRIEND = 0x51;
|
||||
FUNC_RECV_TRANSFER = 0x52;
|
||||
FUNC_REFRESH_PYQ = 0x53;
|
||||
FUNC_DOWNLOAD_ATTACH = 0x54;
|
||||
FUNC_GET_CONTACT_INFO = 0x55;
|
||||
FUNC_REVOKE_MSG = 0x56;
|
||||
FUNC_REFRESH_QRCODE = 0x57;
|
||||
FUNC_DECRYPT_IMAGE = 0x60;
|
||||
FUNC_EXEC_OCR = 0x61;
|
||||
FUNC_ADD_ROOM_MEMBERS = 0x70;
|
||||
FUNC_DEL_ROOM_MEMBERS = 0x71;
|
||||
FUNC_INV_ROOM_MEMBERS = 0x72;
|
||||
FUNC_SHUTDOWN = 0xFF;
|
||||
}
|
||||
|
||||
message Request
|
||||
{
|
||||
Functions func = 1;
|
||||
oneof msg
|
||||
{
|
||||
Empty empty = 2; // 无参数
|
||||
string str = 3; // 字符串
|
||||
TextMsg txt = 4; // 发送文本消息结构
|
||||
PathMsg file = 5; // 发送图片、文件消息结构
|
||||
DbQuery query = 6; // 数据库查询参数结构
|
||||
Verification v = 7; // 通过好友验证参数结构
|
||||
MemberMgmt m = 8; // 群成员管理,添加、删除、邀请
|
||||
XmlMsg xml = 9; // XML参数结构
|
||||
DecPath dec = 10; // 解密图片参数结构
|
||||
Transfer tf = 11; // 接收转账参数结构
|
||||
uint64 ui64 = 12 [ jstype = JS_STRING ]; // 64 位整数,通用
|
||||
bool flag = 13; // 布尔值
|
||||
AttachMsg att = 14; // 下载图片、视频、文件参数结构
|
||||
AudioMsg am = 15; // 保存语音参数结构
|
||||
RichText rt = 16; // 发送卡片消息结构
|
||||
PatMsg pm = 17; // 发送拍一拍参数结构
|
||||
ForwardMsg fm = 18; // 转发消息参数结构
|
||||
}
|
||||
}
|
||||
|
||||
message Response
|
||||
{
|
||||
Functions func = 1;
|
||||
oneof msg
|
||||
{
|
||||
int32 status = 2; // Int 状态,通用
|
||||
string str = 3; // 字符串
|
||||
WxMsg wxmsg = 4; // 微信消息
|
||||
MsgTypes types = 5; // 消息类型
|
||||
RpcContacts contacts = 6; // 联系人
|
||||
DbNames dbs = 7; // 数据库列表
|
||||
DbTables tables = 8; // 表列表
|
||||
DbRows rows = 9; // 行列表
|
||||
UserInfo ui = 10; // 个人信息
|
||||
OcrMsg ocr = 11; // OCR 结果
|
||||
};
|
||||
}
|
||||
|
||||
message Empty { }
|
||||
|
||||
message WxMsg
|
||||
{
|
||||
bool is_self = 1; // 是否自己发送的
|
||||
bool is_group = 2; // 是否群消息
|
||||
uint64 id = 3 [ jstype = JS_STRING ]; // 消息 id
|
||||
uint32 type = 4; // 消息类型
|
||||
uint32 ts = 5; // 消息类型
|
||||
string roomid = 6; // 群 id(如果是群消息的话)
|
||||
string content = 7; // 消息内容
|
||||
string sender = 8; // 消息发送者
|
||||
string sign = 9; // Sign
|
||||
string thumb = 10; // 视频或图片消息的缩略图路径
|
||||
string extra = 11; // 附加内容,视频或图片消息的路径
|
||||
string xml = 12; // 消息 xml 部分
|
||||
}
|
||||
|
||||
message TextMsg
|
||||
{
|
||||
string msg = 1; // 要发送的消息内容
|
||||
string receiver = 2; // 消息接收人,当为群时可@
|
||||
string aters = 3; // 要@的人列表,逗号分隔
|
||||
}
|
||||
|
||||
message PathMsg
|
||||
{
|
||||
string path = 1; // 要发送的图片的路径
|
||||
string receiver = 2; // 消息接收人
|
||||
}
|
||||
|
||||
message XmlMsg
|
||||
{
|
||||
string receiver = 1; // 消息接收人
|
||||
string content = 2; // xml 内容
|
||||
string path = 3; // 图片路径
|
||||
uint64 type = 4; // 消息类型
|
||||
}
|
||||
|
||||
message MsgTypes { map<int32, string> types = 1; }
|
||||
|
||||
message RpcContact
|
||||
{
|
||||
string wxid = 1; // 微信 id
|
||||
string code = 2; // 微信号
|
||||
string remark = 3; // 备注
|
||||
string name = 4; // 微信昵称
|
||||
string country = 5; // 国家
|
||||
string province = 6; // 省/州
|
||||
string city = 7; // 城市
|
||||
int32 gender = 8; // 性别
|
||||
}
|
||||
message RpcContacts { repeated RpcContact contacts = 1; }
|
||||
|
||||
message DbNames { repeated string names = 1; }
|
||||
|
||||
message DbTable
|
||||
{
|
||||
string name = 1; // 表名
|
||||
string sql = 2; // 建表 SQL
|
||||
}
|
||||
message DbTables { repeated DbTable tables = 1; }
|
||||
|
||||
message DbQuery
|
||||
{
|
||||
string db = 1; // 目标数据库
|
||||
string sql = 2; // 查询 SQL
|
||||
}
|
||||
|
||||
message DbField
|
||||
{
|
||||
int32 type = 1; // 字段类型
|
||||
string column = 2; // 字段名称
|
||||
bytes content = 3; // 字段内容
|
||||
}
|
||||
message DbRow { repeated DbField fields = 1; }
|
||||
message DbRows { repeated DbRow rows = 1; }
|
||||
|
||||
message Verification
|
||||
{
|
||||
string v3 = 1; // 加密的用户名
|
||||
string v4 = 2; // Ticket
|
||||
int32 scene = 3; // 添加方式:17 名片,30 扫码
|
||||
}
|
||||
|
||||
message MemberMgmt
|
||||
{
|
||||
string roomid = 1; // 要加的群ID
|
||||
string wxids = 2; // 要加群的人列表,逗号分隔
|
||||
}
|
||||
|
||||
message UserInfo
|
||||
{
|
||||
string wxid = 1; // 微信ID
|
||||
string name = 2; // 昵称
|
||||
string mobile = 3; // 手机号
|
||||
string home = 4; // 文件/图片等父路径
|
||||
string alias = 5; // 修改后的wxid
|
||||
}
|
||||
|
||||
message DecPath
|
||||
{
|
||||
string src = 1; // 源路径
|
||||
string dst = 2; // 目标路径
|
||||
}
|
||||
|
||||
message Transfer
|
||||
{
|
||||
string wxid = 1; // 转账人
|
||||
string tfid = 2; // 转账id transferid
|
||||
string taid = 3; // Transaction id
|
||||
}
|
||||
|
||||
message AttachMsg
|
||||
{
|
||||
uint64 id = 1 [ jstype = JS_STRING ]; // 消息 id
|
||||
string thumb = 2; // 消息中的 thumb
|
||||
string extra = 3; // 消息中的 extra
|
||||
}
|
||||
|
||||
message AudioMsg
|
||||
{
|
||||
uint64 id = 1 [ jstype = JS_STRING ]; // 语音消息 id
|
||||
string dir = 2; // 存放目录
|
||||
}
|
||||
|
||||
message RichText
|
||||
{
|
||||
string name = 1; // 显示名字
|
||||
string account = 2; // 公众号 id
|
||||
string title = 3; // 标题
|
||||
string digest = 4; // 摘要
|
||||
string url = 5; // 链接
|
||||
string thumburl = 6; // 缩略图
|
||||
string receiver = 7; // 接收人
|
||||
}
|
||||
|
||||
message PatMsg
|
||||
{
|
||||
string roomid = 1; // 群 id
|
||||
string wxid = 2; // wxid
|
||||
}
|
||||
|
||||
message OcrMsg
|
||||
{
|
||||
int32 status = 1; // 状态
|
||||
string result = 2; // 结果
|
||||
}
|
||||
|
||||
message ForwardMsg
|
||||
{
|
||||
uint64 id = 1 [ jstype = JS_STRING ]; // 待转发消息 ID
|
||||
string receiver = 2; // 转发接收目标,群为 roomId,个人为 wxid
|
||||
}
|
||||
|
||||
// RoomData内部转换
|
||||
message RoomData
|
||||
{
|
||||
message RoomMember {
|
||||
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; // 管理员
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file !.gitkeep
|
||||
Binary file not shown.
Reference in new issue
Block a user