1. 优化获取accessToken的代码

2. 微信相关的渠道发送失败,增加埋点信息
pull/57/head
3y 1 year ago
parent 7ffe07679c
commit 038a16dbdc

@ -1,32 +0,0 @@
package com.java3y.austin.common.constant;
/**
*
*
* @author 3y
*/
public class AccessTokenPrefixConstant {
/**
*
*/
public static final String DING_DING_ACCESS_TOKEN_PREFIX = "ding_ding_access_token_";
/**
* PUSH
*/
public static final String GE_TUI_ACCESS_TOKEN_PREFIX = "ge_tui_access_token_";
/**
*
*/
public static final String OFFICIAL_ACCOUNT_ACCESS_TOKEN_PREFIX = "official_account";
/**
*
*/
public static final String MINI_PROGRAM_TOKEN_PREFIX = "mini_program";
}

@ -23,51 +23,54 @@ public enum ChannelType implements PowerfulEnum {
/** /**
* IM() -- * IM() --
*/ */
IM(10, "IM(站内信)", ImContentModel.class, "im"), IM(10, "IM(站内信)", ImContentModel.class, "im", null, null),
/** /**
* push() -- * push() --
*/ */
PUSH(20, "push(通知栏)", PushContentModel.class, "push"), PUSH(20, "push(通知栏)", PushContentModel.class, "push", "ge_tui_access_token_", 3600 * 24L),
/** /**
* sms() -- * sms() --
*/ */
SMS(30, "sms(短信)", SmsContentModel.class, "sms"), SMS(30, "sms(短信)", SmsContentModel.class, "sms", null, null),
/** /**
* email() -- QQ163 * email() -- QQ163
*/ */
EMAIL(40, "email(邮件)", EmailContentModel.class, "email"), EMAIL(40, "email(邮件)", EmailContentModel.class, "email", null, null),
/** /**
* officialAccounts() -- * officialAccounts() --
* accessToken weixin-java-mp expireTime
*/ */
OFFICIAL_ACCOUNT(50, "officialAccounts(服务号)", OfficialAccountsContentModel.class, "official_accounts"), OFFICIAL_ACCOUNT(50, "officialAccounts(服务号)", OfficialAccountsContentModel.class, "official_accounts", "official_account_", null),
/** /**
* miniProgram() * miniProgram()
* accessToken weixin-java-miniapp expireTime
*/ */
MINI_PROGRAM(60, "miniProgram(小程序)", MiniProgramContentModel.class, "mini_program"), MINI_PROGRAM(60, "miniProgram(小程序)", MiniProgramContentModel.class, "mini_program", "mini_program_", null),
/** /**
* enterpriseWeChat() * enterpriseWeChat()
*/ */
ENTERPRISE_WE_CHAT(70, "enterpriseWeChat(企业微信)", EnterpriseWeChatContentModel.class, "enterprise_we_chat"), ENTERPRISE_WE_CHAT(70, "enterpriseWeChat(企业微信)", EnterpriseWeChatContentModel.class, "enterprise_we_chat", null, null),
/** /**
* dingDingRobot() * dingDingRobot()
*/ */
DING_DING_ROBOT(80, "dingDingRobot(钉钉机器人)", DingDingRobotContentModel.class, "ding_ding_robot"), DING_DING_ROBOT(80, "dingDingRobot(钉钉机器人)", DingDingRobotContentModel.class, "ding_ding_robot", null, null),
/** /**
* dingDingWorkNotice() * dingDingWorkNotice()
*/ */
DING_DING_WORK_NOTICE(90, "dingDingWorkNotice(钉钉工作通知)", DingDingWorkContentModel.class, "ding_ding_work_notice"), DING_DING_WORK_NOTICE(90, "dingDingWorkNotice(钉钉工作通知)", DingDingWorkContentModel.class, "ding_ding_work_notice", "ding_ding_access_token_", 3600 * 2L),
/** /**
* enterpriseWeChat() * enterpriseWeChat()
*/ */
ENTERPRISE_WE_CHAT_ROBOT(100, "enterpriseWeChat(企业微信机器人)", EnterpriseWeChatRobotContentModel.class, "enterprise_we_chat_robot"), ENTERPRISE_WE_CHAT_ROBOT(100, "enterpriseWeChat(企业微信机器人)", EnterpriseWeChatRobotContentModel.class, "enterprise_we_chat_robot", null, null),
/** /**
* feiShuRoot() * feiShuRoot()
*/ */
FEI_SHU_ROBOT(110, "feiShuRoot(飞书机器人)", FeiShuRobotContentModel.class, "fei_shu_robot"), FEI_SHU_ROBOT(110, "feiShuRoot(飞书机器人)", FeiShuRobotContentModel.class, "fei_shu_robot", null, null),
/** /**
* alipayMiniProgram() * alipayMiniProgram()
*/ */
ALIPAY_MINI_PROGRAM(120, "alipayMiniProgram(支付宝小程序)", AlipayMiniProgramContentModel.class, "alipay_mini_program"), ALIPAY_MINI_PROGRAM(120, "alipayMiniProgram(支付宝小程序)", AlipayMiniProgramContentModel.class, "alipay_mini_program", null, null),
; ;
/** /**
@ -90,6 +93,17 @@ public enum ChannelType implements PowerfulEnum {
*/ */
private final String codeEn; private final String codeEn;
/**
* accessToken prefix
*/
private final String accessTokenPrefix;
/**
* accessToken expire
*
*/
private final Long accessTokenExpire;
/** /**
* codeclass * codeclass
* *

@ -2,7 +2,6 @@ package com.java3y.austin.cron.handler;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.constant.AccessTokenPrefixConstant;
import com.java3y.austin.common.constant.CommonConstant; import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount; import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
@ -36,6 +35,9 @@ public class RefreshDingDingAccessTokenHandler {
@Autowired @Autowired
private ChannelAccountDao channelAccountDao; private ChannelAccountDao channelAccountDao;
@Autowired
private AccessTokenUtils accessTokenUtils;
/** /**
* ) * )
@ -47,9 +49,9 @@ public class RefreshDingDingAccessTokenHandler {
List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.DING_DING_WORK_NOTICE.getCode()); List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.DING_DING_WORK_NOTICE.getCode());
for (ChannelAccount channelAccount : accountList) { for (ChannelAccount channelAccount : accountList) {
DingDingWorkNoticeAccount account = JSON.parseObject(channelAccount.getAccountConfig(), DingDingWorkNoticeAccount.class); DingDingWorkNoticeAccount account = JSON.parseObject(channelAccount.getAccountConfig(), DingDingWorkNoticeAccount.class);
String accessToken = AccessTokenUtils.getDingDingAccessToken(account); String accessToken = accessTokenUtils.getAccessToken(ChannelType.DING_DING_WORK_NOTICE.getCode(), channelAccount.getId().intValue(), account, true);
if (StrUtil.isNotBlank(accessToken)) { if (StrUtil.isNotBlank(accessToken)) {
redisTemplate.opsForValue().set(AccessTokenPrefixConstant.DING_DING_ACCESS_TOKEN_PREFIX + channelAccount.getId(), accessToken); redisTemplate.opsForValue().set(ChannelType.DING_DING_WORK_NOTICE.getAccessTokenPrefix() + channelAccount.getId(), accessToken);
} }
} }
}); });

@ -2,7 +2,6 @@ package com.java3y.austin.cron.handler;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.constant.AccessTokenPrefixConstant;
import com.java3y.austin.common.constant.CommonConstant; import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.GeTuiAccount; import com.java3y.austin.common.dto.account.GeTuiAccount;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
@ -36,6 +35,9 @@ public class RefreshGeTuiAccessTokenHandler {
@Autowired @Autowired
private ChannelAccountDao channelAccountDao; private ChannelAccountDao channelAccountDao;
@Autowired
private AccessTokenUtils accessTokenUtils;
/** /**
* ) * )
@ -47,9 +49,9 @@ public class RefreshGeTuiAccessTokenHandler {
List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.PUSH.getCode()); List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.PUSH.getCode());
for (ChannelAccount channelAccount : accountList) { for (ChannelAccount channelAccount : accountList) {
GeTuiAccount account = JSON.parseObject(channelAccount.getAccountConfig(), GeTuiAccount.class); GeTuiAccount account = JSON.parseObject(channelAccount.getAccountConfig(), GeTuiAccount.class);
String accessToken = AccessTokenUtils.getGeTuiAccessToken(account); String accessToken = accessTokenUtils.getAccessToken(ChannelType.PUSH.getCode(), channelAccount.getId().intValue(), account, true);
if (StrUtil.isNotBlank(accessToken)) { if (StrUtil.isNotBlank(accessToken)) {
redisTemplate.opsForValue().set(AccessTokenPrefixConstant.GE_TUI_ACCESS_TOKEN_PREFIX + channelAccount.getId(), accessToken); redisTemplate.opsForValue().set(ChannelType.PUSH.getAccessTokenPrefix() + channelAccount.getId(), accessToken);
} }
} }
}); });

@ -13,7 +13,6 @@ import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
import com.dingtalk.api.response.OapiMessageCorpconversationGetsendresultResponse; import com.dingtalk.api.response.OapiMessageCorpconversationGetsendresultResponse;
import com.dingtalk.api.response.OapiMessageCorpconversationRecallResponse; import com.dingtalk.api.response.OapiMessageCorpconversationRecallResponse;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AccessTokenPrefixConstant;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.SendChanelUrlConstant; import com.java3y.austin.common.constant.SendChanelUrlConstant;
import com.java3y.austin.common.domain.LogParam; import com.java3y.austin.common.domain.LogParam;
@ -54,6 +53,8 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired @Autowired
private AccessTokenUtils accessTokenUtils;
@Autowired
private StringRedisTemplate redisTemplate; private StringRedisTemplate redisTemplate;
@Autowired @Autowired
private LogUtils logUtils; private LogUtils logUtils;
@ -69,8 +70,9 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try { try {
DingDingWorkNoticeAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), DingDingWorkNoticeAccount.class); DingDingWorkNoticeAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), DingDingWorkNoticeAccount.class);
String accessToken = accessTokenUtils.getAccessToken(taskInfo.getSendChannel(), taskInfo.getSendAccount(), account, false);
OapiMessageCorpconversationAsyncsendV2Request request = assembleParam(account, taskInfo); OapiMessageCorpconversationAsyncsendV2Request request = assembleParam(account, taskInfo);
String accessToken = getAccessToken(account, Long.valueOf(taskInfo.getSendAccount()));
OapiMessageCorpconversationAsyncsendV2Response response = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_SEND_URL).execute(request, accessToken); OapiMessageCorpconversationAsyncsendV2Response response = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_SEND_URL).execute(request, accessToken);
// 发送成功后记录TaskId用于消息撤回(支持当天的) // 发送成功后记录TaskId用于消息撤回(支持当天的)
@ -179,7 +181,7 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
public void pull(Long accountId) { public void pull(Long accountId) {
try { try {
DingDingWorkNoticeAccount account = accountUtils.getAccountById(accountId.intValue(), DingDingWorkNoticeAccount.class); DingDingWorkNoticeAccount account = accountUtils.getAccountById(accountId.intValue(), DingDingWorkNoticeAccount.class);
String accessToken = getAccessToken(account, accountId); String accessToken = accessTokenUtils.getAccessToken(ChannelType.DING_DING_WORK_NOTICE.getCode(), accountId.intValue(), account, false);
DingTalkClient client = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_PULL_URL); DingTalkClient client = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_PULL_URL);
OapiMessageCorpconversationGetsendresultRequest req = new OapiMessageCorpconversationGetsendresultRequest(); OapiMessageCorpconversationGetsendresultRequest req = new OapiMessageCorpconversationGetsendresultRequest();
req.setAgentId(Long.valueOf(account.getAgentId())); req.setAgentId(Long.valueOf(account.getAgentId()));
@ -205,7 +207,7 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> { SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> {
try { try {
DingDingWorkNoticeAccount account = accountUtils.getAccountById(recallTaskInfo.getSendAccount(), DingDingWorkNoticeAccount.class); DingDingWorkNoticeAccount account = accountUtils.getAccountById(recallTaskInfo.getSendAccount(), DingDingWorkNoticeAccount.class);
String accessToken = getAccessToken(account, Long.valueOf(recallTaskInfo.getSendAccount())); String accessToken = accessTokenUtils.getAccessToken(recallTaskInfo.getSendChannel(), recallTaskInfo.getSendAccount(), account, false);
// 优先去除messageId如果未传入messageId则按照模板id去除 // 优先去除messageId如果未传入messageId则按照模板id去除
if (CollUtil.isNotEmpty(recallTaskInfo.getRecallMessageId())) { if (CollUtil.isNotEmpty(recallTaskInfo.getRecallMessageId())) {
@ -241,27 +243,5 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
OapiMessageCorpconversationRecallResponse rsp = client.execute(req, accessToken); OapiMessageCorpconversationRecallResponse rsp = client.execute(req, accessToken);
logUtils.print(LogParam.builder().bizType(RECALL_BIZ_TYPE).object(JSON.toJSONString(rsp)).build()); logUtils.print(LogParam.builder().bizType(RECALL_BIZ_TYPE).object(JSON.toJSONString(rsp)).build());
} }
/**
* token
*
* @param account
* @param accountId ID
* @return token
*/
private String getAccessToken(DingDingWorkNoticeAccount account, Long accountId) {
String accessToken = redisTemplate.opsForValue().get(AccessTokenPrefixConstant.DING_DING_ACCESS_TOKEN_PREFIX + accountId);
if (StrUtil.isNotBlank(accessToken)) {
return accessToken;
}
accessToken = AccessTokenUtils.getDingDingAccessToken(account);
if (StrUtil.isNotBlank(accessToken)) {
redisTemplate.opsForValue().set(AccessTokenPrefixConstant.DING_DING_ACCESS_TOKEN_PREFIX + accountId, accessToken);
} else {
log.error("DingDingWorkNoticeHandler#getAccessToken fail accessToken{} accountId{} ", accessToken, accountId);
}
return accessToken;
}
} }

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant; import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.RecallTaskInfo; import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.EnterpriseWeChatContentModel; import com.java3y.austin.common.dto.model.EnterpriseWeChatContentModel;
@ -13,6 +14,7 @@ import com.java3y.austin.common.enums.SendMessageType;
import com.java3y.austin.handler.handler.BaseHandler; import com.java3y.austin.handler.handler.BaseHandler;
import com.java3y.austin.handler.handler.Handler; import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import com.java3y.austin.support.utils.LogUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxMpErrorMsgEnum; import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpService;
@ -40,6 +42,8 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired
private LogUtils logUtils;
public EnterpriseWeChatHandler() { public EnterpriseWeChatHandler() {
channelCode = ChannelType.ENTERPRISE_WE_CHAT.getCode(); channelCode = ChannelType.ENTERPRISE_WE_CHAT.getCode();
@ -54,8 +58,8 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
if (Integer.valueOf(WxMpErrorMsgEnum.CODE_0.getCode()).equals(result.getErrCode())) { if (Integer.valueOf(WxMpErrorMsgEnum.CODE_0.getCode()).equals(result.getErrCode())) {
return true; return true;
} }
// 常见的错误 应当 关联至 AnchorState,由austin后台统一透出失败原因 logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
log.error("EnterpriseWeChatHandler#handler fail!result:{},params:{}", JSON.toJSONString(result), JSON.toJSONString(taskInfo)); .ids(taskInfo.getReceiver()).state(result.getErrCode()).build());
} catch (Exception e) { } catch (Exception e) {
log.error("EnterpriseWeChatHandler#handler fail:{},params:{}", log.error("EnterpriseWeChatHandler#handler fail:{},params:{}",
Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo)); Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo));

