68 lines
3.0 KiB
Plaintext
68 lines
3.0 KiB
Plaintext
<cfcomponent extends="taffy.core.resource" taffy:uri="/serviceOperation/{svcOperationId}">
|
|
|
|
<cfsilent>
|
|
<cfimport prefix="m" taglib="../lib"/>
|
|
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/>
|
|
</cfsilent>
|
|
|
|
|
|
<cffunction name="get" hint="Операция сервиса"><!--- *** TODO проверка принадлежности тенанту --->
|
|
<cfargument name="svcOperationId" type="string" required=true hint="type:integer"/>
|
|
<cftry>
|
|
<cfset this.helper.validateField(arguments, "svcOperationId", "integer")/>
|
|
<cfcatch type="invalidParamValue">
|
|
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
|
</cfcatch>
|
|
</cftry>
|
|
|
|
<cfquery name="local.qSvcOperation" result="local.result">
|
|
select
|
|
<m:field_set titleMapOut="local.titleMap" lengthOut="local.fieldCount">
|
|
<m:field title="ID" cfSqlType="CF_SQL_INTEGER">o.svc_operation_id</m:field>
|
|
<m:field title="operation">o.operation</m:field>
|
|
<m:field title="URL">o.url</m:field>
|
|
<m:field title="Описание">o.descr</m:field>
|
|
</m:field_set>
|
|
from svc_operation o
|
|
where o.svc_operation_id=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.svcOperationId#" null=#!isValid('integer',arguments.svcOperationId)#/>
|
|
</cfquery>
|
|
|
|
<cfquery name="local.qCfsParam" result="local.result">
|
|
select
|
|
<m:field_set titleMapOut="local.cfsParamMap" lengthOut="local.fieldCount">
|
|
<m:field title="ID" cfSqlType="CF_SQL_INTEGER">p.svc_operation_cfs_param_id</m:field>
|
|
<!--- <m:field cfSqlType="CF_SQL_INTEGER">p.svc_operation_id</m:field> --->
|
|
<m:field>p.svc_operation_cfs_param</m:field>
|
|
<m:field>p.label</m:field>
|
|
<m:field>p.data_type</m:field>
|
|
<m:field>p.value_list</m:field>
|
|
<m:field cfSqlType="CF_SQL_INTEGER">p.ref_svc_id</m:field>
|
|
<m:field cfSqlType="CF_SQL_BIT">p.is_required</m:field>
|
|
<m:field>p.default_value</m:field>
|
|
<m:field title="Описание">p.descr</m:field>
|
|
</m:field_set>
|
|
from svc_operation_cfs_param p
|
|
where p.svc_operation_id=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.svcOperationId#" null=#!isValid('integer',arguments.svcOperationId)#/>
|
|
</cfquery>
|
|
|
|
<cfif local.qSvcOperation.recordCount EQ 0>
|
|
<cfreturn representationOf(this.helper.formatMessage("Not Found")).withStatus(404)/>
|
|
</cfif>
|
|
|
|
<cfset var out=structNew("linked")/>
|
|
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
|
|
|
<cfset "out.svcOperation" = this.helper.appendRecord(
|
|
structNew("linked"), "", local.titleMap, local.qSvcOperation, this.helper.snake2camel
|
|
)/>
|
|
|
|
<cfset "out.svcOperation.cfsParams"=[]/>
|
|
<cfloop query=#local.qCfsParam#>
|
|
<cfset arrayAppend(out.svcOperation.cfsParams, this.helper.appendRecord(structNew("linked"), "", local.cfsParamMap, local.qCfsParam, this.helper.snake2camel))/>
|
|
</cfloop>
|
|
|
|
<cfset "out.runDurationMs"=getTickCount() - request.startTickCount/>
|
|
<cfreturn representationOf(out) />
|
|
</cffunction>
|
|
|
|
</cfcomponent> |