중간저장
This commit is contained in:
parent
68d9ba9ae7
commit
c6b154c322
23
config.ini
23
config.ini
|
|
@ -0,0 +1,23 @@
|
|||
[사업자1]
|
||||
name = 김땡땡
|
||||
number = 423
|
||||
phone = 010-5555-6666
|
||||
address = 부산시 연제구 땡떙땡
|
||||
card = 국민카드 ㅇㅇㅇㅇ
|
||||
|
||||
[사업자1_coupang]
|
||||
api_key = 5654-9821ㄹ--165ㅇㄹ-98546ㄹ16
|
||||
|
||||
[사업자1_gmarket]
|
||||
api_key = 지마켓 API 키
|
||||
|
||||
[사업자 1]
|
||||
name = 김ㅌ떄이ㅏㅓ
|
||||
number = ㅈ32423`
|
||||
phone = 5523
|
||||
address =
|
||||
card =
|
||||
|
||||
[사업자 1_coupang]
|
||||
api_key = ㄷ421-6564-854321
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
from PyQt5.QtWidgets import QMainWindow, QTabWidget, QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QApplication, QMessageBox
|
||||
import logging
|
||||
from playwright_handler import login_and_update_api_keys
|
||||
from src.config_handler import *
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -31,3 +32,15 @@ class MainWindow(QMainWindow):
|
|||
|
||||
def applyMarketSettings(self):
|
||||
QMessageBox.information(self, "성공", "마켓 설정이 성공적으로 변경되었습니다.")
|
||||
|
||||
def loadConfig(self):
|
||||
config = load_config()
|
||||
for i in range(self.tabWidget.count()):
|
||||
tab = self.tabWidget.widget(i)
|
||||
business_number = f"사업자{i+1}"
|
||||
business_info = get_business_info(config, business_number)
|
||||
tab.businessNameInput.setText(business_info.get('name', ''))
|
||||
tab.businessNumberInput.setText(business_info.get('number', ''))
|
||||
tab.businessPhoneInput.setText(business_info.get('phone', ''))
|
||||
tab.businessAddressInput.setText(business_info.get('address', ''))
|
||||
tab.connectedCardInput.setText(business_info.get('card', ''))
|
||||
56
main.py
56
main.py
|
|
@ -1,11 +1,55 @@
|
|||
from PyQt5.QtWidgets import QApplication
|
||||
from configurator import MainWindow
|
||||
from log_config import setup_logging
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QTabWidget, QMenuBar, QAction, QFileDialog, QMessageBox
|
||||
import sys
|
||||
from src.log_config import setup_logging
|
||||
|
||||
from src.market_config_widget import MarketConfigWidget
|
||||
from src.config_handler import *
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
setup_logging()
|
||||
self.setWindowTitle("Market API Configurator")
|
||||
self.setGeometry(100, 100, 600, 900)
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
self.tabWidget = QTabWidget(self)
|
||||
self.setCentralWidget(self.tabWidget)
|
||||
|
||||
# 메뉴바 및 설정 불러오기 액션 추가
|
||||
menuBar = QMenuBar(self)
|
||||
self.setMenuBar(menuBar)
|
||||
fileMenu = menuBar.addMenu("&File")
|
||||
loadAction = QAction("설정 불러오기", self)
|
||||
loadAction.triggered.connect(self.loadConfig)
|
||||
fileMenu.addAction(loadAction)
|
||||
|
||||
# 사업자 탭 생성
|
||||
for i in range(1, 6):
|
||||
tab = MarketConfigWidget(f"사업자{i}", self)
|
||||
self.tabWidget.addTab(tab, f"사업자{i}")
|
||||
|
||||
def loadConfig(self):
|
||||
options = QFileDialog.Options()
|
||||
fileName, _ = QFileDialog.getOpenFileName(self, "설정 파일 불러오기", "",
|
||||
"INI Files (*.ini);;All Files (*)", options=options)
|
||||
if fileName:
|
||||
try:
|
||||
config = load_config(fileName)
|
||||
for i in range(self.tabWidget.count()):
|
||||
tab = self.tabWidget.widget(i)
|
||||
business_number = f"사업자{i+1}"
|
||||
if business_number in config:
|
||||
tab.loadBusinessInfo(config[business_number])
|
||||
tab.loadMarketInfo(config) # MarketConfigWidget에 해당 메소드 구현 필요
|
||||
else:
|
||||
QMessageBox.warning(self, "경고", f"{business_number} 정보가 파일에 없습니다.")
|
||||
except Exception as e:
|
||||
QMessageBox.critical(self, "오류", f"설정 파일을 불러오는 중 오류가 발생했습니다: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_logging()
|
||||
app = QApplication(sys.argv)
|
||||
mainWindow = MainWindow()
|
||||
mainWindow.show()
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QFormLayout, QMessageBox
|
||||
from src.config_handler import *
|
||||
class BusinessInfoWidget(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.layout = QVBoxLayout(self)
|
||||
|
||||
# 사업자 정보 입력 필드
|
||||
self.businessInfoLayout = QFormLayout()
|
||||
self.businessNameInput = QLineEdit(self)
|
||||
self.businessNumberInput = QLineEdit(self)
|
||||
self.businessPhoneInput = QLineEdit(self)
|
||||
self.businessAddressInput = QLineEdit(self)
|
||||
self.connectedCardInput = QLineEdit(self)
|
||||
|
||||
self.businessInfoLayout.addRow(QLabel('사업자 이름:'), self.businessNameInput)
|
||||
self.businessInfoLayout.addRow(QLabel('사업자 번호:'), self.businessNumberInput)
|
||||
self.businessInfoLayout.addRow(QLabel('사업자 전화번호:'), self.businessPhoneInput)
|
||||
self.businessInfoLayout.addRow(QLabel('사업장 주소:'), self.businessAddressInput)
|
||||
self.businessInfoLayout.addRow(QLabel('연결된 카드:'), self.connectedCardInput)
|
||||
|
||||
self.layout.addLayout(self.businessInfoLayout)
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import configparser
|
||||
|
||||
def load_config(file_path="config.ini"):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(file_path, encoding='utf-8') # utf-8 인코딩으로 읽기
|
||||
return config
|
||||
|
||||
def save_config(config, file_path="config.ini"):
|
||||
with open(file_path, 'w', encoding='utf-8') as configfile: # utf-8 인코딩으로 쓰기
|
||||
config.write(configfile)
|
||||
|
||||
def get_business_info(config, business_number):
|
||||
return dict(config[business_number])
|
||||
|
||||
def get_market_info(config, business_number, market):
|
||||
return dict(config[f"{business_number}_{market}"])
|
||||
|
|
@ -6,7 +6,7 @@ def setup_logging():
|
|||
logger.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
|
||||
file_handler = logging.FileHandler('app.log')
|
||||
file_handler = logging.FileHandler('app.log', encoding='utf-8')
|
||||
file_handler.setLevel(logging.INFO)
|
||||
file_handler.setFormatter(formatter)
|
||||
logger.addHandler(file_handler)
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QFormLayout, QMessageBox, QGroupBox, QHBoxLayout
|
||||
from src.business_info_widget import BusinessInfoWidget # 사업자 정보 위젯 import
|
||||
from src.config_handler import *
|
||||
|
||||
class MarketConfigWidget(QWidget):
|
||||
def __init__(self, business_number, parent=None):
|
||||
super().__init__(parent)
|
||||
self.business_number = business_number
|
||||
self.layout = QVBoxLayout(self)
|
||||
|
||||
self.businessInfoWidget = BusinessInfoWidget(self)
|
||||
self.layout.addWidget(self.createGroupBox('사업자 정보', self.businessInfoWidget))
|
||||
|
||||
# 마켓 설정 필드 예시
|
||||
self.coupangLayout = QFormLayout()
|
||||
self.coupangApiKeyInput = QLineEdit(self)
|
||||
self.coupangLayout.addRow(QLabel('쿠팡 API Key:'), self.coupangApiKeyInput)
|
||||
self.layout.addLayout(self.coupangLayout)
|
||||
|
||||
# 마켓 설정 적용 버튼
|
||||
self.applyMarketSettingsBtn = QPushButton('마켓 설정 적용', self)
|
||||
self.applyMarketSettingsBtn.clicked.connect(self.applyMarketSettings)
|
||||
self.layout.addWidget(self.applyMarketSettingsBtn)
|
||||
|
||||
# "사업자 변경 실행" 버튼 추가
|
||||
self.executeChangeBtn = QPushButton('사업자 변경 실행', self)
|
||||
self.executeChangeBtn.clicked.connect(self.executeChange)
|
||||
self.layout.addWidget(self.executeChangeBtn)
|
||||
|
||||
def createGroupBox(self, title, widget):
|
||||
groupBox = QGroupBox(title)
|
||||
layout = QHBoxLayout()
|
||||
layout.addWidget(widget)
|
||||
groupBox.setLayout(layout)
|
||||
return groupBox
|
||||
|
||||
def applyMarketSettings(self):
|
||||
config = load_config()
|
||||
business_number = self.business_number # 예: "사업자1"
|
||||
|
||||
# 사업자 정보 저장
|
||||
config[business_number] = {
|
||||
'name': self.businessInfoWidget.businessNameInput.text(),
|
||||
'number': self.businessInfoWidget.businessNumberInput.text(),
|
||||
'phone': self.businessInfoWidget.businessPhoneInput.text(),
|
||||
'address': self.businessInfoWidget.businessAddressInput.text(),
|
||||
'card': self.businessInfoWidget.connectedCardInput.text()
|
||||
}
|
||||
|
||||
# 마켓 설정 저장 (쿠팡 예시)
|
||||
market_key = f"{business_number}_coupang"
|
||||
config[market_key] = {
|
||||
'api_key': self.coupangApiKeyInput.text()
|
||||
}
|
||||
|
||||
# 추가 마켓 설정 저장 필요 시 여기에 구현...
|
||||
|
||||
# 변경된 설정을 파일에 저장
|
||||
save_config(config)
|
||||
|
||||
QMessageBox.information(self, "성공", "설정이 성공적으로 적용되었습니다.")
|
||||
Loading…
Reference in New Issue