From 2cc9ec6bb14e813b58ba6ac89df0f2248ab4ef7d Mon Sep 17 00:00:00 2001 From: thug0bin Date: Thu, 12 Mar 2026 17:15:28 +0900 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=EA=B1=B4=EC=A1=B0=EC=8B=9C?= =?UTF-8?q?=EB=9F=BD=20=ED=99=98=EC=82=B0=EA=B3=84=EC=88=98=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /admin/drysyrup 페이지 구현 - GET /api/drug-info/drysyrup 전체 목록 API - DELETE /api/drug-info/drysyrup/ 삭제 API - 검색, CRUD, 통계 카드 기능 --- backend/app.py | 127 ++++ backend/templates/admin_drysyrup.html | 980 ++++++++++++++++++++++++++ 2 files changed, 1107 insertions(+) create mode 100644 backend/templates/admin_drysyrup.html diff --git a/backend/app.py b/backend/app.py index 85a7d1d..7c4d486 100644 --- a/backend/app.py +++ b/backend/app.py @@ -4145,6 +4145,133 @@ def api_drysyrup_update(sung_code): return jsonify({'success': False, 'error': str(e)}), 500 +@app.route('/api/drug-info/drysyrup', methods=['GET']) +def api_drysyrup_list(): + """ + 건조시럽 전체 목록 조회 API + + Query params: + q: 검색어 (성분명/제품명 검색) + + Returns: + { "success": true, "data": [...] } + """ + try: + session = db_manager.get_postgres_session() + if session is None: + return jsonify({ + 'success': False, + 'error': 'PostgreSQL 연결 실패', + 'data': [] + }) + + search_query = request.args.get('q', '').strip() + + if search_query: + query = text(""" + SELECT + idx, + ingredient_code, + ingredient_name, + product_name, + conversion_factor, + post_prep_amount, + main_ingredient_amt, + storage_conditions, + expiration_date + FROM drysyrup + WHERE + ingredient_name ILIKE :search + OR product_name ILIKE :search + OR ingredient_code ILIKE :search + ORDER BY ingredient_name, product_name + """) + rows = session.execute(query, {'search': f'%{search_query}%'}).fetchall() + else: + query = text(""" + SELECT + idx, + ingredient_code, + ingredient_name, + product_name, + conversion_factor, + post_prep_amount, + main_ingredient_amt, + storage_conditions, + expiration_date + FROM drysyrup + ORDER BY ingredient_name, product_name + """) + rows = session.execute(query).fetchall() + + data = [] + for row in rows: + data.append({ + 'idx': row[0], + 'sung_code': row[1], + 'ingredient_name': row[2], + 'product_name': row[3], + 'conversion_factor': float(row[4]) if row[4] is not None else None, + 'post_prep_amount': row[5], + 'main_ingredient_amt': row[6], + 'storage_conditions': row[7], + 'expiration_date': row[8] + }) + + return jsonify({ + 'success': True, + 'data': data, + 'count': len(data) + }) + + except Exception as e: + logging.error(f"건조시럽 목록 조회 오류: {e}") + return jsonify({ + 'success': False, + 'error': str(e), + 'data': [] + }), 500 + + +@app.route('/api/drug-info/drysyrup/', methods=['DELETE']) +def api_drysyrup_delete(sung_code): + """ + 건조시럽 삭제 API + """ + try: + session = db_manager.get_postgres_session() + if session is None: + return jsonify({'success': False, 'error': 'PostgreSQL 연결 실패'}), 500 + + # 존재 여부 확인 + check_query = text("SELECT 1 FROM drysyrup WHERE ingredient_code = :sung_code") + existing = session.execute(check_query, {'sung_code': sung_code}).fetchone() + + if not existing: + return jsonify({'success': False, 'error': '존재하지 않는 성분코드'}), 404 + + # 삭제 + delete_query = text("DELETE FROM drysyrup WHERE ingredient_code = :sung_code") + session.execute(delete_query, {'sung_code': sung_code}) + session.commit() + + return jsonify({'success': True, 'message': '삭제 완료'}) + + except Exception as e: + logging.error(f"건조시럽 삭제 오류 (SUNG_CODE={sung_code}): {e}") + try: + session.rollback() + except: + pass + return jsonify({'success': False, 'error': str(e)}), 500 + + +@app.route('/admin/drysyrup') +def admin_drysyrup(): + """건조시럽 환산계수 관리 페이지""" + return render_template('admin_drysyrup.html') + + # ==================== 입고이력 API ==================== @app.route('/api/drugs//purchase-history') diff --git a/backend/templates/admin_drysyrup.html b/backend/templates/admin_drysyrup.html new file mode 100644 index 0000000..1169780 --- /dev/null +++ b/backend/templates/admin_drysyrup.html @@ -0,0 +1,980 @@ + + + + + + 건조시럽 환산계수 관리 - 청춘약국 + + + + + + + +
+
+
+

💧 건조시럽 환산계수 관리

+

건조시럽 mL → g 환산계수 데이터 관리

+
+ +
+
+ + +
+ + + + +
+
+ + +
+ +
+ + +
+
+
-
+
전체 등록
+
+
+
-
+
냉장보관
+
+
+
-
+
실온보관
+
+
+ + +
+
+
+ 환산계수 목록 + 0건 +
+
+
+ + + + + + + + + + + + + + + + + +
성분코드성분명제품명환산계수보관조건유효기간관리
+
+
+

데이터 로딩 중...

+
+
+
+
+
+ + + + + + + + +
+ + + +