diff --git a/backend/migrations/054_ttlock_fix_api_server.sql b/backend/migrations/054_ttlock_fix_api_server.sql new file mode 100644 index 0000000..c81a423 --- /dev/null +++ b/backend/migrations/054_ttlock_fix_api_server.sql @@ -0,0 +1,12 @@ +-- Исправляем старые значения api_server: euopen.ttlock.com → euapi.ttlock.com +-- (euopen — это веб-портал разработчиков, а не API-сервер) +UPDATE hotel_ttlock_config +SET api_server = 'https://euapi.ttlock.com' +WHERE api_server = 'https://euopen.ttlock.com'; + +UPDATE hotel_ttlock_config +SET api_server = 'https://cnapi.ttlock.com' +WHERE api_server = 'https://open.ttlock.com'; + +ALTER TABLE hotel_ttlock_config + ALTER COLUMN api_server SET DEFAULT 'https://euapi.ttlock.com'; diff --git a/backend/src/routes/ttlock.ts b/backend/src/routes/ttlock.ts index ebcff79..8cf7505 100644 --- a/backend/src/routes/ttlock.ts +++ b/backend/src/routes/ttlock.ts @@ -51,14 +51,14 @@ const ttlockRoutes: FastifyPluginAsync = async (fastify) => { [hotelId], ) if (!rows[0]) { - return { isEnabled: false, clientId: '', cardSectors: '1,2,3,4,5,6,7,8,9,10', apiServer: 'https://euopen.ttlock.com' } + return { isEnabled: false, clientId: '', cardSectors: '1,2,3,4,5,6,7,8,9,10', apiServer: 'https://euapi.ttlock.com' } } const r = rows[0] return { isEnabled: r.is_enabled, clientId: r.client_id, cardSectors: r.card_sectors, - apiServer: r.api_server ?? 'https://euopen.ttlock.com', + apiServer: r.api_server ?? 'https://euapi.ttlock.com', } }) @@ -187,7 +187,7 @@ const ttlockRoutes: FastifyPluginAsync = async (fastify) => { type: 'ttlock:test_api', clientId: cfg.client_id, clientSecret: cfg.client_secret, - apiServer: cfg.api_server ?? 'https://euopen.ttlock.com', + apiServer: cfg.api_server ?? 'https://euapi.ttlock.com', }, 15_000) as { ok?: boolean; lockCount?: number; error?: string } if (!result.ok) return reply.code(502).send({ error: result.error ?? 'Ошибка API' }) @@ -394,7 +394,7 @@ const ttlockRoutes: FastifyPluginAsync = async (fastify) => { cardSectors: cfg.card_sectors, clientId: cfg.client_id, clientSecret: cfg.client_secret, - apiServer: cfg.api_server ?? 'https://euopen.ttlock.com', + apiServer: cfg.api_server ?? 'https://euapi.ttlock.com', startDate: checkIn, endDate: checkOut, }, 30_000) diff --git a/src/pages/TTLockPage.tsx b/src/pages/TTLockPage.tsx index e081047..c4f503f 100644 --- a/src/pages/TTLockPage.tsx +++ b/src/pages/TTLockPage.tsx @@ -143,7 +143,7 @@ export function TTLockPage() { const [clientId, setClientId] = useState('') const [clientSecret, setClientSecret] = useState('') const [cardSectors, setCardSectors] = useState('1,2,3,4,5,6,7,8,9,10') - const [apiServer, setApiServer] = useState('https://euopen.ttlock.com') + const [apiServer, setApiServer] = useState('https://euapi.ttlock.com') // Per-workstation COM port state const [wsComPorts, setWsComPorts] = useState>({}) @@ -243,7 +243,7 @@ export function TTLockPage() { setIsEnabled(cfg.isEnabled) setClientId(cfg.clientId) setCardSectors(cfg.cardSectors || '1,2,3,4,5,6,7,8,9,10') - setApiServer(cfg.apiServer || 'https://euopen.ttlock.com') + setApiServer(cfg.apiServer || 'https://euapi.ttlock.com') setMappings(maps) setRooms(roomList) setWorkstations(wsList) @@ -415,8 +415,8 @@ export function TTLockPage() {
{[ - { value: 'https://euopen.ttlock.com', label: 'EU', hint: 'euopen.ttlock.com' }, - { value: 'https://open.ttlock.com', label: 'China', hint: 'open.ttlock.com' }, + { value: 'https://euapi.ttlock.com', label: 'EU', hint: 'euapi.ttlock.com' }, + { value: 'https://cnapi.ttlock.com', label: 'China', hint: 'cnapi.ttlock.com' }, ].map(opt => (