71 lines
2.9 KiB
Plaintext
71 lines
2.9 KiB
Plaintext
<cfcomponent extends="taffy.core.resource" taffy:uri="/services/{svcId}">
|
|
|
|
<cfsilent>
|
|
<cfimport prefix="m" taglib="../lib"/>
|
|
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/>
|
|
</cfsilent>
|
|
|
|
|
|
<cffunction name="get" hint="Сервис"><!--- *** TODO проверка принадлежности тенанту --->
|
|
<cfargument name="svcId" type="string" required=true hint="type:integer"/>
|
|
<cftry>
|
|
<cfset this.helper.validateField(arguments, "svcId", "integer")/>
|
|
<cfcatch type="invalidParamValue">
|
|
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
|
</cfcatch>
|
|
</cftry>
|
|
|
|
<!--- <cfdump var=#arguments#/> <cfabort/> --->
|
|
|
|
|
|
<cfquery name="local.qSvc" result="local.result">
|
|
select
|
|
<m:field_set titleMapOut="local.titleMap" lengthOut="local.fieldCount">
|
|
<m:field title="ID" cfSqlType="CF_SQL_INTEGER">s.svc_id</m:field>
|
|
<m:field title="Сервис">s.svc</m:field>
|
|
<m:field title="URL создания">(select url from svc_operation so where so.operation='create' AND so.svc_id=s.svc_id limit 1) as create_url</m:field>
|
|
<m:field>s.is_production_ready</m:field>
|
|
<m:field title="Описание">s.descr</m:field>
|
|
</m:field_set>
|
|
from svc s
|
|
where svc_id=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.svcId#" null=#!isValid('integer',arguments.svcId)#/>
|
|
</cfquery>
|
|
|
|
<cfquery name="local.qSvcOperation" result="local.result">
|
|
select
|
|
<m:field_set titleMapOut="local.operationsMap" lengthOut="local.fieldCount">
|
|
<m:field title="ID" cfSqlType="CF_SQL_INTEGER">j.svc_operation_id</m:field>
|
|
<!--- <m:field title="ID сервиса">j.svc_id</m:field> --->
|
|
<m:field title="Операция">j.operation</m:field>
|
|
<m:field title="URL">j.url</m:field>
|
|
<m:field title="Описание">j.descr</m:field>
|
|
</m:field_set>
|
|
from svc_operation j
|
|
where j.svc_id=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.svcId#" null=#!isValid('integer',arguments.svcId)#/>
|
|
</cfquery>
|
|
|
|
<cfif local.qSvc.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 var rec={}/>
|
|
<cfset this.helper.appendRecord(rec, "", local.titleMap, local.qSvc, this.helper.snake2camel)/>
|
|
<cfset "out.svc"=rec/> --->
|
|
|
|
<cfset "out.svc" = this.helper.appendRecord(
|
|
structNew("linked"), "", local.titleMap, local.qSvc, this.helper.snake2camel
|
|
)/>
|
|
|
|
<cfset "out.svc.operations"=[]/>
|
|
<cfloop query=#local.qSvcOperation#>
|
|
<cfset arrayAppend(out.svc.operations, this.helper.appendRecord(structNew("linked"), "", local.operationsMap, local.qSvcOperation, this.helper.snake2camel))/>
|
|
</cfloop>
|
|
|
|
<cfset "out.runDurationMs"=getTickCount() - request.startTickCount/>
|
|
<cfreturn representationOf(out) />
|
|
</cffunction>
|
|
|
|
</cfcomponent> |