package yem.base.common.module.code.api;

import kd.bos.bill.AbstractBillWebApiPlugin;
import kd.bos.entity.api.ApiResult;
import kd.sdk.plugin.Plugin;
import yem.base.common.module.code.dynamic.BillPostCodeEdit;
import yem.base.common.utils.YEM;

import java.util.Map;

/**
 * @author longh
 * @description 脚本执行接口
 * @date 2024年2月3日
 */
public class CodeExcuteApi extends AbstractBillWebApiPlugin implements Plugin {

    @Override
    public ApiResult doCustomService(Map<String, Object> params) {
        String code = (String) params.getOrDefault("code", "");
        Boolean backError = (Boolean) params.getOrDefault("backError", false);
        if (YEM.isEmpty(code)) {
            return ApiResult.fail("code参数未传");
        }
        Object runResult = BillPostCodeEdit.getRunResult(code, backError);
        return ApiResult.success(runResult);
    }

}