150
This commit is contained in:
+30
-17
@@ -51,7 +51,7 @@
|
||||
|
||||
//variables.framework.docs={};
|
||||
variables.framework.docs.APIName="svc-api";
|
||||
variables.framework.docs.APIVersion="0.149"; /*$ git config --global --unset user.password*/
|
||||
variables.framework.docs.APIVersion="0.150"; /*$ git config --global --unset user.password*/
|
||||
|
||||
variables.framework.globalHeaders = structNew();
|
||||
variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location";
|
||||
@@ -255,7 +255,8 @@
|
||||
if (prefix.status_code NEQ 200) {
|
||||
//writedump(this.iamServiceUrl);
|
||||
//writedump(resp);
|
||||
return representationOf( {"iamServiceUrl"=this.iamServiceUrl, "idpResponse"=resp} ).withStatus(500);
|
||||
var iamStatusCode = (isValid("integer", prefix.status_code)) ? val(prefix.status_code) : 500;
|
||||
return representationOf( {"iamServiceUrl"=this.iamServiceUrl, "idpResponse"=resp} ).withStatus(iamStatusCode);
|
||||
//abort;
|
||||
//throw("IDP response not OK");
|
||||
}
|
||||
@@ -279,7 +280,7 @@
|
||||
return representationOf( {"exception"=e, "idpResponse"=result} );
|
||||
}
|
||||
|
||||
var usrCustomerInfo=getUsrCustomerInfo(idpUserData.userInfo.contactId);
|
||||
var usrCustomerInfo=getUsrCustomerInfo(idpUserData.userInfo.contactId, idpUserData.userInfo.companyId);
|
||||
|
||||
if (lCase(arguments.cfc) EQ 'user') {
|
||||
if (structIsEmpty(usrCustomerInfo)) return representationOf("User information not found").withStatus(404);
|
||||
@@ -392,6 +393,7 @@
|
||||
|
||||
<cffunction name="getUsrCustomerInfo">
|
||||
<cfargument name="usrUid"/>
|
||||
<cfargument name="contragentUid"/>
|
||||
|
||||
<!--- глупейшее определение спецификации по умолчанию (надо переделать, чтобы создавалась, или вообще просто записывать факты без спеки). Но помним, что при постановке на тестирование цены еше не фиксированы --->
|
||||
<!--- заметим, что у нас контрагент может быть определен параллельно, от IDP --->
|
||||
@@ -399,30 +401,41 @@
|
||||
|
||||
<!--- Во избежании потери времени при отладке временно сделаем создание дефолтового контракта и спецификации, если их нет --->
|
||||
<!--- *** хватается первый попавшийся контракт и спецификация --->
|
||||
<cfquery name="local.qGetCustomerInfo">
|
||||
|
||||
<cfquery name="local.qGetContragentInfo">
|
||||
select z.contragent_id, c.contragent_id, c.contract_id, s.specification_id
|
||||
from contragent z
|
||||
join contract c on (z.contragent_id=c.contragent_id)
|
||||
join specification s on (c.contract_id=s.contract_id)
|
||||
where z.external_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.contragentUid#" null=#!isValid('guid',arguments.contragentUid)#/>
|
||||
order by s.specification_id desc
|
||||
limit 1;
|
||||
</cfquery>
|
||||
|
||||
|
||||
<cfquery name="local.qGetUserInfo">
|
||||
select u.usr_id, c.contragent_id, c.contract_id, s.specification_id
|
||||
from usr u
|
||||
join contract c on (u.contragent_id=c.contragent_id)
|
||||
join specification s on (c.contract_id=s.contract_id)
|
||||
where idp_usr_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.usrUid#" null=#!isValid('guid',arguments.usrUid)#/>
|
||||
order by specification_id desc
|
||||
where u.idp_usr_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.usrUid#" null=#!isValid('guid',arguments.usrUid)#/>
|
||||
order by s.specification_id desc
|
||||
limit 1;
|
||||
</cfquery>
|
||||
</cfquery>
|
||||
|
||||
<!--- <cfdump var=#local.qGetCustomerInfo#/><cfabort/> --->
|
||||
<cfif local.qGetCustomerInfo.recordCount GT 0>
|
||||
<cfreturn {"usrId"=#local.qGetCustomerInfo.usr_id#,
|
||||
"contragentId"=#local.qGetCustomerInfo.contragent_id#,
|
||||
"contractId"=#local.qGetCustomerInfo.contract_id#,
|
||||
"specificationId"=#local.qGetCustomerInfo.specification_id#
|
||||
}/>
|
||||
<cfelse>
|
||||
<cfreturn {}/> <!--- неуклюжий способ обозначить ошибку --->
|
||||
</cfif>
|
||||
<cfreturn {
|
||||
"usrId"=#local.qGetUserInfo.usr_id#,
|
||||
"contragentId"=#local.qGetContragentInfo.contragent_id#,
|
||||
"contractId"=#local.qGetContragentInfo.contract_id#,
|
||||
"specificationId"=#local.qGetContragentInfo.specification_id#
|
||||
}/>
|
||||
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="corsHeaders">
|
||||
<!--- фрагмент взят из taffy/core/api.cfc и немного переписан --->
|
||||
<!--- *** фрагмент взят из taffy/core/api.cfc и немного переписан --->
|
||||
<cfset var _taffyRequest=request._taffyRequest/>
|
||||
<cfset local={}/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user