@ -5,6 +5,7 @@ import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.RecallTaskInfo; import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.account.EnterpriseWeChatRobotAccount; import com.java3y.austin.common.dto.account.EnterpriseWeChatRobotAccount;
@ -16,6 +17,7 @@ import com.java3y.austin.handler.domain.wechat.robot.EnterpriseWeChatRootResult;
import com.java3y.austin.handler.handler.BaseHandler; import com.java3y.austin.handler.handler.BaseHandler;
import com.java3y.austin.handler.handler.Handler; import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import com.java3y.austin.support.utils.LogUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -33,6 +35,8 @@ public class EnterpriseWeChatRobotHandler extends BaseHandler implements Handler
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired
private LogUtils logUtils;
public EnterpriseWeChatRobotHandler() { public EnterpriseWeChatRobotHandler() {
channelCode = ChannelType.ENTERPRISE_WE_CHAT_ROBOT.getCode(); channelCode = ChannelType.ENTERPRISE_WE_CHAT_ROBOT.getCode();
@ -51,7 +55,8 @@ public class EnterpriseWeChatRobotHandler extends BaseHandler implements Handler
if (weChatRootResult.getErrcode() == 0) { if (weChatRootResult.getErrcode() == 0) {
return true; return true;
} }
log.error("EnterpriseWeChatRobotHandler#handler fail! result:{},params:{}", JSON.toJSONString(weChatRootResult), JSON.toJSONString(taskInfo)); logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
.ids(taskInfo.getReceiver()).state(weChatRootResult.getErrcode()).build());
} catch (Exception e) { } catch (Exception e) {
log.error("EnterpriseWeChatRobotHandler#handler fail!e:{},params:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo)); log.error("EnterpriseWeChatRobotHandler#handler fail!e:{},params:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo));
} }

