APL函數(shù)代碼開(kāi)放場(chǎng)景-自定義控制器Java接口說(shuō)明
2025-01-07 15:23:45 39 本站
package fx.custom.apl.example.controller;
import com.fxiaoke.functions.FunctionContext;
import com.fxiaoke.functions.client.DebugHelper;
import com.fxiaoke.functions.template.IControllerAction;
import com.fxiaoke.functions.utils.Maps;
import java.io.IOException;
import java.util.Map;
import static com.fxiaoke.functions.Fx.log;
/**
* 異步自定義控制器使用樣例
* 將通用邏輯放到一個(gè)自定義控制器函數(shù)中,還可以設(shè)置參數(shù),然后由其他調(diào)用
*/
public class ControllerExample implements IControllerAction {
/**
* 自定義控制器函數(shù)的運(yùn)行方法
*/
@Override
public Map execute(FunctionContext context, Map<String, Object> syncArg) {
// todo 自定義控制器調(diào)用方函數(shù)// Map data = context.getData();// Map param = Maps.of("objectData", Maps.of(// "objAPIName", data.get("object_describe_api_name"),// "masterFieldVal", Maps.of("test_null_value", null,// "CRM_SALES_ORDER_NO", data.get("filed_asdvaf__c"),// "SALES_ORGANIZATION", data.get("filed_gh4hj__c"),// "PRODUCT_GROUP", data.get("filed_htj6__c"),// "CUSTOMER_NO", data.get("filed_jy032__c")// )// ));//// //異步調(diào)用func_c6hYc__c,不阻塞當(dāng)前函數(shù)但拿不到返回結(jié)果,觸發(fā)多次順序也無(wú)法保證// APIResult apiResult = Fx.function.executeAsyncFunc("ControlRun__c", Maps.of("syncArg", param));// if (apiResult.isError()) {// log.info("error:" + apiResult.getMessage());// }// log.info(apiResult.getData());
/*******************************分割線(xiàn)**********************************/
// todo 自定義控制器被調(diào)用方函數(shù) ,注意先在編輯器右上方設(shè)置參數(shù)syncArg
Map objectData = (Map) syncArg.get("syncArg");
log.info(objectData);
return Maps.of("success", true);
}
public static void main(String[] args) throws IOException {
DebugHelper helper = new DebugHelper();
helper.init();
Map syncArg = Maps.of("objectData", Maps.of(
"objAPIName", "salesOrderTakeDown",
"masterFieldVal", Maps.of("test_null_value", null,
"CRM_SALES_ORDER_NO", "SHDD-202210130622",
"SALES_ORGANIZATION", "1000",
"PRODUCT_GROUP", "00",
"CUSTOMER_NO", "2200006"
)
));
//模擬調(diào)試的上下文,沒(méi)有數(shù)據(jù)可以使用helper.dataContext mock核心數(shù)據(jù)
FunctionContext context = helper.context("object_zBB6O__c", "63fd7a30ffd89f00013c7be3");
Map execute = new ControllerExample().execute(context, Maps.of("syncArg", syncArg));
log.info(execute);
}}
部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),如有侵權(quán),請(qǐng)聯(lián)系客服刪除處理。