From 2a3382084d881466090dbd6ed1fb0d7dde08820c Mon Sep 17 00:00:00 2001 From: aweso Date: Tue, 13 Jan 2026 21:26:49 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B0=94=EB=A1=9C=EB=B9=8C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- barobill_registration/api.php | 125 ++++++++ barobill_registration/index.php | 487 +++++++++++++++--------------- barobill_registration/init_db.php | 12 + 3 files changed, 376 insertions(+), 248 deletions(-) create mode 100644 barobill_registration/api.php create mode 100644 barobill_registration/init_db.php diff --git a/barobill_registration/api.php b/barobill_registration/api.php new file mode 100644 index 0000000..90aa0fe --- /dev/null +++ b/barobill_registration/api.php @@ -0,0 +1,125 @@ + 'Method not allowed']); + break; +} + +function handleGet($pdo) { + if (isset($_GET['id'])) { + $stmt = $pdo->prepare("SELECT * FROM barobill_members WHERE id = ?"); + $stmt->execute([$_GET['id']]); + echo json_encode($stmt->fetch(PDO::FETCH_ASSOC)); + } else { + $stmt = $pdo->query("SELECT * FROM barobill_members ORDER BY created_at DESC"); + echo json_encode(['members' => $stmt->fetchAll(PDO::FETCH_ASSOC)]); + } +} + +function handlePost($pdo) { + $data = json_decode(file_get_contents('php://input'), true); + + // Simple duplicate check + $check = $pdo->prepare("SELECT id FROM barobill_members WHERE biz_no = ?"); + $check->execute([$data['bizNo']]); + if ($check->fetch()) { + http_response_code(400); + echo json_encode(['error' => 'Business number already registered.']); + return; + } + + try { + $stmt = $pdo->prepare("INSERT INTO barobill_members + (biz_no, corp_name, ceo_name, addr, biz_type, biz_class, barobill_id, barobill_pwd, manager_name, manager_email, manager_hp) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + $stmt->execute([ + $data['bizNo'], + $data['corpName'], + $data['ceoName'], + $data['addr'], + $data['bizType'], + $data['bizClass'], + $data['id'], + password_hash($data['pwd'], PASSWORD_DEFAULT), // Note: In real API, pwd might not be stored like this or handled by Barobill + $data['managerName'], + $data['managerEmail'], + $data['managerHP'] + ]); + + echo json_encode(['success' => true, 'id' => $pdo->lastInsertId()]); + } catch (Exception $e) { + http_response_code(500); + echo json_encode(['error' => $e->getMessage()]); + } +} + +function handlePut($pdo) { + $data = json_decode(file_get_contents('php://input'), true); + if (!isset($data['id'])) { + http_response_code(400); + echo json_encode(['error' => 'Missing member ID']); + return; + } + + try { + $stmt = $pdo->prepare("UPDATE barobill_members SET + corp_name = ?, ceo_name = ?, addr = ?, biz_type = ?, biz_class = ?, + manager_name = ?, manager_email = ?, manager_hp = ? + WHERE id = ?"); + + $stmt->execute([ + $data['corpName'], + $data['ceoName'], + $data['addr'], + $data['bizType'], + $data['bizClass'], + $data['managerName'], + $data['managerEmail'], + $data['managerHP'], + $data['id'] + ]); + + echo json_encode(['success' => true]); + } catch (Exception $e) { + http_response_code(500); + echo json_encode(['error' => $e->getMessage()]); + } +} + +function handleDelete($pdo) { + $id = $_GET['id'] ?? null; + if (!$id) { + http_response_code(400); + echo json_encode(['error' => 'Missing member ID']); + return; + } + + try { + $stmt = $pdo->prepare("DELETE FROM barobill_members WHERE id = ?"); + $stmt->execute([$id]); + echo json_encode(['success' => true]); + } catch (Exception $e) { + http_response_code(500); + echo json_encode(['error' => $e->getMessage()]); + } +} +?> diff --git a/barobill_registration/index.php b/barobill_registration/index.php index 8d2f67e..17e522a 100644 --- a/barobill_registration/index.php +++ b/barobill_registration/index.php @@ -14,19 +14,12 @@ tailwind.config = { theme: { extend: { - fontFamily: { - sans: ['Pretendard', 'sans-serif'], - }, + fontFamily: { sans: ['Pretendard', 'sans-serif'] }, colors: { background: 'rgb(250, 250, 250)', - primary: { - DEFAULT: '#2563eb', - foreground: '#ffffff', - }, + primary: { DEFAULT: '#2563eb', foreground: '#ffffff' }, }, - borderRadius: { - 'card': '12px', - } + borderRadius: { 'card': '12px' } } } } @@ -35,14 +28,10 @@ - - - - - +