@ -4,6 +4,8 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.Sets;
import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.RecallTaskInfo; import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.MiniProgramContentModel; import com.java3y.austin.common.dto.model.MiniProgramContentModel;
@ -11,7 +13,9 @@ import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.handler.BaseHandler; import com.java3y.austin.handler.handler.BaseHandler;
import com.java3y.austin.handler.handler.Handler; import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import com.java3y.austin.support.utils.LogUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -29,6 +33,8 @@ import java.util.Set;
public class MiniProgramAccountHandler extends BaseHandler implements Handler { public class MiniProgramAccountHandler extends BaseHandler implements Handler {
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired
private LogUtils logUtils;
public MiniProgramAccountHandler() { public MiniProgramAccountHandler() {
channelCode = ChannelType.MINI_PROGRAM.getCode(); channelCode = ChannelType.MINI_PROGRAM.getCode();
@ -36,17 +42,24 @@ public class MiniProgramAccountHandler extends BaseHandler implements Handler {
@Override @Override
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try {
MiniProgramContentModel contentModel = (MiniProgramContentModel) taskInfo.getContentModel(); MiniProgramContentModel contentModel = (MiniProgramContentModel) taskInfo.getContentModel();
WxMaService wxMaService = accountUtils.getAccountById(taskInfo.getSendAccount(), WxMaService.class); WxMaService wxMaService = accountUtils.getAccountById(taskInfo.getSendAccount(), WxMaService.class);
List<WxMaSubscribeMessage> wxMaSubscribeMessages = assembleReq(taskInfo.getReceiver(), contentModel); List<WxMaSubscribeMessage> wxMaSubscribeMessages = assembleReq(taskInfo.getReceiver(), contentModel);
for (WxMaSubscribeMessage message : wxMaSubscribeMessages) { for (WxMaSubscribeMessage message : wxMaSubscribeMessages) {
try { try {
wxMaService.getSubscribeService().sendSubscribeMsg(message); wxMaService.getSubscribeService().sendSubscribeMsg(message);
} catch (Exception e) { } catch (WxErrorException e) {
log.info("MiniProgramAccountHandler#handler fail! param:{},e:{}", JSON.toJSONString(taskInfo), Throwables.getStackTraceAsString(e)); logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
.ids(Sets.newHashSet(message.getToUser())).state(e.getError().getErrorCode()).build());
} }
} }
return true; return true;
} catch (Exception e) {
log.error("MiniProgramAccountHandler#handler fail:{},params:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo));
}
return false;
} }
/** /**

@ -2,6 +2,8 @@ package com.java3y.austin.handler.handler.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.Sets;
import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.RecallTaskInfo; import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.OfficialAccountsContentModel; import com.java3y.austin.common.dto.model.OfficialAccountsContentModel;
@ -9,7 +11,9 @@ import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.handler.BaseHandler; import com.java3y.austin.handler.handler.BaseHandler;
import com.java3y.austin.handler.handler.Handler; import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import com.java3y.austin.support.utils.LogUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
@ -31,6 +35,8 @@ public class OfficialAccountHandler extends BaseHandler implements Handler {
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired
private LogUtils logUtils;
public OfficialAccountHandler() { public OfficialAccountHandler() {
channelCode = ChannelType.OFFICIAL_ACCOUNT.getCode(); channelCode = ChannelType.OFFICIAL_ACCOUNT.getCode();
@ -45,8 +51,9 @@ public class OfficialAccountHandler extends BaseHandler implements Handler {
for (WxMpTemplateMessage message : messages) { for (WxMpTemplateMessage message : messages) {
try { try {
wxMpService.getTemplateMsgService().sendTemplateMsg(message); wxMpService.getTemplateMsgService().sendTemplateMsg(message);
} catch (Exception e) { } catch (WxErrorException e) {
log.info("OfficialAccountHandler#handler fail! param:{},e:{}", JSON.toJSONString(taskInfo), Throwables.getStackTraceAsString(e)); logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
.ids(Sets.newHashSet(message.getToUser())).state(e.getError().getErrorCode()).build());
} }
} }
return true; return true;

@ -2,13 +2,11 @@ package com.java3y.austin.handler.handler.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.ContentType; import cn.hutool.http.ContentType;
import cn.hutool.http.Header; import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AccessTokenPrefixConstant;
import com.java3y.austin.common.constant.SendChanelUrlConstant; import com.java3y.austin.common.constant.SendChanelUrlConstant;
import com.java3y.austin.common.domain.RecallTaskInfo; import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
@ -25,7 +23,6 @@ import com.java3y.austin.support.utils.AccessTokenUtils;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Set; import java.util.Set;
@ -48,7 +45,7 @@ public class PushHandler extends BaseHandler implements Handler {
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired @Autowired
private StringRedisTemplate redisTemplate; private AccessTokenUtils accessTokenUtils;
@Override @Override
@ -56,7 +53,7 @@ public class PushHandler extends BaseHandler implements Handler {
try { try {
GeTuiAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), GeTuiAccount.class); GeTuiAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), GeTuiAccount.class);
String token = getAccessToken(taskInfo, account); String token = accessTokenUtils.getAccessToken(taskInfo.getSendChannel(), taskInfo.getSendAccount(), account, false);
PushParam pushParam = PushParam.builder().token(token).appId(account.getAppId()).taskInfo(taskInfo).build(); PushParam pushParam = PushParam.builder().token(token).appId(account.getAppId()).taskInfo(taskInfo).build();
String result; String result;
@ -143,27 +140,6 @@ public class PushHandler extends BaseHandler implements Handler {
return taskId; return taskId;
} }
/**
* token
*
* @param taskInfo
* @param account
* @return token
*/
private String getAccessToken(TaskInfo taskInfo, GeTuiAccount account) {
String token = redisTemplate.opsForValue().get(AccessTokenPrefixConstant.GE_TUI_ACCESS_TOKEN_PREFIX + taskInfo.getSendAccount());
if (StrUtil.isNotBlank(token)) {
return token;
}
token = AccessTokenUtils.getGeTuiAccessToken(account);
if (StrUtil.isNotBlank(token)) {
redisTemplate.opsForValue().set(AccessTokenPrefixConstant.GE_TUI_ACCESS_TOKEN_PREFIX + taskInfo.getSendAccount(), token);
} else {
log.error("PushHandler#getAccessToken fail taskInfo:{} account:{}", taskInfo, account);
}
return token;
}
private SendPushParam assembleParam(PushContentModel pushContentModel) { private SendPushParam assembleParam(PushContentModel pushContentModel) {
return assembleParam(pushContentModel, null); return assembleParam(pushContentModel, null);
} }

@ -30,7 +30,8 @@ public class ChannelAccount {
/** /**
* *
* com.java3y.austin.common.enums.ChannelType *
* @see com.java3y.austin.common.enums.ChannelType
*/ */
private Integer sendChannel; private Integer sendChannel;

@ -5,7 +5,6 @@ import com.google.common.eventbus.EventBus;
import com.java3y.austin.common.domain.RecallTaskInfo; import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.support.constans.MessageQueuePipeline; import com.java3y.austin.support.constans.MessageQueuePipeline;
import com.java3y.austin.support.domain.MessageTemplate;
import com.java3y.austin.support.mq.SendMqService; import com.java3y.austin.support.mq.SendMqService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

@ -1,5 +1,6 @@
package com.java3y.austin.support.utils; package com.java3y.austin.support.utils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.ContentType; import cn.hutool.http.ContentType;
import cn.hutool.http.Header; import cn.hutool.http.Header;
@ -14,9 +15,16 @@ import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.constant.SendChanelUrlConstant; import com.java3y.austin.common.constant.SendChanelUrlConstant;
import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount; import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount;
import com.java3y.austin.common.dto.account.GeTuiAccount; import com.java3y.austin.common.dto.account.GeTuiAccount;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.EnumUtil;
import com.java3y.austin.support.dto.GeTuiTokenResultDTO; import com.java3y.austin.support.dto.GeTuiTokenResultDTO;
import com.java3y.austin.support.dto.QueryTokenParamDTO; import com.java3y.austin.support.dto.QueryTokenParamDTO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/** /**
* token * token
@ -24,21 +32,65 @@ import lombok.extern.slf4j.Slf4j;
* @author wuhui * @author wuhui
*/ */
@Slf4j @Slf4j
@Component
public class AccessTokenUtils { public class AccessTokenUtils {
@Autowired
private StringRedisTemplate redisTemplate;
/**
* accessToken
* 1redisredis
* 2redisaccessTokenredis
*
* @param sendChannel
* @param accountId Id
* @param account
* @param refresh accessToken
* @return
* @see com.java3y.austin.common.enums.ChannelType
*/
public String getAccessToken(Integer sendChannel, Integer accountId, Object account, Boolean refresh) {
String resultToken = "";
// expireTime跟渠道的accessToken失效有关个推accessToken默认有效是1天钉钉工作消息默认有效是2小时
String accessTokenPrefix = EnumUtil.getEnumByCode(sendChannel, ChannelType.class).getAccessTokenPrefix();
Long expireTime = EnumUtil.getEnumByCode(sendChannel, ChannelType.class).getAccessTokenExpire();
try {
resultToken = redisTemplate.opsForValue().get(accessTokenPrefix + accountId);
if (StrUtil.isNotBlank(resultToken) && !refresh) {
return resultToken;
}
if (ChannelType.DING_DING_WORK_NOTICE.getCode().equals(sendChannel)) {
resultToken = getDingDingAccessToken(account);
} else if (ChannelType.PUSH.getCode().equals(sendChannel)) {
resultToken = getGeTuiAccessToken(account);
}
if (StrUtil.isNotBlank(resultToken)) {
redisTemplate.opsForValue().set(accessTokenPrefix + accountId, resultToken, expireTime, TimeUnit.SECONDS);
}
} catch (Exception e) {
log.error("AccessTokenUtils#getAccessToken fail,sendChannel:[{}],accountId:[{}],error mgs:{}", sendChannel, accountId, Throwables.getStackTraceAsString(e));
}
return resultToken;
}
/** /**
* access_token * access_token
* *
* @param account * @param account
* @return access_token * @return access_token
*/ */
public static String getDingDingAccessToken(DingDingWorkNoticeAccount account) { private String getDingDingAccessToken(Object account) {
String accessToken = ""; String accessToken = "";
try { try {
DingDingWorkNoticeAccount dingWorkNoticeAccount = (DingDingWorkNoticeAccount) account;
DingTalkClient client = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_TOKEN_URL); DingTalkClient client = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_TOKEN_URL);
OapiGettokenRequest req = new OapiGettokenRequest(); OapiGettokenRequest req = new OapiGettokenRequest();
req.setAppkey(account.getAppKey()); req.setAppkey(dingWorkNoticeAccount.getAppKey());
req.setAppsecret(account.getAppSecret()); req.setAppsecret(dingWorkNoticeAccount.getAppSecret());
req.setHttpMethod(CommonConstant.REQUEST_METHOD_GET); req.setHttpMethod(CommonConstant.REQUEST_METHOD_GET);
OapiGettokenResponse rsp = client.execute(req); OapiGettokenResponse rsp = client.execute(req);
accessToken = rsp.getAccessToken(); accessToken = rsp.getAccessToken();
@ -54,20 +106,21 @@ public class AccessTokenUtils {
* @param account * @param account
* @return access_token * @return access_token
*/ */
public static String getGeTuiAccessToken(GeTuiAccount account) { private String getGeTuiAccessToken(Object account) {
String accessToken = ""; String accessToken = "";
try { try {
String url = SendChanelUrlConstant.GE_TUI_BASE_URL + account.getAppId() + SendChanelUrlConstant.GE_TUI_AUTH; GeTuiAccount geTuiAccount = (GeTuiAccount) account;
String url = SendChanelUrlConstant.GE_TUI_BASE_URL + geTuiAccount.getAppId() + SendChanelUrlConstant.GE_TUI_AUTH;
String time = String.valueOf(System.currentTimeMillis()); String time = String.valueOf(System.currentTimeMillis());
String digest = SecureUtil.sha256().digestHex(account.getAppKey() + time + account.getMasterSecret()); String digest = SecureUtil.sha256().digestHex(geTuiAccount.getAppKey() + time + geTuiAccount.getMasterSecret());
QueryTokenParamDTO param = QueryTokenParamDTO.builder() QueryTokenParamDTO param = QueryTokenParamDTO.builder()
.timestamp(time) .timestamp(time)
.appKey(account.getAppKey()) .appKey(geTuiAccount.getAppKey())
.sign(digest).build(); .sign(digest).build();
String body = HttpRequest.post(url).header(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue()) String body = HttpRequest.post(url).header(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue())
.body(JSON.toJSONString(param)) .body(JSON.toJSONString(param))
.timeout(20000) .timeout(2000)
.execute().body(); .execute().body();
GeTuiTokenResultDTO geTuiTokenResultDTO = JSON.parseObject(body, GeTuiTokenResultDTO.class); GeTuiTokenResultDTO geTuiTokenResultDTO = JSON.parseObject(body, GeTuiTokenResultDTO.class);
if (geTuiTokenResultDTO.getCode().equals(0)) { if (geTuiTokenResultDTO.getCode().equals(0)) {

@ -6,7 +6,6 @@ import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AccessTokenPrefixConstant;
import com.java3y.austin.common.constant.CommonConstant; import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.WeChatMiniProgramAccount; import com.java3y.austin.common.dto.account.WeChatMiniProgramAccount;
import com.java3y.austin.common.dto.account.WeChatOfficialAccount; import com.java3y.austin.common.dto.account.WeChatOfficialAccount;
@ -16,7 +15,6 @@ import com.java3y.austin.support.dao.ChannelAccountDao;
import com.java3y.austin.support.domain.ChannelAccount; import com.java3y.austin.support.domain.ChannelAccount;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl;
@ -121,7 +119,7 @@ public class AccountUtils {
*/ */
public WxMpService initOfficialAccountService(WeChatOfficialAccount officialAccount) { public WxMpService initOfficialAccountService(WeChatOfficialAccount officialAccount) {
WxMpService wxMpService = new WxMpServiceImpl(); WxMpService wxMpService = new WxMpServiceImpl();
WxMpRedisConfigImpl config = new WxMpRedisConfigImpl(redisTemplateWxRedisOps(), AccessTokenPrefixConstant.OFFICIAL_ACCOUNT_ACCESS_TOKEN_PREFIX); WxMpRedisConfigImpl config = new WxMpRedisConfigImpl(redisTemplateWxRedisOps(), ChannelType.ENTERPRISE_WE_CHAT.getAccessTokenPrefix());
config.setAppId(officialAccount.getAppId()); config.setAppId(officialAccount.getAppId());
config.setSecret(officialAccount.getSecret()); config.setSecret(officialAccount.getSecret());
config.setToken(officialAccount.getToken()); config.setToken(officialAccount.getToken());
@ -138,7 +136,7 @@ public class AccountUtils {
*/ */
private WxMaService initMiniProgramService(WeChatMiniProgramAccount miniProgramAccount) { private WxMaService initMiniProgramService(WeChatMiniProgramAccount miniProgramAccount) {
WxMaService wxMaService = new WxMaServiceImpl(); WxMaService wxMaService = new WxMaServiceImpl();
WxMaRedisBetterConfigImpl config = new WxMaRedisBetterConfigImpl(redisTemplateWxRedisOps(), AccessTokenPrefixConstant.MINI_PROGRAM_TOKEN_PREFIX); WxMaRedisBetterConfigImpl config = new WxMaRedisBetterConfigImpl(redisTemplateWxRedisOps(), ChannelType.MINI_PROGRAM.getAccessTokenPrefix());
config.setAppid(miniProgramAccount.getAppId()); config.setAppid(miniProgramAccount.getAppId());
config.setSecret(miniProgramAccount.getAppSecret()); config.setSecret(miniProgramAccount.getAppSecret());
config.useStableAccessToken(true); config.useStableAccessToken(true);

@ -9,15 +9,17 @@ import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMediaUploadRequest; import com.dingtalk.api.request.OapiMediaUploadRequest;
import com.dingtalk.api.response.OapiMediaUploadResponse; import com.dingtalk.api.response.OapiMediaUploadResponse;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AccessTokenPrefixConstant;
import com.java3y.austin.common.constant.CommonConstant; import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.constant.SendChanelUrlConstant; import com.java3y.austin.common.constant.SendChanelUrlConstant;
import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount;
import com.java3y.austin.common.dto.account.EnterpriseWeChatRobotAccount; import com.java3y.austin.common.dto.account.EnterpriseWeChatRobotAccount;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.EnumUtil; import com.java3y.austin.common.enums.EnumUtil;
import com.java3y.austin.common.enums.FileType; import com.java3y.austin.common.enums.FileType;
import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.common.vo.BasicResultVO;
import com.java3y.austin.handler.domain.wechat.robot.EnterpriseWeChatRootResult; import com.java3y.austin.handler.domain.wechat.robot.EnterpriseWeChatRootResult;
import com.java3y.austin.support.utils.AccessTokenUtils;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import com.java3y.austin.web.service.MaterialService; import com.java3y.austin.web.service.MaterialService;
import com.java3y.austin.web.utils.SpringFileUtils; import com.java3y.austin.web.utils.SpringFileUtils;
@ -39,18 +41,18 @@ import org.springframework.web.multipart.MultipartFile;
@Slf4j @Slf4j
@Service @Service
public class MaterialServiceImpl implements MaterialService { public class MaterialServiceImpl implements MaterialService {
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired
private AccessTokenUtils accessTokenUtils;
@Override @Override
public BasicResultVO dingDingMaterialUpload(MultipartFile file, String sendAccount, String fileType) { public BasicResultVO dingDingMaterialUpload(MultipartFile file, String sendAccount, String fileType) {
OapiMediaUploadResponse rsp; OapiMediaUploadResponse rsp;
try { try {
String accessToken = redisTemplate.opsForValue().get(AccessTokenPrefixConstant.DING_DING_ACCESS_TOKEN_PREFIX + sendAccount); DingDingWorkNoticeAccount account = accountUtils.getAccountById(Integer.valueOf(sendAccount), DingDingWorkNoticeAccount.class);
String accessToken = accessTokenUtils.getAccessToken(ChannelType.DING_DING_WORK_NOTICE.getCode(), Integer.valueOf(sendAccount), account, false);
DingTalkClient client = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_UPLOAD_URL); DingTalkClient client = new DefaultDingTalkClient(SendChanelUrlConstant.DING_DING_UPLOAD_URL);
OapiMediaUploadRequest req = new OapiMediaUploadRequest(); OapiMediaUploadRequest req = new OapiMediaUploadRequest();
FileItem item = new FileItem(new StringBuilder().append(IdUtil.fastSimpleUUID()).append(file.getOriginalFilename()).toString(), FileItem item = new FileItem(new StringBuilder().append(IdUtil.fastSimpleUUID()).append(file.getOriginalFilename()).toString(),

Loading…
Cancel
Save