103 bookmark fixes

This commit is contained in:
msyu
2025-05-13 22:32:29 +03:00
parent 7b9e811cce
commit 95da82b6df
7 changed files with 426 additions and 7 deletions
+50 -1
View File
@@ -3,7 +3,56 @@
<cfsilent>
<cfimport prefix="m" taglib="../lib"/>
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/>
</cfsilent>
</cfsilent>
<cffunction name="get" hint="Букмарк">
<cfargument name="bookmarkUid" type="string" required=true hint="type:guid"/>
<cfset var local={}/>
<cftry>
<cftry>
<cfset this.helper.validateField(arguments, "bookmarkUid", "guid")/>
<cfcatch type="invalidParamValue">
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
</cfcatch>
</cftry>
<cfset var out={}/>
<cfset request.locateIamService()/>
<cfquery name="local.qRead" result="local.result">
select
<m:field_set titleMapOut="local.titleMap" lengthOut="local.fieldCount">
<m:field>b.bookmark_uid::text as bookmark_uid</m:field>
<m:field>b.bookmark</m:field>
<m:field>b.descr</m:field>
<m:field>b.url</m:field>
<m:field>b.icon_url</m:field>
<m:field>b.contragent_id</m:field>
<m:field formatter=#request.castToBool#>b.is_enabled</m:field>
<m:field>to_char(b.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created</m:field>
<m:field>to_char(b.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated</m:field>
</m:field_set>
from bookmark b
where b.bookmark_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.bookmarkUid#" null=#!isValid('guid',arguments.bookmarkUid)#/>
AND (b.contragent_id = <cfqueryparam cfsqltype="cf_sql_integer" value=#arguments.contragentId# null=#!isNumeric(arguments.contragentId)#/>)
</cfquery>
<!--- <cfdump var=#local.qRead#/><cfabort/> --->
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
<cfset "out.bookmark" = this.helper.appendRecord(structNew("linked"), "", local.titleMap, local.qRead, this.helper.snake2camel)/>
<cfset "out.runDurationMs"=getTickCount()-request.startTickCount/>
<cfreturn representationOf(out)/>
<cfcatch type="any">
<cfreturn representationOf(cfcatch)/>
</cfcatch>
</cftry>
</cffunction>
<cffunction name="patch">
<cfargument name="bookmarkUid" type="string" required=true hint="type:guid"/>