Add pharmacy auto-registration and infrastructure improvements
- Auto-generate pharmacy_code (P001~P999) when creating new pharmacy - Add new pharmacy fields: owner info, institution code/type, API port - Change Headplane port mapping: 3000 → 3001 to avoid conflicts - Add code-server setup script for development environment - Add LXC Caddy setup documentation - Update .gitignore to exclude farmq-admin submodule 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -415,23 +415,53 @@ def create_app(config_name=None):
|
||||
# FARMQ 데이터베이스에 약국 생성
|
||||
farmq_session = get_farmq_session()
|
||||
try:
|
||||
# pharmacy_code 자동 생성 (P001~P999)
|
||||
last_pharmacy = farmq_session.query(PharmacyInfo)\
|
||||
.filter(PharmacyInfo.pharmacy_code.like('P%'))\
|
||||
.order_by(PharmacyInfo.pharmacy_code.desc())\
|
||||
.first()
|
||||
|
||||
if last_pharmacy and last_pharmacy.pharmacy_code:
|
||||
try:
|
||||
last_num = int(last_pharmacy.pharmacy_code[1:])
|
||||
new_num = last_num + 1
|
||||
except:
|
||||
new_num = 1
|
||||
else:
|
||||
new_num = 1
|
||||
|
||||
pharmacy_code = f"P{new_num:03d}" # P001, P002, ...
|
||||
|
||||
new_pharmacy = PharmacyInfo(
|
||||
pharmacy_code=pharmacy_code,
|
||||
pharmacy_name=pharmacy_name,
|
||||
business_number=data.get('business_number', '').strip(),
|
||||
manager_name=data.get('manager_name', '').strip(),
|
||||
phone=data.get('phone', '').strip(),
|
||||
address=data.get('address', '').strip(),
|
||||
|
||||
# 신규 필드
|
||||
owner_name=data.get('owner_name', '').strip(),
|
||||
owner_license=data.get('owner_license', '').strip(),
|
||||
owner_phone=data.get('owner_phone', '').strip(),
|
||||
owner_email=data.get('owner_email', '').strip(),
|
||||
institution_code=data.get('institution_code', '').strip() or None,
|
||||
institution_type=data.get('institution_type', '').strip() or None,
|
||||
api_port=data.get('api_port', 8082),
|
||||
|
||||
# 기존 필드
|
||||
proxmox_host=data.get('proxmox_host', '').strip(),
|
||||
headscale_user_name=data.get('headscale_user_name', '').strip(),
|
||||
status='active'
|
||||
)
|
||||
|
||||
|
||||
farmq_session.add(new_pharmacy)
|
||||
farmq_session.commit()
|
||||
|
||||
farmq_session.refresh(new_pharmacy)
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': f'약국 "{pharmacy_name}"가 성공적으로 생성되었습니다.',
|
||||
'message': f'약국 "{pharmacy_name}" (코드: {pharmacy_code}) 생성 완료',
|
||||
'pharmacy': new_pharmacy.to_dict()
|
||||
})
|
||||
|
||||
@@ -440,6 +470,8 @@ def create_app(config_name=None):
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ 약국 생성 오류: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': f'서버 오류: {str(e)}'
|
||||
|
||||
Reference in New Issue
Block a user