diff --git a/backend-node/src/controllers/buttonActionStandardController.ts b/backend-node/src/controllers/buttonActionStandardController.ts index fbab4d98..57831c77 100644 --- a/backend-node/src/controllers/buttonActionStandardController.ts +++ b/backend-node/src/controllers/buttonActionStandardController.ts @@ -1,6 +1,6 @@ import { Request, Response } from "express"; import { AuthenticatedRequest } from "../types/auth"; -import { query, queryOne, pool } from "../database/db"; +import { query, queryOne, transaction } from "../database/db"; export class ButtonActionStandardController { // 버튼 액션 목록 조회 @@ -363,26 +363,16 @@ export class ButtonActionStandardController { } // 트랜잭션으로 일괄 업데이트 - const client = await pool.connect(); - try { - await client.query("BEGIN"); - + await transaction(async (client) => { for (const item of buttonActions) { await client.query( `UPDATE button_action_standards - SET sort_order = $1, updated_by = $2, updated_date = $3 - WHERE action_type = $4`, - [item.sort_order, req.user?.userId || "system", new Date(), item.action_type] + SET sort_order = $1, updated_by = $2, updated_date = NOW() + WHERE action_type = $3`, + [item.sort_order, req.user?.userId || "system", item.action_type] ); } - - await client.query("COMMIT"); - } catch (error) { - await client.query("ROLLBACK"); - throw error; - } finally { - client.release(); - } + }); return res.json({ success: true,