This commit is contained in:
admin
2026-01-17 11:08:57 +09:00
parent d8ec60629e
commit 6661c7ac89
10 changed files with 610 additions and 47 deletions

View File

@@ -8,7 +8,9 @@ router = APIRouter(prefix="/year-locks", tags=["年度锁定"])
def get_year_locks():
with get_connection() as conn, conn.cursor() as cur:
cur.execute("""
SELECT fiscal_year, is_locked, locked_at, locked_by
SELECT fiscal_year, is_locked,
(locked_at AT TIME ZONE 'UTC') AT TIME ZONE 'Asia/Tokyo' as locked_at,
locked_by
FROM year_locks
ORDER BY fiscal_year
""")
@@ -20,11 +22,11 @@ def lock_year(fiscal_year: int):
with get_connection() as conn, conn.cursor() as cur:
cur.execute("""
INSERT INTO year_locks (fiscal_year, is_locked, locked_at, locked_by)
VALUES (%s, true, NOW(), %s)
VALUES (%s, true, CURRENT_TIMESTAMP AT TIME ZONE 'Asia/Tokyo', %s)
ON CONFLICT (fiscal_year)
DO UPDATE
SET is_locked = true,
locked_at = NOW(),
locked_at = CURRENT_TIMESTAMP AT TIME ZONE 'Asia/Tokyo',
locked_by = EXCLUDED.locked_by
""", (fiscal_year, "system"))
conn.commit()