- config/wholesalers.json: 도매상 정보 중앙 관리 (ID, 이름, 로고, 색상, API) - config/__init__.py: Python 헬퍼 (get_wholesalers, get_wholesaler) - wholesaler_config_api.py: /api/config/wholesalers 엔드포인트 - 백제약품 로고(favicon) 추가: logo_baekje.ico - 잔고 모달에 로고 표시 기능 추가
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
# -*- 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()
|