package com.qianwen.core.notify.provider.wechat.mp; import com.alibaba.fastjson.JSON; import javax.annotation.Nonnull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.qianwen.core.notify.DefaultNotifyType; import com.qianwen.core.notify.NotifyType; import com.qianwen.core.notify.Provider; import com.qianwen.core.notify.notifier.NotifierProperties; import com.qianwen.core.notify.notifier.NotifierProvider; import com.qianwen.core.notify.provider.wechat.WechatProvider; import com.qianwen.core.notify.template.TemplateManager; import com.qianwen.core.notify.template.TemplateProperties; import com.qianwen.core.notify.template.TemplateProvider; import com.qianwen.core.tool.metadata.ConfigMetadata; import com.qianwen.core.tool.metadata.ConfigMetadataConstants; import com.qianwen.core.tool.metadata.DataType; import com.qianwen.core.tool.metadata.DefaultConfigMetadata; import com.qianwen.core.tool.metadata.SimplePropertyMetadata; import com.qianwen.core.tool.metadata.config.ConfigKeyValue; import com.qianwen.core.tool.metadata.types.BooleanType; import com.qianwen.core.tool.metadata.types.ObjectType; import com.qianwen.core.tool.metadata.types.StringType; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.stereotype.Component; @ConditionalOnBean({TemplateManager.class}) @Component /* loaded from: blade-starter-notify-9.3.0.0-SNAPSHOT.jar:org/springblade/core/notify/provider/wechat/mp/WechatMpNotifierProvider.class */ public class WechatMpNotifierProvider implements NotifierProvider, TemplateProvider { private final TemplateManager templateManager; public static final DefaultConfigMetadata templateConfig; private static final Logger log = LoggerFactory.getLogger(WechatMpNotifierProvider.class); public static final DefaultConfigMetadata notifierConfig = new DefaultConfigMetadata("公众号配置", "").add("name", "name", "公众号名称", (DataType) new StringType().expand(new ConfigKeyValue[]{ConfigMetadataConstants.maxLength.value(255L)})).add("appid", "appid", "appid", (DataType) new StringType().expand(new ConfigKeyValue[]{ConfigMetadataConstants.maxLength.value(255L)})).add("secret", "secret", "secret", new StringType()).add("token", "token", "token", new StringType()).add("aesKey", "aesKey", "aesKey", new StringType()); static { SimplePropertyMetadata appid = new SimplePropertyMetadata(); appid.setId("appid"); appid.setName("appid"); appid.setValueType(new StringType()); SimplePropertyMetadata pagePath = new SimplePropertyMetadata(); pagePath.setId("pagePath"); pagePath.setName("小程序路径"); pagePath.setValueType(new StringType()); SimplePropertyMetadata usePath = new SimplePropertyMetadata(); usePath.setId("usePath"); usePath.setName("是否使用path,否则使用pagepath"); usePath.setValueType(new BooleanType()); templateConfig = new DefaultConfigMetadata("消息模版", "").add("templateId", "模板ID", "模板ID.", (DataType) new StringType().expand(new ConfigKeyValue[]{ConfigMetadataConstants.maxLength.value(255L)})).add("url", "模板跳转链接.", "url和miniprogram都是非必填字段,若都不传则模板无跳转;若都传,会优先跳转至小程序。\n 开发者可根据实际需要选择其中一种跳转方式即可。当用户的微信客户端版本不支持跳小程序时,将会跳转至url。", new StringType()).add("miniProgram", "跳小程序地址", "跳小程序所需数据,不需跳小程序可不用传该数据", new ObjectType().addPropertyMetadata(appid).addPropertyMetadata(pagePath).addPropertyMetadata(usePath)); } public WechatMpNotifierProvider(TemplateManager templateManager) { this.templateManager = templateManager; } @Override // com.qianwen.core.notify.notifier.NotifierProvider, com.qianwen.core.notify.template.TemplateProvider public NotifyType getType() { return DefaultNotifyType.weiXinMp; } @Override // com.qianwen.core.notify.notifier.NotifierProvider, com.qianwen.core.notify.template.TemplateProvider public Provider getProvider() { return WechatProvider.mpMessage; } @Override // com.qianwen.core.notify.template.TemplateProvider public WechatMpMessageTemplate createTemplate(TemplateProperties properties) { return (WechatMpMessageTemplate) JSON.parseObject(properties.getTemplate(), WechatMpMessageTemplate.class); } @Override // com.qianwen.core.notify.notifier.NotifierProvider public WeixinMpNotifier createNotifier(@Nonnull NotifierProperties properties) { return new WeixinMpNotifier(properties, this.templateManager); } @Override // com.qianwen.core.notify.notifier.NotifierProvider public ConfigMetadata getNotifierConfigMetadata() { return notifierConfig; } @Override // com.qianwen.core.notify.template.TemplateProvider public ConfigMetadata getTemplateConfigMetadata() { return templateConfig; } }