205 getStringFromStruct

This commit is contained in:
2026-02-04 19:42:12 +03:00
parent b8212ddca5
commit b44255dfbd
3 changed files with 54 additions and 24 deletions
+1 -1
View File
@@ -57,7 +57,7 @@
//variables.framework.docs={}; //variables.framework.docs={};
variables.framework.docs.APIName="svc-api"; variables.framework.docs.APIName="svc-api";
variables.framework.docs.APIVersion="0.204"; /*$ git config --global --unset user.password*/ variables.framework.docs.APIVersion="0.205"; /*$ git config --global --unset user.password*/
variables.framework.globalHeaders = structNew(); variables.framework.globalHeaders = structNew();
variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location"; variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location";
+52 -23
View File
@@ -285,7 +285,20 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
</cfif> </cfif>
</cffunction> </cffunction>
<cffunction name="getValueFromStruct" returntype="string" hint="returns scalar"> <!--- <cffunction name="getValueFromStruct" returntype="string" hint="returns scalar">
<cfargument name="struct" type="struct" required="true"/>
<cfargument name="path" type="string" required="true"/>
<cftry>
<cfreturn structGet("arguments.struct.#arguments.path#")/>
<cfcatch type="any">
<!--- можно ожидать ошибки, если по указанному пути расположена не структура --->
<cfreturn cfcatch.message/><!--- халява, для упрощения диагностики --->
</cfcatch>
</cftry>
</cffunction> --->
<cffunction name="getValueFromStruct" returntype="any">
<cfargument name="struct" type="struct" required="true"/> <cfargument name="struct" type="struct" required="true"/>
<cfargument name="path" type="string" required="true"/> <cfargument name="path" type="string" required="true"/>
@@ -298,6 +311,19 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
</cftry> </cftry>
</cffunction> </cffunction>
<cffunction name="getStringFromStruct" returntype="string" hint="returns scalar">
<cfargument name="struct" type="struct" required="true"/>
<cfargument name="path" type="string" required="true"/>
<cfset var value = getValueFromStruct(arguments.struct,arguments.path)/>
<cfif isStruct(value) OR isArray(value)>
<cfreturn serializeJson(value)/>
</cfif>
<cfreturn toString(value)/>
</cffunction>
<cffunction name="getKeyListFromStruct" returntype="string" hint="returns list"> <cffunction name="getKeyListFromStruct" returntype="string" hint="returns list">
<cfargument name="struct" type="struct" required="true"/> <cfargument name="struct" type="struct" required="true"/>
<cfargument name="path" type="string" required="true"/> <cfargument name="path" type="string" required="true"/>
@@ -312,6 +338,7 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
</cftry> </cftry>
</cffunction> </cffunction>
<cffunction name="getArrayAsListFromStruct" returntype="string" hint="returns list"> <cffunction name="getArrayAsListFromStruct" returntype="string" hint="returns list">
<cfargument name="struct" type="struct" required="true"/> <cfargument name="struct" type="struct" required="true"/>
<cfargument name="path" type="string" required="true"/> <cfargument name="path" type="string" required="true"/>
@@ -326,6 +353,7 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
</cftry> </cftry>
</cffunction> </cffunction>
<cffunction name="getInstanceState" returntype="struct"> <cffunction name="getInstanceState" returntype="struct">
<cfargument name="instanceUid" type="guid" required="true"/> <cfargument name="instanceUid" type="guid" required="true"/>
@@ -350,29 +378,30 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
<cfreturn {}/> <cfreturn {}/>
</cffunction> </cffunction>
<cffunction name="getResourceRealmConfig" returntype="struct">
<cfargument name="resourceRealm" type="string" default=#getResourceRealm()#/><!--- платформа может быть определена для родительского инстанса где то в иерархии --->
<cfset var local={}/> <cffunction name="getResourceRealmConfig" returntype="struct">
<cfquery name="local.qResourceRealm" datasource="cmdb"> <cfargument name="resourceRealm" type="string" default=#getResourceRealm()#/><!--- платформа может быть определена для родительского инстанса где то в иерархии --->
select r.resource_realm_id, r.properties
from resource_realm r <cfset var local={}/>
where r.resource_realm=<cfqueryparam cfsqltype="cf_sql_varchar" value=#arguments.resourceRealm#/> <cfquery name="local.qResourceRealm" datasource="cmdb">
</cfquery> select r.resource_realm_id, r.properties
<!--- <cfdump var=#arguments#/> from resource_realm r
<cfdump var=#local.qResourceRealm#/> ---> where r.resource_realm=<cfqueryparam cfsqltype="cf_sql_varchar" value=#arguments.resourceRealm#/>
<cftry> </cfquery>
<cfset var structConfig = deserializeJson(local.qResourceRealm.properties)/> <!--- <cfdump var=#arguments#/>
<cfcatch type="ANY"> <cfdump var=#local.qResourceRealm#/> --->
<cfreturn {"error":"error parsing resource realm properties"}/> <cftry>
<!--- вообще-то такого быть не должно: свойства хранятся в поле jsonb ---> <cfset var structConfig = deserializeJson(local.qResourceRealm.properties)/>
</cfcatch> <cfcatch type="ANY">
</cftry> <cfreturn {"error":"error parsing resource realm properties"}/>
<cfif len(structConfig)> <!--- вообще-то такого быть не должно: свойства хранятся в поле jsonb --->
<cfreturn structConfig/> </cfcatch>
</cfif> </cftry>
<cfreturn {}/> <cfif len(structConfig)>
</cffunction> <cfreturn structConfig/>
</cfif>
<cfreturn {}/>
</cffunction>
@@ -110,6 +110,7 @@
</m:field_set> </m:field_set>
from svc_operation_cfs_param p from svc_operation_cfs_param p
where p.svc_operation_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.svcOperationId#" null=#!isValid('integer',arguments.svcOperationId)#/> where p.svc_operation_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.svcOperationId#" null=#!isValid('integer',arguments.svcOperationId)#/>
AND p.is_actual
order by p.sort, p.svc_operation_cfs_param_id order by p.sort, p.svc_operation_cfs_param_id
</cfquery> </cfquery>