232 service catalog
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@
|
||||
|
||||
//variables.framework.docs={};
|
||||
variables.framework.docs.APIName="svc-api";
|
||||
variables.framework.docs.APIVersion="0.231"; /*$ git config --global --unset user.password*/
|
||||
variables.framework.docs.APIVersion="0.232"; /*$ git config --global --unset user.password*/
|
||||
|
||||
variables.framework.globalHeaders = structNew();
|
||||
variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location";
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
bookmark={prefix="b", type="string"},
|
||||
url={prefix="b", type="string"},
|
||||
icon_url={prefix="b", type="string"},
|
||||
descr={prefix="b", type="integer"},
|
||||
descr={prefix="b", type="string"},
|
||||
is_enabled={prefix="b", type="boolean"},
|
||||
sort={prefix="b", type="integer"}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy:uri="/service-catalog/services">
|
||||
|
||||
<cfsilent>
|
||||
<cfimport prefix="m" taglib="../lib"/>
|
||||
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/><!---*** странно, почему мы его видим?---><!---вынести в апп?--->
|
||||
</cfsilent>
|
||||
|
||||
<!---спецификация полей, пригодных для фильтрации (?и сортировки)--->
|
||||
<cfset this.fieldsSpec={
|
||||
service_id={prefix="s", type="cf_sql_integer"}
|
||||
,business_line_id={prefix="s", type="cf_sql_integer"}
|
||||
,business_line={prefix="s", type="cf_sql_varchar"}
|
||||
,area_id={prefix="s", type="cf_sql_integer"}
|
||||
,area={prefix="s", type="cf_sql_varchar"}
|
||||
,area_code={prefix="s", type="cf_sql_varchar"}
|
||||
,analytic_code={prefix="s", type="cf_sql_varchar"}
|
||||
,abstract_service_id={prefix="s", type="cf_sql_integer"}
|
||||
,abstract_service={prefix="s", type="cf_sql_varchar"}
|
||||
,abstract_service_code={prefix="s", type="cf_sql_varchar"}
|
||||
,abstract_service_status_id={prefix="s", type="cf_sql_integer"}
|
||||
,abstract_service_status={prefix="s", type="cf_sql_varchar"}
|
||||
,service_code={prefix="s", type="cf_sql_varchar"}
|
||||
,service={prefix="s", type="cf_sql_varchar"}
|
||||
,modifier={prefix="s", type="cf_sql_varchar"}
|
||||
,modifier_code={prefix="s", type="cf_sql_varchar"}
|
||||
,measure_id={prefix="s", type="cf_sql_integer"}
|
||||
,service_status_id={prefix="s", type="cf_sql_integer"}
|
||||
,service_status={prefix="s", type="cf_sql_varchar"}
|
||||
,measure_short={prefix="s", type="cf_sql_varchar"}
|
||||
,sort={prefix="s", type="cf_sql_integer"}
|
||||
,vat_perc={prefix="s", type="cf_sql_integer"}
|
||||
,vat_free={prefix="s", type="cf_sql_bit"}
|
||||
,vat_rate={prefix="s", type="cf_sql_numeric"}
|
||||
,capacity_legend={prefix="s", type="cf_sql_integer"}
|
||||
,commercial_note={prefix="s", type="cf_sql_varchar"}
|
||||
,is_published={prefix="s", type="cf_sql_bit"}
|
||||
}
|
||||
/>
|
||||
|
||||
<!--- предполагается показывать букмарки только "настоящим" клиентам, поэтому используем contragent_id как признак своих--->
|
||||
|
||||
<cffunction name="get" hint="Каталог конкретных услуг">
|
||||
<cfargument name="pageSize" type="string" hint="type:integer" default="100"/>
|
||||
<cfargument name="page" type="string" hint="type:integer" default="1"/>
|
||||
<cfargument name="orderBy" type="string" hint="type:string, description:comma-separated list of fields to sort by, example:fld1.ASC,fld2.DESC,fld3.ASC" default=""/>
|
||||
|
||||
<cfset var local={}/>
|
||||
<cftry> <!--- отладка на время проблемы 404 --->
|
||||
|
||||
|
||||
<!---parse and validate request parameters--->
|
||||
<cftry>
|
||||
<cfset this.helper.validateField(arguments, "pageSize", "integer")/>
|
||||
<cfset this.helper.validateField(arguments, "page", "integer")/>
|
||||
|
||||
<!---мы мирно игнорируем поля, отсутствующие в спецификации, что позволяет не делать исключения для orderBy и т.п.--->
|
||||
<cfset var filter=this.helper.parseFilterParams(this.fieldsSpec)/>
|
||||
<!--- <cfset var order=this.helper.parseOrderBy(this.fieldsSpec, arguments.orderBy)/> --->
|
||||
|
||||
<cfcatch type="invalidParamValue">
|
||||
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
||||
</cfcatch>
|
||||
<cfcatch type="any">
|
||||
<cfreturn representationOf(cfcatch)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfset var out={}/>
|
||||
<cfset var maxrows=arguments.pageSize*arguments.page/>
|
||||
<cfset var startrow=arguments.pageSize*(arguments.page-1)+1/>
|
||||
|
||||
<!--- <cfset request.locateIamService()/> --->
|
||||
|
||||
<cfquery name="local.qRead" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.titleMap" lengthOut="local.fieldCount">
|
||||
<m:field title="service_id">service_id</m:field>
|
||||
<m:field title="business_line_id">business_line_id</m:field>
|
||||
<m:field title="business_line">business_line</m:field>
|
||||
<m:field title="area_id">area_id</m:field>
|
||||
<m:field title="area">area</m:field>
|
||||
<m:field title="area_code">area_code</m:field>
|
||||
<m:field title="analytic_code">analytic_code</m:field>
|
||||
<m:field title="abstract_service_id">abstract_service_id</m:field>
|
||||
<m:field title="abstract_service">abstract_service</m:field>
|
||||
<m:field title="abstract_service_code">abstract_service_code</m:field>
|
||||
<m:field title="abstract_service_status_id">abstract_service_status_id</m:field>
|
||||
<m:field title="abstract_service_status">abstract_service_status</m:field>
|
||||
<m:field title="service_code">service_code</m:field>
|
||||
<m:field title="service">service</m:field>
|
||||
<m:field title="modifier">modifier</m:field>
|
||||
<m:field title="modifier_code">modifier_code</m:field>
|
||||
<m:field title="measure_id">measure_id</m:field>
|
||||
<m:field title="service_status_id">service_status_id</m:field>
|
||||
<m:field title="service_status">service_status</m:field>
|
||||
<m:field title="measure_short">measure_short</m:field>
|
||||
<m:field title="sort">sort</m:field>
|
||||
<m:field title="vat_perc">vat_perc</m:field>
|
||||
<m:field title="vat_free">vat_free</m:field>
|
||||
<m:field title="vat_rate">vat_rate</m:field>
|
||||
<m:field title="capacity_legend">capacity_legend</m:field>
|
||||
<m:field title="commercial_note">commercial_note</m:field>
|
||||
<m:field title="is_published">is_published</m:field>
|
||||
<m:field title="dt_load">dt_load</m:field>
|
||||
</m:field_set>
|
||||
from service_catalog.service s
|
||||
where 1=1 <m:filter_build filter=#filter#/>
|
||||
order by analytic_code
|
||||
, abstract_service
|
||||
, service_id
|
||||
, coalesce(sort,0)
|
||||
<!--- , modifier_id --->
|
||||
limit #maxrows#
|
||||
</cfquery>
|
||||
<!--- <cfdump var=#local.qRead#/><cfabort/> --->
|
||||
|
||||
|
||||
|
||||
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
||||
<cfset "out.resultSetSize"=#local.qRead.recordCount#/>
|
||||
<cfset "out.pageSize"=#arguments.pageSize*1#/>
|
||||
<cfset "out.page"=#arguments.page*1#/>
|
||||
<cfset "out.orderBy"=#arguments.orderBy#/>
|
||||
|
||||
<cfset var resultCollection=[]/>
|
||||
<cfloop query=#local.qRead# startRow=#startrow# endRow=#(startrow+maxrows-1)#>
|
||||
<cfset var rec={}/>
|
||||
<cfset this.helper.appendRecord(rec, "", local.titleMap, local.qRead, this.helper.snake2camel)/>
|
||||
<cfset arrayAppend(resultCollection, rec)/>
|
||||
</cfloop>
|
||||
|
||||
<cfset "out.size"=#arrayLen(resultCollection)#/>
|
||||
<cfset "out.results"=#resultCollection#/>
|
||||
<cfset "out.runDurationMs"=getTickCount()-request.startTickCount/>
|
||||
<cfreturn representationOf(out)/>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfreturn representationOf(cfcatch)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
|
||||
<cfscript>
|
||||
function plain2htm(s) {
|
||||
return replace(replace(s, chr(13),'',"ALL"),chr(10),'<br/>', "ALL");
|
||||
}
|
||||
//request.plain2htm = plain2htm;
|
||||
|
||||
function htm2plain(s) {
|
||||
return replaceNoCase(s, '<br/>', '#chr(13)##chr(10)#', "ALL");
|
||||
}
|
||||
//request.htm2plain = htm2plain;
|
||||
|
||||
function cleanHtm(s) {
|
||||
return replaceList(s, '<,>,"', '<,>,"');
|
||||
}
|
||||
//request.cleanHtm = cleanHtm;
|
||||
</cfscript>
|
||||
|
||||
<cffunction name="plain2HtmClean">
|
||||
<cfargument name="s" type="string"/>
|
||||
<cfreturn plain2htm(cleanHtm(s))/>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="cleanInput">
|
||||
<cfargument name="s" type="string"/>
|
||||
<cfreturn htmlEditFormat(s)/>
|
||||
</cffunction>
|
||||
|
||||
</cfcomponent>
|
||||
@@ -0,0 +1,205 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy:uri="/service-catalog/service-params">
|
||||
|
||||
<cfsilent>
|
||||
<cfimport prefix="m" taglib="../lib"/>
|
||||
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/><!---*** странно, почему мы его видим?---><!---вынести в апп?--->
|
||||
</cfsilent>
|
||||
|
||||
<!---спецификация полей, пригодных для фильтрации (?и сортировки)--->
|
||||
<cfset this.fieldsSpec={
|
||||
service_param_id={prefix="p", type="cf_sql_integer"}
|
||||
,service_id={prefix="p", type="cf_sql_integer"}
|
||||
,service_param={prefix="p", type="cf_sql_varchar"}
|
||||
,param={prefix="p", type="cf_sql_varchar"}
|
||||
,component_code={prefix="p", type="cf_sql_varchar"}
|
||||
,component={prefix="p", type="cf_sql_varchar"}
|
||||
,measure_id={prefix="p", type="cf_sql_integer"}
|
||||
,measure_short={prefix="p", type="cf_sql_varchar"}
|
||||
,min_value={prefix="p", type="cf_sql_numeric"}
|
||||
,max_value={prefix="p", type="cf_sql_numeric"}
|
||||
,incr={prefix="p", type="cf_sql_numeric"}
|
||||
,param_class_sort={prefix="p", type="cf_sql_integer"}
|
||||
,param_sort={prefix="p", type="cf_sql_integer"}
|
||||
,sku={prefix="p", type="cf_sql_varchar"}
|
||||
,is_multiple={prefix="p", type="cf_sql_bit"}
|
||||
|
||||
,business_line_id={prefix="s", type="cf_sql_integer"}
|
||||
,business_line={prefix="s", type="cf_sql_varchar"}
|
||||
,area_id={prefix="s", type="cf_sql_integer"}
|
||||
,area={prefix="s", type="cf_sql_varchar"}
|
||||
,area_code={prefix="s", type="cf_sql_varchar"}
|
||||
,analytic_code={prefix="s", type="cf_sql_varchar"}
|
||||
,abstract_service_id={prefix="s", type="cf_sql_integer"}
|
||||
,abstract_service={prefix="s", type="cf_sql_varchar"}
|
||||
,abstract_service_code={prefix="s", type="cf_sql_varchar"}
|
||||
,abstract_service_status_id={prefix="s", type="cf_sql_integer"}
|
||||
,abstract_service_status={prefix="s", type="cf_sql_varchar"}
|
||||
,service_code={prefix="s", type="cf_sql_varchar"}
|
||||
,service={prefix="s", type="cf_sql_varchar"}
|
||||
,modifier={prefix="s", type="cf_sql_varchar"}
|
||||
,modifier_code={prefix="s", type="cf_sql_varchar"}
|
||||
|
||||
,service_status_id={prefix="s", type="cf_sql_integer"}
|
||||
,service_status={prefix="s", type="cf_sql_varchar"}
|
||||
<!--- ,measure_short={prefix="s", type="cf_sql_varchar"} --->
|
||||
,sort={prefix="s", type="cf_sql_integer"}
|
||||
,vat_perc={prefix="s", type="cf_sql_integer"}
|
||||
,vat_free={prefix="s", type="cf_sql_bit"}
|
||||
,vat_rate={prefix="s", type="cf_sql_numeric"}
|
||||
,capacity_legend={prefix="s", type="cf_sql_integer"}
|
||||
,commercial_note={prefix="s", type="cf_sql_varchar"}
|
||||
,is_published={prefix="s", type="cf_sql_bit"}
|
||||
}
|
||||
/>
|
||||
|
||||
<!--- предполагается показывать букмарки только "настоящим" клиентам, поэтому используем contragent_id как признак своих--->
|
||||
|
||||
<cffunction name="get" hint="Каталог конкретных услуг">
|
||||
<cfargument name="pageSize" type="string" hint="type:integer" default="100"/>
|
||||
<cfargument name="page" type="string" hint="type:integer" default="1"/>
|
||||
<cfargument name="orderBy" type="string" hint="type:string, description:comma-separated list of fields to sort by, example:fld1.ASC,fld2.DESC,fld3.ASC" default=""/>
|
||||
|
||||
<cfset var local={}/>
|
||||
<cftry> <!--- отладка на время проблемы 404 --->
|
||||
|
||||
|
||||
<!---parse and validate request parameters--->
|
||||
<cftry>
|
||||
<cfset this.helper.validateField(arguments, "pageSize", "integer")/>
|
||||
<cfset this.helper.validateField(arguments, "page", "integer")/>
|
||||
|
||||
<!---мы мирно игнорируем поля, отсутствующие в спецификации, что позволяет не делать исключения для orderBy и т.п.--->
|
||||
<cfset var filter=this.helper.parseFilterParams(this.fieldsSpec)/>
|
||||
<!--- <cfset var order=this.helper.parseOrderBy(this.fieldsSpec, arguments.orderBy)/> --->
|
||||
|
||||
<cfcatch type="invalidParamValue">
|
||||
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
||||
</cfcatch>
|
||||
<cfcatch type="any">
|
||||
<cfreturn representationOf(cfcatch)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfset var out={}/>
|
||||
<cfset var maxrows=arguments.pageSize*arguments.page/>
|
||||
<cfset var startrow=arguments.pageSize*(arguments.page-1)+1/>
|
||||
|
||||
<!--- <cfset request.locateIamService()/> --->
|
||||
|
||||
<cfquery name="local.qRead" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.titleMap" lengthOut="local.fieldCount">
|
||||
<m:field title="service_param_id">p.service_param_id</m:field>
|
||||
<m:field title="service_id">p.service_id</m:field>
|
||||
<m:field title="service_param">p.service_param</m:field>
|
||||
<m:field title="param">p.param</m:field>
|
||||
<m:field title="component_code">p.component_code</m:field>
|
||||
<m:field title="component">p.component</m:field>
|
||||
<m:field title="measure_id">p.measure_id</m:field>
|
||||
<m:field title="measure_short">p.measure_short</m:field>
|
||||
<m:field title="min_value">p.min_value</m:field>
|
||||
<m:field title="max_value">p.max_value</m:field>
|
||||
<m:field title="incr">p.incr</m:field>
|
||||
<m:field title="param_class_sort">p.param_class_sort</m:field>
|
||||
<m:field title="param_sort">p.param_sort</m:field>
|
||||
<m:field title="sku">p.sku</m:field>
|
||||
<m:field title="is_multiple">p.is_multiple</m:field>
|
||||
<m:field title="dt_load">p.dt_load</m:field>
|
||||
|
||||
<m:field title="business_line_id">s.business_line_id</m:field>
|
||||
<m:field title="business_line">s.business_line</m:field>
|
||||
<m:field title="area_id">s.area_id</m:field>
|
||||
<m:field title="area">s.area</m:field>
|
||||
<m:field title="area_code">s.area_code</m:field>
|
||||
<m:field title="analytic_code">s.analytic_code</m:field>
|
||||
<m:field title="abstract_service_id">s.abstract_service_id</m:field>
|
||||
<m:field title="abstract_service">s.abstract_service</m:field>
|
||||
<m:field title="abstract_service_code">s.abstract_service_code</m:field>
|
||||
<m:field title="abstract_service_status_id">s.abstract_service_status_id</m:field>
|
||||
<m:field title="abstract_service_status">s.abstract_service_status</m:field>
|
||||
<m:field title="service_code">s.service_code</m:field>
|
||||
<m:field title="service">s.service</m:field>
|
||||
<m:field title="modifier">s.modifier</m:field>
|
||||
<m:field title="modifier_code">s.modifier_code</m:field>
|
||||
<!--- <m:field title="measure_id">s.measure_id</m:field> --->
|
||||
<m:field title="service_status_id">s.service_status_id</m:field>
|
||||
<m:field title="service_status">s.service_status</m:field>
|
||||
<!--- <m:field title="measure_short">s.measure_short</m:field> --->
|
||||
<m:field title="sort">s.sort</m:field>
|
||||
<m:field title="vat_perc">s.vat_perc</m:field>
|
||||
<m:field title="vat_free">s.vat_free</m:field>
|
||||
<m:field title="vat_rate">s.vat_rate</m:field>
|
||||
<m:field title="capacity_legend">s.capacity_legend</m:field>
|
||||
<m:field title="commercial_note">commercial_note</m:field>
|
||||
<m:field title="is_published">s.is_published</m:field>
|
||||
</m:field_set>
|
||||
from service_catalog.service_param p
|
||||
join service_catalog.service s on (p.service_id=s.service_id)
|
||||
where 1=1 <m:filter_build filter=#filter#/>
|
||||
order by analytic_code
|
||||
, abstract_service
|
||||
, service_id
|
||||
, coalesce(sort,0)
|
||||
<!--- , modifier_id --->
|
||||
limit #maxrows#
|
||||
</cfquery>
|
||||
<!--- <cfdump var=#local.qRead#/><cfabort/> --->
|
||||
|
||||
|
||||
|
||||
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
||||
<cfset "out.resultSetSize"=#local.qRead.recordCount#/>
|
||||
<cfset "out.pageSize"=#arguments.pageSize*1#/>
|
||||
<cfset "out.page"=#arguments.page*1#/>
|
||||
<cfset "out.orderBy"=#arguments.orderBy#/>
|
||||
|
||||
<cfset var resultCollection=[]/>
|
||||
<cfloop query=#local.qRead# startRow=#startrow# endRow=#(startrow+maxrows-1)#>
|
||||
<cfset var rec={}/>
|
||||
<cfset this.helper.appendRecord(rec, "", local.titleMap, local.qRead, this.helper.snake2camel)/>
|
||||
<cfset arrayAppend(resultCollection, rec)/>
|
||||
</cfloop>
|
||||
|
||||
<cfset "out.size"=#arrayLen(resultCollection)#/>
|
||||
<cfset "out.results"=#resultCollection#/>
|
||||
<cfset "out.runDurationMs"=getTickCount()-request.startTickCount/>
|
||||
<cfreturn representationOf(out)/>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfreturn representationOf(cfcatch)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
|
||||
<cfscript>
|
||||
function plain2htm(s) {
|
||||
return replace(replace(s, chr(13),'',"ALL"),chr(10),'<br/>', "ALL");
|
||||
}
|
||||
//request.plain2htm = plain2htm;
|
||||
|
||||
function htm2plain(s) {
|
||||
return replaceNoCase(s, '<br/>', '#chr(13)##chr(10)#', "ALL");
|
||||
}
|
||||
//request.htm2plain = htm2plain;
|
||||
|
||||
function cleanHtm(s) {
|
||||
return replaceList(s, '<,>,"', '<,>,"');
|
||||
}
|
||||
//request.cleanHtm = cleanHtm;
|
||||
</cfscript>
|
||||
|
||||
<cffunction name="plain2HtmClean">
|
||||
<cfargument name="s" type="string"/>
|
||||
<cfreturn plain2htm(cleanHtm(s))/>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="cleanInput">
|
||||
<cfargument name="s" type="string"/>
|
||||
<cfreturn htmlEditFormat(s)/>
|
||||
</cffunction>
|
||||
|
||||
</cfcomponent>
|
||||
Reference in New Issue
Block a user