This repository has been archived on 2026-03-21. You can view files and clone it, but cannot push or open issues or pull requests.
payfrit-biz/api/businesses/setHiring.cfm
John 16a3b7c9a3 Replace queryExecute with queryTimed across all endpoints for perf tracking
Converts 200+ endpoint files to use queryTimed() wrapper which tracks
DB query count and execution time. Restores perf dashboard files that
were accidentally moved to _scripts/. Includes portal UI updates.
2026-02-02 00:28:37 -08:00

68 lines
1.5 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">
<cfheader name="Cache-Control" value="no-store">
<cfscript>
/*
PATH: /api/businesses/setHiring.cfm
INPUT (JSON):
{ "BusinessID": 17, "IsHiring": true }
OUTPUT (JSON):
{ OK: true, IsHiring: true } or { OK: false, ERROR: string }
*/
function apiAbort(required struct payload) {
writeOutput(serializeJSON(payload));
abort;
}
function readJsonBody() {
var raw = getHttpRequestData().content;
if (isNull(raw)) raw = "";
if (!len(trim(raw))) return {};
try {
var data = deserializeJSON(raw);
if (isStruct(data)) return data;
} catch (any e) {}
return {};
}
data = readJsonBody();
businessId = structKeyExists(data, "BusinessID") ? val(data.BusinessID) : 0;
isHiring = structKeyExists(data, "IsHiring") ? (data.IsHiring == true ? 1 : 0) : -1;
if (businessId <= 0) {
apiAbort({ "OK": false, "ERROR": "missing_business_id" });
}
if (isHiring == -1) {
apiAbort({ "OK": false, "ERROR": "missing_is_hiring" });
}
try {
queryTimed("
UPDATE Businesses
SET IsHiring = ?
WHERE ID = ?
", [
{ value: isHiring, cfsqltype: "cf_sql_tinyint" },
{ value: businessId, cfsqltype: "cf_sql_integer" }
], { datasource: "payfrit" });
writeOutput(serializeJSON({
"OK": true,
"IsHiring": isHiring == 1
}));
abort;
} catch (any e) {
apiAbort({
"OK": false,
"ERROR": "server_error",
"MESSAGE": e.message
});
}
</cfscript>