package com.seeyon.apps.esign.utils;

/**
 * 签署回调 URL 构建工具
 */
public final class CallbackUrlBuilder {

    private CallbackUrlBuilder() {}

    public static final String DEFAULT_CALLBACK_PATH = "/seeyon/esigncallback.do?method=callback";
    private static final String SEEYON_PREFIX = "/seeyon";

    private static final String PARAM_FORM_ID = "&formId=";
    private static final String PARAM_TABLE_NAME = "&tablename=";
    private static final String PARAM_UPDATE_FIELD = "&updatefield=";
    private static final String PARAM_STATUS_FIELD = "&statusfield=";
    private static final String PARAM_BIZ_TYPE = "&bizType=";
    private static final String PARAM_X_ID = "&xId=";

    public static String build(String callbackBaseUrl, String bizType,
                               String formId, String tableName,
                               String updateField, String statusField,
                               Long statusEnumId, String appId) {
        String basePath = callbackBaseUrl == null ? DEFAULT_CALLBACK_PATH : SEEYON_PREFIX + callbackBaseUrl;
        return basePath
                + PARAM_FORM_ID + formId
                + PARAM_TABLE_NAME + tableName
                + PARAM_UPDATE_FIELD + updateField
                + PARAM_STATUS_FIELD + statusField + "_" + statusEnumId
                + PARAM_BIZ_TYPE + bizType
                + PARAM_X_ID + appId;
    }
}
