parent
7e75a5b88f
commit
b57d512a70
@ -0,0 +1,32 @@
|
||||
package com.java3y.austin.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 微信下发消息类型枚举
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Getter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
public enum WechatMessageType {
|
||||
|
||||
TEST(10, "文本"),
|
||||
VOICE(20, "语音"),
|
||||
VIDEO(30, "视频"),
|
||||
NEWS(40, "图文"),
|
||||
TEXT_CARD(50, "文本卡片"),
|
||||
FILE(60, "文件"),
|
||||
MINI_PROGRAM_NOTICE(70, "小程序通知"),
|
||||
MARKDOWN(80, "markdown"),
|
||||
TEMPLATE_CARD(90, "模板卡片"),
|
||||
IMAGE(100, "图片"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
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