常见的方法和请求

This commit is contained in:
王涛 2023-06-01 10:22:56 +08:00
parent 391011b696
commit 51498cde8a
17 changed files with 103 additions and 26 deletions

View File

@ -1,11 +1,17 @@
package com.example.wxhk.infe;
import io.vertx.core.json.JsonObject;
/**
* http接口请求的基础接口
*
* @author wt
* @date 2023/06/01
*/
public interface SendMsg extends java.io.Serializable{
public interface SendMsg<T> extends java.io.Serializable{
default JsonObject toJson(){
return JsonObject.mapFrom(this);
}
}

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class AddFriends implements SendMsg {
public class AddFriends implements SendMsg<AddFriends> {
String wxid;
/**
* 验证信息

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class ConfirmThePayment implements SendMsg {
public class ConfirmThePayment implements SendMsg<ConfirmThePayment> {
/**
* 转账人微信id从hook的消息中获取
*/

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class FindWeChat implements SendMsg {
public class FindWeChat implements SendMsg<FindWeChat> {
/**
* 通过 手机或qq查询信息
*/

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class ForwardMessages implements SendMsg {
public class ForwardMessages implements SendMsg<ForwardMessages> {
/**
* 消息接收人wxid
*/

View File

@ -11,6 +11,6 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class GetGroupMembers implements SendMsg {
public class GetGroupMembers implements SendMsg<GetGroupMembers> {
String chatRoomId;
}

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class GetsTheNicknameOfAGroupMember implements SendMsg {
public class GetsTheNicknameOfAGroupMember implements SendMsg<GetsTheNicknameOfAGroupMember> {
/**
* 聊天室id
*/

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class IncreaseGroupMembership implements SendMsg {
public class IncreaseGroupMembership implements SendMsg<IncreaseGroupMembership> {
/**
* 聊天室id
*/

View File

@ -0,0 +1,18 @@
package com.example.wxhk.model.request;
import com.example.wxhk.infe.SendMsg;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 开启hook
*
* @author wt
* @date 2023/06/01
*/
@Data
@Accessors(chain = true)
public class OpenHook implements SendMsg<OpenHook> {
String port;
String ip;
}

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class SendAtText implements SendMsg {
public class SendAtText implements SendMsg<SendAtText> {
/**
* 聊天室id,群聊用
*/

View File

@ -12,7 +12,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class SendFile implements SendMsg {
public class SendFile implements SendMsg<SendFile> {
String wxid;
/**
* 发送文件路径

View File

@ -12,7 +12,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class SendImg implements SendMsg {
public class SendImg implements SendMsg<SendImg> {
String wxid;
/**
* 发送图片接口

View File

@ -12,7 +12,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class SendText implements SendMsg {
public class SendText implements SendMsg<SendText> {
String wxid;
String msg;
}

View File

@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class ThroughFriends implements SendMsg {
public class ThroughFriends implements SendMsg<ThroughFriends> {
/**
* 添加好友消息内容里的encryptusername
*/

View File

@ -53,6 +53,7 @@ public class HttpAsyncUtil {
发送文件("6"),
开启hook("9"),
关闭hook("10"),
添加好友("20"),
通过好友申请("23"),
获取群成员("25"),
获取群成员昵称("26"),

View File

@ -1,7 +1,7 @@
package com.example.wxhk.util;
import com.example.wxhk.model.PrivateChatMsg;
import com.example.wxhk.model.request.SendMsg;
import com.example.wxhk.model.request.*;
import com.example.wxhk.tcp.vertx.ArrHandle;
import com.example.wxhk.tcp.vertx.InitWeChat;
import io.vertx.core.json.JsonObject;
@ -54,29 +54,40 @@ public class HttpSendUtil {
}
public static JsonObject 发送文本(String wxid,String msg){
public static JsonObject 发送文本(String wxid, String msg) {
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送文本, JsonObject.mapFrom(new SendMsg().setMsg(msg).setWxid(wxid)));
}
public static JsonObject 发送文本(String msg){
return 发送文本(ArrHandle.getPriMsg().getFromUser(),msg);
public static JsonObject 发送文本(String msg) {
return 发送文本(ArrHandle.getPriMsg().getFromUser(), msg);
}
public static JsonObject 发送at文本(String chatRoomId,String wxids,String msg){
public static JsonObject 发送at文本(String chatRoomId, String wxids, String msg) {
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送at文本, JsonObject.mapFrom(new SendMsg().setMsg(msg).setWxids(wxids).setChatRoomId(chatRoomId)));
}
public static JsonObject 发送at文本(String wxids,String msg){
return 发送at文本(ArrHandle.getPriMsg().getFromGroup(),wxids,msg);
public static JsonObject 发送at文本(String wxids, String msg) {
return 发送at文本(ArrHandle.getPriMsg().getFromGroup(), wxids, msg);
}
public static JsonObject 发送图片(String wxid,String msg){
public static JsonObject 发送图片(String wxid, String msg) {
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送图片, JsonObject.mapFrom(new SendMsg().setImagePath(msg).setWxid(wxid)));
}
public static JsonObject 发送图片(String msg){
return 发送图片(ArrHandle.getPriMsg().getFromUser(),msg);
public static JsonObject 发送图片(String msg) {
return 发送图片(ArrHandle.getPriMsg().getFromUser(), msg);
}
public static JsonObject 发送文件(String wxid,String msg){
public static JsonObject 发送文件(String wxid, String msg) {
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送文件, JsonObject.mapFrom(new SendMsg().setFilePath(msg).setWxid(wxid)));
}
public static JsonObject 发送文件(String msg){
return 发送文件(ArrHandle.getPriMsg().getFromUser(),msg);
public static JsonObject 发送文件(String msg) {
return 发送文件(ArrHandle.getPriMsg().getFromUser(), msg);
}
public static JsonObject 添加好友(AddFriends p) {
return HttpSyncUtil.exec(HttpAsyncUtil.Type.添加好友, p.toJson());
}
@ -85,4 +96,39 @@ public class HttpSendUtil {
return exec.getJsonObject("data").getString("wxid");
}
public static JsonObject 联系人列表(){
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.联系人列表, new JsonObject());
return exec.getJsonObject("data");
}
public static JsonObject 开启hook(OpenHook hook){
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.开启hook,hook.toJson());
return exec.getJsonObject("data");
}
@Deprecated
public static com.example.wxhk.infe.SendMsg of(HttpAsyncUtil.Type type) {
switch (type) {
case 检查微信登陆 -> {
}
case 获取登录信息 -> {
}
case 发送文本 -> {
return new SendText();
}
case 发送at文本 -> {
return new SendAtText();
}
case 发送图片 -> {
return new SendImg();
}
case 发送文件 -> {
return new SendFile();
}
}
return new SendText();
}
}

View File

@ -40,5 +40,11 @@ class HttpAsyncUtilTest {
}
ThreadUtil.sync(this);
}
@Test
void exec2() {
}
}