diff --git a/src/main/java/com/fr/plugin/dynamic/dbconnect/extension/AbstractFetchDynamicDbConnect.java b/src/main/java/com/fr/plugin/dynamic/dbconnect/extension/AbstractFetchDynamicDbConnect.java new file mode 100644 index 0000000..4aa33b0 --- /dev/null +++ b/src/main/java/com/fr/plugin/dynamic/dbconnect/extension/AbstractFetchDynamicDbConnect.java @@ -0,0 +1,43 @@ +package com.fr.plugin.dynamic.dbconnect.extension; + +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.dynamic.dbconnect.bean.DynamicDbConnectBean; +import com.fr.plugin.dynamic.dbconnect.conf.DynamicDbConnectConfig; +import com.fr.stable.fun.mark.API; + +import java.util.HashMap; +@API( + level = 1 +) +public class AbstractFetchDynamicDbConnect implements FetchDynamicDbConnect{ + + public String mark4Provider() { + return this.getClass().getName(); + } + + public int currentAPILevel() { + return 1; + } + + @Override + public String getConnectName(HashMap params) { + String role = params.get("role");; + String viewlet = params.get("viewlet"); + String fineUserName = params.get("fine_username").toString(); + String fineRole = params.get("fine_role").toString(); + FineLoggerFactory.getLogger().info("DynamicDbConnectDSModifyProvider fineUserName="+fineUserName+",fineRole="+fineRole+",viewlet="+viewlet+",role="+role); + String oldConfig = DynamicDbConnectConfig.getInstance().oldConfig; + String newConfig = DynamicDbConnectConfig.getInstance().getConnectConfig(); + if(oldConfig.equals(newConfig) == false){ + DynamicDbConnectConfig.getInstance().parseConfig(); + DynamicDbConnectConfig.getInstance().oldConfig = newConfig; + } + + DynamicDbConnectBean connectBean = DynamicDbConnectConfig.getInstance().getDbConnectBean(viewlet,role); + if(connectBean != null){ + return connectBean.getConnectName(); + } + + return null; + } +}