feat(0): [java]-[wechat-ferry-mvn]-登录信息返回字段修改

This commit is contained in:
chandler 2024-10-06 15:15:01 +08:00
parent adcc05dc7c
commit 96e8fbea19
8 changed files with 114 additions and 32 deletions

View File

@ -2,6 +2,7 @@ package com.wechat.ferry;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* 启动类
@ -9,6 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @author chandler
* @date 2024-09-21 12:19
*/
@EnableScheduling
@SpringBootApplication
public class WeChatFerryApplication {

View File

@ -14,17 +14,18 @@ import com.wechat.ferry.entity.vo.request.WxPpDatabaseSqlReq;
import com.wechat.ferry.entity.vo.request.WxPpDatabaseTableReq;
import com.wechat.ferry.entity.vo.request.WxPpGroupMemberReq;
import com.wechat.ferry.entity.vo.request.WxPpSendCardMsgReq;
import com.wechat.ferry.entity.vo.request.WxPpSendFileMsgReq;
import com.wechat.ferry.entity.vo.request.WxPpSendEmojiMsgReq;
import com.wechat.ferry.entity.vo.request.WxPpSendFileMsgReq;
import com.wechat.ferry.entity.vo.request.WxPpSendImageMsgReq;
import com.wechat.ferry.entity.vo.request.WxPpSendTextMsgReq;
import com.wechat.ferry.entity.vo.response.WxPpContactsResp;
import com.wechat.ferry.entity.vo.response.WxPpDatabaseRowResp;
import com.wechat.ferry.entity.vo.response.WxPpGroupMemberResp;
import com.wechat.ferry.entity.vo.response.WxPpLoginInfoResp;
import com.wechat.ferry.entity.vo.response.WxPpMsgTypeResp;
import com.wechat.ferry.entity.vo.response.WxPpSendCardMsgResp;
import com.wechat.ferry.entity.vo.response.WxPpSendFileMsgResp;
import com.wechat.ferry.entity.vo.response.WxPpSendEmojiMsgResp;
import com.wechat.ferry.entity.vo.response.WxPpSendFileMsgResp;
import com.wechat.ferry.entity.vo.response.WxPpSendImageMsgResp;
import com.wechat.ferry.entity.vo.response.WxPpSendTextMsgResp;
import com.wechat.ferry.enums.ResponseCodeEnum;
@ -60,18 +61,18 @@ public class WeChatDllController {
return TResponse.ok(ResponseCodeEnum.SUCCESS, status);
}
@ApiOperation(value = "获取登录微信", notes = "queryLoginWeChatNo")
@PostMapping(value = "/loginWeChatNo")
public TResponse<Object> queryLoginWeChatNo() {
String weChatNo = weChatDllService.queryLoginWeChatId();
return TResponse.ok(ResponseCodeEnum.SUCCESS, weChatNo);
@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<Object> queryLoginWeChatInfo() {
return TResponse.ok(ResponseCodeEnum.SUCCESS);
public TResponse<WxPpLoginInfoResp> queryLoginWeChatInfo() {
WxPpLoginInfoResp resp = weChatDllService.queryLoginWeChatInfo();
return TResponse.ok(ResponseCodeEnum.SUCCESS, resp);
}
@ApiOperation(value = "获取消息类型", notes = "queryMsgTypeList")

View File

@ -15,16 +15,17 @@ import lombok.Data;
public class WxPpContactsResp {
/**
* 微信编号
* 微信内部识别号UID
* 原始微信账号ID"wxid_"开头初始默认的微信ID=微信号
*/
@ApiModelProperty(value = "微信编号")
private String weChatNo;
@ApiModelProperty(value = "微信内部识别号UID")
private String weChatUid;
/**
* 微信代码
* 微信
*/
@ApiModelProperty(value = "微信代码")
private String weChatCode;
@ApiModelProperty(value = "微信")
private String weChatNo;
/**
* 备注

View File

@ -15,10 +15,11 @@ import lombok.Data;
public class WxPpGroupMemberResp {
/**
* 微信编号
* 微信内部识别号UID
* 原始微信账号ID"wxid_"开头初始默认的微信ID=微信号
*/
@ApiModelProperty(value = "微信编号")
private String weChatNo;
@ApiModelProperty(value = "微信内部识别号UID")
private String weChatUid;
/**
* 微信昵称

View File

@ -0,0 +1,42 @@
package com.wechat.ferry.entity.vo.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 请求出参-登录个微信息
*
* @author chandler
* @date 2024/10/05 22:53
*/
@Data
@ApiModel(value = "wxPpLoginInfoResp", description = "登录个微信息查询请求出参")
public class WxPpLoginInfoResp {
/**
* 微信内部识别号UID
* 原始微信账号ID"wxid_"开头初始默认的微信ID=微信号
*/
@ApiModelProperty(value = "微信内部识别号UID")
private String weChatUid;
/**
* name
*/
@ApiModelProperty(value = "name")
private String name;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private String phone;
/**
* 文件/图片等父路径
*/
@ApiModelProperty(value = "文件/图片等父路径")
private String homePath;
}

View File

@ -13,6 +13,7 @@ import com.wechat.ferry.entity.vo.request.WxPpSendTextMsgReq;
import com.wechat.ferry.entity.vo.response.WxPpContactsResp;
import com.wechat.ferry.entity.vo.response.WxPpDatabaseRowResp;
import com.wechat.ferry.entity.vo.response.WxPpGroupMemberResp;
import com.wechat.ferry.entity.vo.response.WxPpLoginInfoResp;
import com.wechat.ferry.entity.vo.response.WxPpMsgTypeResp;
import com.wechat.ferry.entity.vo.response.WxPpSendCardMsgResp;
import com.wechat.ferry.entity.vo.response.WxPpSendEmojiMsgResp;
@ -39,14 +40,24 @@ public interface WeChatDllService {
Boolean loginStatus();
/**
* 得微信客户端登录的微信ID
* 取登录微信内部识别号UID
*
* @return 微信ID
* @return 微信内部识别号UID
*
* @author chandler
* @date 2024-10-01 21:22
*/
String queryLoginWeChatId();
String queryLoginWeChatUid();
/**
* 获取登录微信信息
*
* @return 当前登录微信信息
*
* @author chandler
* @date 2024-10-05 22:54
*/
WxPpLoginInfoResp queryLoginWeChatInfo();
/**
* 获取所有消息类型

View File

@ -29,6 +29,7 @@ import com.wechat.ferry.entity.vo.response.WxPpContactsResp;
import com.wechat.ferry.entity.vo.response.WxPpDatabaseFieldResp;
import com.wechat.ferry.entity.vo.response.WxPpDatabaseRowResp;
import com.wechat.ferry.entity.vo.response.WxPpGroupMemberResp;
import com.wechat.ferry.entity.vo.response.WxPpLoginInfoResp;
import com.wechat.ferry.entity.vo.response.WxPpMsgTypeResp;
import com.wechat.ferry.entity.vo.response.WxPpSendCardMsgResp;
import com.wechat.ferry.entity.vo.response.WxPpSendEmojiMsgResp;
@ -67,10 +68,24 @@ public class WeChatDllServiceImpl implements WeChatDllService {
}
@Override
public String queryLoginWeChatId() {
String weChatNo = wechatSocketClient.getSelfWxId();
log.info("[查询]-[登录微信编号]-weChatNo:{}", weChatNo);
return weChatNo;
public String queryLoginWeChatUid() {
String weChatUid = wechatSocketClient.getSelfWxId();
log.info("[查询]-[登录微信UID]-weChatUid:{}", weChatUid);
return weChatUid;
}
@Override
public WxPpLoginInfoResp queryLoginWeChatInfo() {
WxPpLoginInfoResp resp = new WxPpLoginInfoResp();
Wcf.UserInfo userInfo = wechatSocketClient.getUserInfo();
if (!ObjectUtils.isEmpty(userInfo)) {
resp.setWeChatUid(userInfo.getWxid());
resp.setName(userInfo.getName());
resp.setPhone(userInfo.getMobile());
resp.setHomePath(userInfo.getHome());
}
log.info("[查询]-[获取登录微信信息]-resp:{}", resp);
return resp;
}
@Override
@ -86,7 +101,7 @@ public class WeChatDllServiceImpl implements WeChatDllService {
list.add(resp);
}
}
log.info("[查询]-[所消息类型]-共查到:{}条", list.size());
log.info("[查询]-[所消息类型]-共查到:{}条", list.size());
return list;
}
@ -97,8 +112,8 @@ public class WeChatDllServiceImpl implements WeChatDllService {
if (!CollectionUtils.isEmpty(rpcContactList)) {
for (Wcf.RpcContact rpcContact : rpcContactList) {
WxPpContactsResp vo = new WxPpContactsResp();
vo.setWeChatNo(rpcContact.getWxid());
vo.setWeChatCode(rpcContact.getCode());
vo.setWeChatUid(rpcContact.getWxid());
vo.setWeChatNo(rpcContact.getCode());
vo.setRemark(rpcContact.getRemark());
vo.setNickName(rpcContact.getName());
if (!ObjectUtils.isEmpty(rpcContact.getCountry())) {
@ -218,12 +233,12 @@ public class WeChatDllServiceImpl implements WeChatDllService {
if ("UserName".equals(dbField.getColumn())) {
vo = new WxPpGroupMemberResp();
String content = (String)converterSqlVal(dbField.getType(), dbField.getContent());
vo.setWeChatNo(content);
vo.setWeChatUid(content);
}
if ("NickName".equals(dbField.getColumn())) {
String content = (String)converterSqlVal(dbField.getType(), dbField.getContent());
vo.setNickName(content);
dbMap.put(vo.getWeChatNo(), vo.getNickName());
dbMap.put(vo.getWeChatUid(), vo.getNickName());
}
}
}
@ -243,7 +258,7 @@ public class WeChatDllServiceImpl implements WeChatDllService {
Wcf.RoomData roomData = Wcf.RoomData.parseFrom(roomDataBytes);
for (Wcf.RoomData.RoomMember member : roomData.getMembersList()) {
vo = new WxPpGroupMemberResp();
vo.setWeChatNo(member.getWxid());
vo.setWeChatUid(member.getWxid());
String nickName = member.getName();
if (ObjectUtils.isEmpty(nickName)) {
// 如果没有设置群昵称则默认为微信名称

View File

@ -14,6 +14,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.wechat.ferry.config.WeChatFerryProperties;
import com.wechat.ferry.entity.dto.WxPpMsgDTO;
import com.wechat.ferry.service.WeChatDllService;
import com.wechat.ferry.service.WeChatExtService;
import com.wechat.ferry.service.WeChatMsgService;
import com.wechat.ferry.utils.HttpClientUtil;
@ -36,6 +37,13 @@ public class WeChatMsgServiceImpl implements WeChatMsgService {
this.weChatDllService = weChatDllService;
}
private WeChatExtService weChatExtService;
@Autowired
public void setWeChatExtService(WeChatExtService weChatExtService) {
this.weChatExtService = weChatExtService;
}
@Resource
private WeChatFerryProperties weChatFerryProperties;
@ -50,6 +58,7 @@ public class WeChatMsgServiceImpl implements WeChatMsgService {
// 指定处理的群聊
if (weChatFerryProperties.getOpenMsgGroups().contains(dto.getRoomId())) {
// TODO 这里可以拓展自己需要的功能
weChatExtService.instructSign(dto);
}
}
log.debug("[收到消息]-[消息内容]-打印:{}", dto);