Update all SQL queries, query result references, and ColdFusion code to match
the renamed database schema. Tables use plural CamelCase, PKs are all `ID`,
column prefixes stripped (e.g. BusinessName→Name, UserFirstName→FirstName).
Key changes:
- Strip table-name prefixes from all column references (Businesses, Users,
Addresses, Hours, Menus, Categories, Items, Stations, Orders,
OrderLineItems, Tasks, TaskCategories, TaskRatings, QuickTaskTemplates,
ScheduledTaskDefinitions, ChatMessages, Beacons, ServicePoints, Employees,
VisitorTrackings, ApiPerfLogs, tt_States, tt_Days, tt_AddressTypes,
tt_OrderTypes, tt_TaskTypes)
- Rename PK references from {TableName}ID to ID in all queries
- Rewrite 7 admin beacon files to use ServicePoints.BeaconID instead of
dropped lt_Beacon_Businesses_ServicePoints link table
- Rewrite beacon assignment files (list, save, delete) for new schema
- Fix FK references incorrectly changed to ID (OrderLineItems.OrderID,
Categories.MenuID, Tasks.CategoryID, ServicePoints.BeaconID)
- Update Addresses: AddressLat→Latitude, AddressLng→Longitude
- Update Users: UserPassword→Password, UserIsEmailVerified→IsEmailVerified,
UserIsActive→IsActive, UserBalance→Balance, etc.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
113 lines
3.2 KiB
Text
113 lines
3.2 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
|
|
<cfscript>
|
|
/**
|
|
* Lookup beacons by UUID
|
|
*
|
|
* POST: {
|
|
* UUIDs: array of UUID strings (without dashes, uppercase)
|
|
* }
|
|
*
|
|
* Returns: {
|
|
* OK: true,
|
|
* BEACONS: [
|
|
* {
|
|
* UUID: "...",
|
|
* BeaconID: int,
|
|
* Name: string,
|
|
* BusinessID: int,
|
|
* Name: string,
|
|
* ServicePointID: int,
|
|
* Name: string,
|
|
* ParentBusinessID: int (if applicable),
|
|
* ParentName: string (if applicable),
|
|
* HasChildren: boolean
|
|
* }
|
|
* ]
|
|
* }
|
|
*/
|
|
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
requestData = deserializeJSON(toString(getHttpRequestData().content));
|
|
|
|
uuids = requestData.UUIDs ?: [];
|
|
|
|
if (!isArray(uuids) || arrayLen(uuids) == 0) {
|
|
response["OK"] = true;
|
|
response["BEACONS"] = [];
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
// Clean and normalize UUIDs (remove dashes, uppercase)
|
|
cleanUUIDs = [];
|
|
for (uuid in uuids) {
|
|
cleanUUID = uCase(reReplace(uuid, "-", "", "all"));
|
|
if (len(cleanUUID) == 32) {
|
|
arrayAppend(cleanUUIDs, cleanUUID);
|
|
}
|
|
}
|
|
|
|
if (arrayLen(cleanUUIDs) == 0) {
|
|
response["OK"] = true;
|
|
response["BEACONS"] = [];
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
// Query for matching beacons with business info
|
|
// Beacons resolve to businesses via: ServicePoints, join table, or owner
|
|
qBeacons = queryExecute("
|
|
SELECT
|
|
b.ID,
|
|
b.Name,
|
|
b.UUID,
|
|
COALESCE(sp.ID, 0) AS ServicePointID,
|
|
COALESCE(sp.Name, '') AS Name,
|
|
COALESCE(sp.BusinessID, lt.BusinessID, b.BusinessID) AS BusinessID,
|
|
biz.Name,
|
|
biz.ParentBusinessID,
|
|
parent.Name AS ParentName,
|
|
(SELECT COUNT(*) FROM Businesses WHERE ParentBusinessID = biz.ID) AS ChildCount
|
|
FROM Beacons b
|
|
LEFT JOIN ServicePoints sp ON sp.BeaconID = b.ID
|
|
LEFT JOIN lt_BeaconsID_BusinessesID lt ON lt.BeaconID = b.ID
|
|
INNER JOIN Businesses biz ON COALESCE(sp.BusinessID, lt.BusinessID, b.BusinessID) = biz.ID
|
|
LEFT JOIN Businesses parent ON biz.ParentBusinessID = parent.ID
|
|
WHERE b.UUID IN (:uuids)
|
|
AND b.IsActive = 1
|
|
AND biz.IsDemo = 0
|
|
AND biz.IsPrivate = 0
|
|
", {
|
|
uuids: { value: arrayToList(cleanUUIDs), cfsqltype: "cf_sql_varchar", list: true }
|
|
}, { datasource: "payfrit" });
|
|
|
|
beacons = [];
|
|
for (row in qBeacons) {
|
|
arrayAppend(beacons, {
|
|
"UUID": row.UUID,
|
|
"BeaconID": row.ID,
|
|
"Name": row.Name,
|
|
"BusinessID": row.BusinessID,
|
|
"Name": row.Name,
|
|
"ServicePointID": row.ServicePointID,
|
|
"Name": row.Name,
|
|
"ParentBusinessID": val(row.ParentBusinessID),
|
|
"ParentName": row.ParentName ?: "",
|
|
"HasChildren": row.ChildCount > 0
|
|
});
|
|
}
|
|
|
|
response["OK"] = true;
|
|
response["BEACONS"] = beacons;
|
|
|
|
} catch (any e) {
|
|
response["ERROR"] = e.message;
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|