feat: 도매상 설정 중앙 관리 시스템
- config/wholesalers.json: 도매상 정보 중앙 관리 (ID, 이름, 로고, 색상, API) - config/__init__.py: Python 헬퍼 (get_wholesalers, get_wholesaler) - wholesaler_config_api.py: /api/config/wholesalers 엔드포인트 - 백제약품 로고(favicon) 추가: logo_baekje.ico - 잔고 모달에 로고 표시 기능 추가
This commit is contained in:
54
backend/config/__init__.py
Normal file
54
backend/config/__init__.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
도매상 설정 중앙 관리
|
||||
|
||||
사용법:
|
||||
from config import get_wholesalers, get_wholesaler
|
||||
|
||||
# 전체 도매상 목록
|
||||
wholesalers = get_wholesalers()
|
||||
|
||||
# 특정 도매상 정보
|
||||
geo = get_wholesaler('geoyoung')
|
||||
print(geo['name']) # 지오영
|
||||
print(geo['logo']) # /static/img/logo_geoyoung.ico
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
_config = None
|
||||
_config_path = Path(__file__).parent / 'wholesalers.json'
|
||||
|
||||
|
||||
def _load_config():
|
||||
global _config
|
||||
if _config is None:
|
||||
with open(_config_path, 'r', encoding='utf-8') as f:
|
||||
_config = json.load(f)
|
||||
return _config
|
||||
|
||||
|
||||
def get_wholesalers():
|
||||
"""전체 도매상 목록 반환 (순서대로)"""
|
||||
config = _load_config()
|
||||
order = config.get('order', [])
|
||||
wholesalers = config.get('wholesalers', {})
|
||||
return [wholesalers[key] for key in order if key in wholesalers]
|
||||
|
||||
|
||||
def get_wholesaler(wholesaler_id: str):
|
||||
"""특정 도매상 정보 반환"""
|
||||
config = _load_config()
|
||||
return config.get('wholesalers', {}).get(wholesaler_id)
|
||||
|
||||
|
||||
def get_all_wholesalers_dict():
|
||||
"""전체 도매상 딕셔너리 반환"""
|
||||
config = _load_config()
|
||||
return config.get('wholesalers', {})
|
||||
|
||||
|
||||
def get_config():
|
||||
"""전체 설정 반환"""
|
||||
return _load_config()
|
||||
65
backend/config/wholesalers.json
Normal file
65
backend/config/wholesalers.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"wholesalers": {
|
||||
"geoyoung": {
|
||||
"id": "geoyoung",
|
||||
"name": "지오영",
|
||||
"shortName": "지오영",
|
||||
"icon": "🏭",
|
||||
"logo": "/static/img/logo_geoyoung.ico",
|
||||
"color": "#06b6d4",
|
||||
"gradient": "linear-gradient(135deg, #0891b2, #06b6d4)",
|
||||
"bgColor": "rgba(6, 182, 212, 0.1)",
|
||||
"api": {
|
||||
"balance": "/api/geoyoung/balance",
|
||||
"stock": "/api/geoyoung/stock",
|
||||
"order": "/api/geoyoung/order"
|
||||
},
|
||||
"env": {
|
||||
"userId": "GEOYOUNG_USER_ID",
|
||||
"password": "GEOYOUNG_PASSWORD"
|
||||
}
|
||||
},
|
||||
"sooin": {
|
||||
"id": "sooin",
|
||||
"name": "수인약품",
|
||||
"shortName": "수인",
|
||||
"icon": "💊",
|
||||
"logo": "/static/img/logo_sooin.svg",
|
||||
"color": "#a855f7",
|
||||
"gradient": "linear-gradient(135deg, #7c3aed, #a855f7)",
|
||||
"bgColor": "rgba(168, 85, 247, 0.1)",
|
||||
"api": {
|
||||
"balance": "/api/sooin/balance",
|
||||
"stock": "/api/sooin/stock",
|
||||
"order": "/api/sooin/order"
|
||||
},
|
||||
"env": {
|
||||
"userId": "SOOIN_USER_ID",
|
||||
"password": "SOOIN_PASSWORD",
|
||||
"vendorCode": "SOOIN_VENDOR_CODE"
|
||||
}
|
||||
},
|
||||
"baekje": {
|
||||
"id": "baekje",
|
||||
"name": "백제약품",
|
||||
"shortName": "백제",
|
||||
"icon": "💉",
|
||||
"logo": "/static/img/logo_baekje.ico",
|
||||
"color": "#f59e0b",
|
||||
"gradient": "linear-gradient(135deg, #d97706, #f59e0b)",
|
||||
"bgColor": "rgba(245, 158, 11, 0.1)",
|
||||
"api": {
|
||||
"balance": "/api/baekje/balance",
|
||||
"stock": "/api/baekje/stock",
|
||||
"order": "/api/baekje/order"
|
||||
},
|
||||
"env": {
|
||||
"userId": "BAEKJE_USER_ID",
|
||||
"password": "BAEKJE_PASSWORD"
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": ["baekje", "geoyoung", "sooin"],
|
||||
"version": "1.0.0",
|
||||
"lastUpdated": "2026-03-06"
|
||||
}
|
||||
Reference in New Issue
Block a user