业务插件
业务插件机制的背景介绍请参考概念理解。
在线定义插件
进入 制品中心->配置->业务域->插件,新增插件:

为了方便理解定义插件的过程,用户可以按照下面json来理解。
{ "campaignAward": { "slot": "Marketing::campaignNode", "name": "奖品", "desc": "发放特定奖品", "extraProperties": { "type": "Action", "bizType": "Reactive" }, "logicFlows": { "execute": "someLogicFlowImplKey", "nodeInfo": "anotherLogicFlowImplKey" }, "logicFunctions": { "doSomething": "someLogicFunctionImplKey" }, "views": { "templateForm": "someViewKey", "definitionForm": "someViewKey2", "instanceForm": "someViewKey3" }, "models": { "configTO": "someModelKey" } }}其中:
- campaignAward 是插件 key ,确保模块下惟一即可。
- slot 属性指定插槽 key ,插槽 key 由业务开发决定并告知插件开发者。
- extraProperties 中可以放置任意 k:v 对,如何使用也由业务开发者决定。
- logicFlows 、logicFunctions 、views 、models 中都可以放置任意 key ,但 value 应当是真实存在的对应资源的 key 。
对应的反序列化模型结构如下:
// 用于 API 返回class PluginDefinition { private String key; private String slot; private String name; private String desc; private Map<String, String> extraProperties; private Map<String, String> logicFlows; private Map<String, String> logicFunctions; private Map<String, String> views; private Map<String, String> models;}
List<PluginDefinition>使用插件
获取插件信息
MS 类在 SDK 中,直接使用即可。
public class MS { public static List<PluginDefinition> listPluginsBySlot(String slotKey); public static @Nullable PluginDefinition getPlugin(String pluginKey);}调用逻辑流/可编排服务
MS 类在 SDK 中,直接使用即可。
public class MS { public static <T> T getLogicFlowImpl(String resourceKey, Class<T> logicFlowInterfaceClass); public static <T> T getLogicFuncImpl(String resourceKey, Class<T> logicFuncInterfaceClass);}模型转换
ModelUtils 类在 SDK 中,直接使用即可。主要用于插件逻辑中自行将数据转换为自己需要的模型。
public class ModelUtils { public static <T extends RootModel<ID>, ID extends Serializable> T toModel(String jsonStr, Class<T> targetModelClass);}打开视图
按给定的初始数据打开视图,如果视图中有 PayloadAction ,则回调 payloadCallback 。
例如营销流程编辑器,每个节点对应自己的配置视图,点击节点后打开视图;点击提交带回数据。
interface TrantorSDK { openView(viewKey: string, params: { openViewType?: 'Self' | 'Dialog' | 'Drawer' | 'Columns' openViewSize?: 's' | 'm' | 'l' payloadCallback?: (ctx: any) => void context?: { modelKey: string record: IDictionary | IDictionary[] } pageState?: IDictionary env?: IDictionary } ): void;}