parent
2af53cf7a7
commit
1c4fd3c9ea
@ -0,0 +1,9 @@
|
|||||||
|
package com.java3y.austin.common.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 3y
|
||||||
|
* 企业微信
|
||||||
|
*/
|
||||||
|
public class EnterpriseWeChatContentModel extends ContentModel {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.java3y.austin.handler.handler.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.java3y.austin.common.domain.TaskInfo;
|
||||||
|
import com.java3y.austin.common.enums.ChannelType;
|
||||||
|
import com.java3y.austin.handler.handler.BaseHandler;
|
||||||
|
import com.java3y.austin.handler.handler.Handler;
|
||||||
|
import com.java3y.austin.handler.script.EnterpriseWeChatService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
|
||||||
|
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 3y
|
||||||
|
* 企业微信推送处理
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EnterpriseWeChatService enterpriseWeChatService;
|
||||||
|
|
||||||
|
|
||||||
|
public EnterpriseWeChatHandler() {
|
||||||
|
channelCode = ChannelType.ENTERPRISE_WE_CHAT.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handler(TaskInfo taskInfo) {
|
||||||
|
WxCpMessage wxCpMessage = new WxCpMessage();
|
||||||
|
|
||||||
|
try {
|
||||||
|
WxCpMessageSendResult result = enterpriseWeChatService.send(wxCpMessage);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("EnterpriseWeChatHandler#handler fail:{},params:{}",
|
||||||
|
Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.java3y.austin.handler.script.impl;
|
||||||
|
|
||||||
|
import com.java3y.austin.handler.script.EnterpriseWeChatService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
|
import me.chanjar.weixin.cp.api.WxCpService;
|
||||||
|
import me.chanjar.weixin.cp.api.impl.WxCpMessageServiceImpl;
|
||||||
|
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
|
||||||
|
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
|
||||||
|
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
|
||||||
|
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
|
||||||
|
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 3y
|
||||||
|
* @date 2022/3/15
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class EnterpriseWeChatServiceImpl implements EnterpriseWeChatService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxCpMessageSendResult send(WxCpMessage wxCpMessage) throws WxErrorException {
|
||||||
|
WxCpMessageServiceImpl messageService = new WxCpMessageServiceImpl(initService());
|
||||||
|
|
||||||
|
return messageService.send(wxCpMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private WxCpService initService() {
|
||||||
|
WxCpServiceImpl wxCpService = new WxCpServiceImpl();
|
||||||
|
wxCpService.setWxCpConfigStorage(initConfig());
|
||||||
|
return wxCpService;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WxCpConfigStorage initConfig() {
|
||||||
|
WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl();
|
||||||
|
config.setCorpId("");
|
||||||
|
config.setCorpSecret("");
|
||||||
|
config.setAgentId(1);
|
||||||
|
config.setToken("");
|
||||||
|
config.setAesKey("");
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue