群信息

This commit is contained in:
王涛 2023-06-01 11:13:49 +08:00
parent 74831d9d8b
commit e058879295
7 changed files with 154 additions and 7 deletions

View File

@ -0,0 +1,11 @@
package com.example.wxhk.infe;
/**
* http 响应
* @author wt
* @date 2023/06/01
*/
public interface Resp extends java.io.Serializable{
}

View File

@ -8,13 +8,10 @@ import io.vertx.core.json.JsonObject;
* @author wt
* @date 2023/06/01
*/
@FunctionalInterface
public interface SendMsg<T> extends java.io.Serializable{
default JsonObject toJson(){
return JsonObject.mapFrom(this);
}
T of();
}

View File

@ -0,0 +1,50 @@
package com.example.wxhk.model.response;
import com.example.wxhk.infe.Resp;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* 联系人列表
* @author wt
* @date 2023/06/01
*/
@Data
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ContactList implements Resp {
/**
* code : 1
* data : [{"customAccount":"","delFlag":0,"type":1,"userName":"朋友推荐消息","verifyFlag":0,"wxid":"fmessage"},{"customAccount":"tencent_cloud","delFlag":0,"type":3,"userName":"腾讯云助手","verifyFlag":24,"wxid":"gh_a73e2407e0f8"},{"customAccount":"","delFlag":0,"type":1,"userName":"语音记事本","verifyFlag":0,"wxid":"medianote"},{"customAccount":"","delFlag":0,"type":1,"userName":"漂流瓶","verifyFlag":0,"wxid":"floatbottle"},{"customAccount":"jys-wt","delFlag":0,"type":8651011,"userName":"时光似水戏流年","verifyFlag":0,"wxid":"wxid_gf1fogt5a0pq22"},{"customAccount":"wxzhifu","delFlag":0,"type":3,"userName":"微信支付","verifyFlag":24,"wxid":"gh_3dfda90e39d6"},{"customAccount":"dhkzfr","delFlag":0,"type":3,"userName":"阿芙(代发)","verifyFlag":0,"wxid":"wxid_kh16lri40gzj22"},{"customAccount":"","delFlag":0,"type":3,"userName":"文件传输助手","verifyFlag":0,"wxid":"filehelper"},{"customAccount":"","delFlag":0,"type":3,"userName":"fff","verifyFlag":0,"wxid":"24964676359@chatroom"},{"customAccount":"","delFlag":0,"type":2,"userName":"最美阿芙","verifyFlag":0,"wxid":"23793178249@chatroom"},{"customAccount":"afu943344","delFlag":0,"type":2,"userName":"A-阿芙4号-LOL永劫云顶出租-代发","verifyFlag":0,"wxid":"wxid_1gxthknqbmwv22"},{"customAccount":"","delFlag":0,"type":3,"userName":"微信收款助手","verifyFlag":24,"wxid":"gh_f0a92aa7146c"},{"customAccount":"","delFlag":0,"type":0,"userName":"","verifyFlag":0,"wxid":"25984984710827869@openim"}]
* result : OK
*/
private Integer code;
private String result;
private List<DataBean> data;
@Data
@Accessors(chain = true)
public static class DataBean implements Serializable {
/**
* customAccount :
* delFlag : 0
* type : 1
* userName : 朋友推荐消息
* verifyFlag : 0
* wxid : fmessage
*/
private String customAccount;
private Integer delFlag;
private Integer type;
private String userName;
private Integer verifyFlag;
private String wxid;
}
}

View File

@ -0,0 +1,37 @@
package com.example.wxhk.model.response;
import com.example.wxhk.infe.Resp;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class GroupMembers implements Resp {
/**
* code : 1
* data : {"admin":"wxid_gf1fogt5a0pq22","chatRoomId":"24964676359@chatroom","members":"wxid_gf1fogt5a0pq22^Gwxid_4yr8erik0uho22"}
* result : OK
*/
private Integer code;
private DataBean data;
private String result;
@Data
public static class DataBean implements Serializable {
/**
* admin : wxid_gf1fogt5a0pq22
* chatRoomId : 24964676359@chatroom
* members : wxid_gf1fogt5a0pq22^Gwxid_4yr8erik0uho22
*/
private String admin;
private String chatRoomId;
private String members;
}
}

View File

@ -2,6 +2,8 @@ package com.example.wxhk.util;
import com.example.wxhk.model.PrivateChatMsg;
import com.example.wxhk.model.request.*;
import com.example.wxhk.model.response.ContactList;
import com.example.wxhk.model.response.GroupMembers;
import com.example.wxhk.tcp.vertx.ArrHandle;
import com.example.wxhk.tcp.vertx.InitWeChat;
import io.vertx.core.json.JsonObject;
@ -96,14 +98,24 @@ public class HttpSendUtil {
return exec.getJsonObject("data").getString("wxid");
}
public static JsonObject 联系人列表(){
public static ContactList 联系人列表(){
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.联系人列表, new JsonObject());
return exec.getJsonObject("data");
return exec.mapTo(ContactList.class);
}
public static JsonObject 开启hook(OpenHook hook){
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.开启hook,hook.toJson());
return exec.getJsonObject("data");
return exec;
}
public static JsonObject 关闭hook(){
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.关闭hook,new JsonObject());
return exec;
}
public static GroupMembers 获取群成员(GetGroupMembers p){
return HttpSyncUtil.exec(HttpAsyncUtil.Type.获取群成员, p.toJson()).mapTo(GroupMembers.class);
}
@Deprecated
public static com.example.wxhk.infe.SendMsg of(HttpAsyncUtil.Type type) {

View File

@ -44,6 +44,5 @@ class HttpAsyncUtilTest {
@Test
void exec2() {
}
}

View File

@ -0,0 +1,41 @@
package com.example.wxhk.util;
import com.example.wxhk.model.request.GetGroupMembers;
import com.example.wxhk.model.response.ContactList;
import com.example.wxhk.model.response.GroupMembers;
import org.dromara.hutool.core.lang.Console;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class HttpSendUtilTest {
@Test
void 获取当前登陆微信id() {
String s = HttpSendUtil.获取当前登陆微信id();
}
@Test
void 联系人列表() {
ContactList contactList = HttpSendUtil.联系人列表();
List<ContactList.DataBean> data = contactList.getData();
for (ContactList.DataBean datum : data) {
Console.log(datum.getWxid(),datum.getUserName());
}
Console.log(contactList);
}
@Test
void 开启hook() {
}
@Test
void 获取群成员() {
GroupMembers 获取群成员 = HttpSendUtil.获取群成员(new GetGroupMembers().setChatRoomId("24964676359@chatroom"));
Console.log(获取群成员);
}
}