云控微信开发SDK使用教程--手机微信朋友圈图片上传服务端

简介: 云控微信开发SDK使用教程--手机微信朋友圈图片上传服务端

云控微信开发SDK使用教程--手机微信朋友圈图片上传服务端

case CircleDetailNotice : {//朋友圈图片上传
log.debug("socket:msgtype=CircleDetailNotice");
circleDetailNoticeHandler.handleMsg(ctx, msgVo);
break;
}
package com.jubotech.framework.netty.handler.socket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.protobuf.util.JsonFormat;
import com.jubotech.business.web.domain.AccountInfo;
import com.jubotech.business.web.domain.BusinessWechatFriends;
import com.jubotech.business.web.domain.WeChatAccountInfo;
import com.jubotech.business.web.service.AccountService;
import com.jubotech.business.web.service.BusinessWechatFriendsService;
import com.jubotech.business.web.service.WeChatAccountService;
import com.jubotech.framework.netty.common.Constant;
import com.jubotech.framework.netty.utils.MessageUtil;
import com.jubotech.framework.netty.utils.NettyConnectionUtil;
import Jubo.JuLiao.IM.Wx.Proto.CircleDetailNotice.CircleDetailNoticeMessage;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumErrorCode;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumMsgType;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.TransportMessage;
import io.netty.channel.ChannelHandlerContext;
@Service
public class CircleDetailNoticeHandler{
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private WeChatAccountService weChatAccountService;
@Autowired
private AccountService accountService;
@Autowired
private BusinessWechatFriendsService businessWechatFriendsService;
/**
 * 朋友圈图片上传
 * @author wechatno:tangjinjinwx
 * @param ctx
 * @param vo
 */
public  void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {
    try {
        CircleDetailNoticeMessage req = vo.getContent().unpack(CircleDetailNoticeMessage.class);
        log.info(JsonFormat.printer().print(req));
        // 把消息转发给pc端
        // a、根据wechatId找到accountid
        // b、通过accountid找到account
        // c、通过account账号找到通道
        WeChatAccountInfo account = weChatAccountService.findWeChatAccountInfoByWeChatId(req.getWeChatId());
        if (null != account && null != account.getAccountid() && 1 != account.getIslogined()) {
            AccountInfo accInfo = accountService.findAccountInfoByid(account.getAccountid());
            if (null != accInfo) {
                // 转发给pc端
                ChannelHandlerContext chx = NettyConnectionUtil.getClientChannelHandlerContextByUserId(accInfo.getAccount());
                if (null != chx) {
                    MessageUtil.sendJsonMsg(chx, EnumMsgType.CircleDetailNotice, NettyConnectionUtil.getNettyId(chx),null, req);
                }
            }
        }
        
        //转发给商务app端
        BusinessWechatFriends  buiness = businessWechatFriendsService.getBusinessWechatFriendsByFriendWechatid(req.getWeChatId());
        if(null != buiness){
            String nettyName = buiness.getCid()+"_"+buiness.getB_number();
            ChannelHandlerContext cx_netty = NettyConnectionUtil.getClientChannelHandlerContextByUserId(nettyName);
            if(null != cx_netty){
                MessageUtil.sendJsonMsg(cx_netty, EnumMsgType.CircleDetailNotice, NettyConnectionUtil.getNettyId(ctx), null, req);
            }
        }
        
        // 告诉客户端消息已收到
        MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
        
         
    } catch (Exception e) {
        e.printStackTrace();
        MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
    }
}
}



相关文章
|
存储 人工智能 开发工具
AI助理化繁为简,速取代码参数——使用python SDK 处理OSS存储的图片
只需要通过向AI助理提问的方式输入您的需求,即可瞬间获得核心流程代码及参数,缩短学习路径、提升开发效率。
1873 5
AI助理化繁为简,速取代码参数——使用python SDK 处理OSS存储的图片
|
10月前
|
数据安全/隐私保护 计算机视觉 Python
人脸识别图片眨眼生成器,手机制作人脸眨眼张嘴, 代替真人刷脸软件
代码实现了基于面部特征点的人脸动画生成,包括眨眼和张嘴动作。它使用dlib进行人脸检测和特征点定位
|
JSON 机器人 API
gewe微信机器人搭建教程
GeWe开放平台是基于 微信开放平台的二次封装API服务,开发者可以使用本服务来处理微信中的各种事件,并可以通过后台调用对应的 API 来驱动微信自动执行任务,如自动收发消息、自动化应答、自动群邀请、群管理等,封装了 RPA技术流程,简化开发者二次开发难度,提供了开发者与微信对接的能力,使用简单,操作快捷,支持多种语言接入。
841 17
|
人工智能 开发框架 机器人
AstrBot:轻松将大模型接入QQ、微信等消息平台,打造多功能AI聊天机器人的开发框架,附详细教程
AstrBot 是一个开源的多平台聊天机器人及开发框架,支持多种大语言模型和消息平台,具备多轮对话、语音转文字等功能。
8759 38
AstrBot:轻松将大模型接入QQ、微信等消息平台,打造多功能AI聊天机器人的开发框架,附详细教程
|
存储 API UED
鸿蒙特效教程02-微信语音录制动画效果实现教程
本教程适合HarmonyOS初学者,通过简单到复杂的步骤,一步步实现类似微信APP中的语音录制动画效果。
534 0
鸿蒙特效教程02-微信语音录制动画效果实现教程
|
人工智能 自然语言处理
使用企业微信或公众号自动回复图片消息
AppFlow支持企业微信和公众号接收图片消息,并提供两种回复方式。方式一:直接回复图片消息,用户发送图片后立即收到回复,但无法继续追问。方式二:先保存图片,待用户发送文字后再一并处理并回复。配置步骤包括选择模板、配置鉴权信息、设置执行动作参数及发布连接流。详细操作可参考相关文档。
1690 1
使用企业微信或公众号自动回复图片消息
Discuz! X3.5插件云诺-阿里云短信手机登录 会员登录后也无法查看附件图片的问题解决方法
Discuz! X3.5插件云诺-阿里云短信手机登录 会员登录后也无法查看附件图片的问题解决方法
301 2
|
前端开发 小程序 Java
java基础:map遍历使用;java使用 Patten 和Matches 进行正则匹配;后端传到前端展示图片三种情况,并保存到手机
这篇文章介绍了Java中Map的遍历方法、使用Pattern和matches进行正则表达式匹配,以及后端向前端传输图片并保存到手机的三种情况。
913 1
|
小程序 JavaScript API
微信小程序开发之:保存图片到手机,使用uni-app 开发小程序;还有微信原生保存图片到手机
这篇文章介绍了如何在uni-app和微信小程序中实现将图片保存到用户手机相册的功能。
4002 0
微信小程序开发之:保存图片到手机,使用uni-app 开发小程序;还有微信原生保存图片到手机

热门文章

最新文章