325 lines
15 KiB
Python
Executable File
325 lines
15 KiB
Python
Executable File
# /opt/docker/dev/service_finder/backend/app/scripts/seed_system_params.py
|
|
import asyncio
|
|
import logging
|
|
from sqlalchemy import select
|
|
from app.db.session import AsyncSessionLocal
|
|
from app.models.system import SystemParameter
|
|
|
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s]: %(message)s')
|
|
logger = logging.getLogger("Seed-System-Params-2.0")
|
|
|
|
async def seed_params():
|
|
async with AsyncSessionLocal() as db:
|
|
|
|
# ----------------------------------------------------------------------
|
|
# GONDOLATMENET A STRUKTÚRÁHOZ:
|
|
# Ez a lista tartalmazza a rendszer összes "alapértelmezett" (global) beállítását.
|
|
# Minden modul innen kapja meg az indulási értékeit. Ha az admin felületen
|
|
# egy értéket módosítanak, ez a script a következő futáskor NEM írja felül azt,
|
|
# csak a leírásokat (description) és a kategóriákat frissíti.
|
|
# ----------------------------------------------------------------------
|
|
|
|
params = [
|
|
# --- 1. KOMMUNIKÁCIÓ (Az EmailManager 2.0 motorja) ---
|
|
{
|
|
"key": "email_provider",
|
|
"value": "smtp", # Lehetőségek: "smtp", "sendgrid", "disabled"
|
|
"category": "communication",
|
|
"description": "Aktív e-mail küldő szolgáltató",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "emails_from_email",
|
|
"value": "noreply@profibot.hu",
|
|
"category": "communication",
|
|
"description": "A rendszer által küldött levelek feladó címe",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "emails_from_name",
|
|
"value": "Sentinel Master",
|
|
"category": "communication",
|
|
"description": "A rendszer által küldött levelek feladó neve",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "sendgrid_api_key",
|
|
"value": "",
|
|
"category": "communication",
|
|
"description": "SendGrid API kulcs (ha a provider 'sendgrid')",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "smtp_config",
|
|
"value": {
|
|
"host": "localhost",
|
|
"port": 587,
|
|
"user": "smtp_user",
|
|
"pass": "smtp_password",
|
|
"tls": True
|
|
},
|
|
"category": "communication",
|
|
"description": "SMTP szerver konfiguráció JSON formátumban",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 2. AUTH & SECURITY (Kapuőr modul) ---
|
|
{"key": "auth_min_password_length", "value": 8, "category": "security", "description": "Minimum jelszóhossz", "scope_level": "global"},
|
|
{"key": "auth_default_role", "value": "user", "category": "auth", "description": "Új regisztrálók alapértelmezett rangja", "scope_level": "global"},
|
|
{"key": "auth_registration_hours", "value": 48, "category": "auth", "description": "Regisztrációs link érvényessége", "scope_level": "global"},
|
|
{"key": "auth_password_reset_hours", "value": 2, "category": "security", "description": "Jelszóvisszaállító link érvényessége", "scope_level": "global"},
|
|
{"key": "asset_auto_transfer_enabled", "value": False, "category": "security", "description": "Autonóm tulajdonosváltás engedélyezése", "scope_level": "global"},
|
|
|
|
# --- 3. LIMITS & CSOMAGOK (A Billing és Asset korlátok) ---
|
|
{
|
|
"key": "VEHICLE_LIMIT",
|
|
"value": {"free": 1, "premium": 5, "vip": 50, "service_pro": 10},
|
|
"category": "limits",
|
|
"description": "Járműszám korlátok előfizetés szerint",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "subscription_packages_matrix",
|
|
"value": {
|
|
"free": {"price": 0, "rank": 1, "type": "credit"},
|
|
"premium": {"price": 1990, "rank": 5, "type": "credit"},
|
|
"vip": {"price": 4990, "rank": 50, "type": "credit"},
|
|
"service_pro": {"price": 9990, "rank": 30, "type": "coin", "initial_coin_bonus": 500}
|
|
},
|
|
"category": "billing",
|
|
"description": "Csomagok, árak és bónuszok központi mátrixa",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 4. FINANCE (Költségek és Devizák) ---
|
|
{"key": "finance_default_currency", "value": "HUF", "category": "finance", "description": "Helyi alap deviza", "scope_level": "global"},
|
|
{"key": "finance_base_currency", "value": "EUR", "category": "finance", "description": "Központi elszámoló deviza (Statisztikákhoz)", "scope_level": "global"},
|
|
{"key": "org_naming_template", "value": "{last_name} Flotta", "category": "system", "description": "Szervezet név sablon", "scope_level": "global"},
|
|
|
|
# --- 5. DOCUMENT & OCR (Robot 1 vezérlése) ---
|
|
{
|
|
"key": "ocr_monthly_limit",
|
|
"value": {"free": 1, "premium": 10, "vip": 100},
|
|
"category": "limits",
|
|
"description": "Havi ingyenes OCR szkennelések száma",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "ocr_auto_trigger_types",
|
|
"value": ["invoice", "registration_card", "sale_contract"],
|
|
"category": "robots",
|
|
"description": "Azonnali OCR feldolgozásra kijelölt típusok",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 6. GAMIFICATION (A Játékmester) ---
|
|
{"key": "gamification_kyc_bonus", "value": 500, "category": "gamification", "description": "XP jutalom a KYC után", "scope_level": "global"},
|
|
{"key": "xp_multiplier_ocr_cost", "value": 1.5, "category": "gamification", "description": "Bónusz szorzó digitális (OCR) adatrögzítésre", "scope_level": "global"},
|
|
{
|
|
"key": "GAMIFICATION_MASTER_CONFIG",
|
|
"value": {
|
|
"xp_logic": {"base_xp": 500, "exponent": 1.5},
|
|
"penalty_logic": {
|
|
"recovery_rate": 0.5,
|
|
"thresholds": {"level_1": 100, "level_2": 500, "level_3": 1000},
|
|
"multipliers": {"L0": 1.0, "L1": 0.5, "L2": 0.1, "L3": 0.0}
|
|
},
|
|
"conversion_logic": {"social_to_credit_rate": 100},
|
|
"level_rewards": {"credits_per_10_levels": 50}
|
|
},
|
|
"category": "gamification",
|
|
"description": "Szintek, büntetések és jutalmak mátrixa",
|
|
"scope_level": "global"
|
|
},
|
|
# --- 6.1 GAMIFICATION 2.0 (Seasonal Competitions & Self-Defense) ---
|
|
{
|
|
"key": "service_trust_threshold",
|
|
"value": 70,
|
|
"category": "gamification",
|
|
"description": "Minimum trust score a szerviz publikálásához (0-100)",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "service_submission_rewards",
|
|
"value": {
|
|
"points": 50,
|
|
"xp": 100,
|
|
"social_credits": 10
|
|
},
|
|
"category": "gamification",
|
|
"description": "Jutalmak sikeres szerviz beküldésért",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "seasonal_competition_config",
|
|
"value": {
|
|
"season_duration_days": 90,
|
|
"top_contributors_count": 10,
|
|
"rewards": {
|
|
"first_place": {"credits": 1000, "badge": "season_champion"},
|
|
"second_place": {"credits": 500, "badge": "season_runner_up"},
|
|
"third_place": {"credits": 250, "badge": "season_bronze"},
|
|
"top_10": {"credits": 100, "badge": "season_elite"}
|
|
}
|
|
},
|
|
"category": "gamification",
|
|
"description": "Szezonális verseny beállítások",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "self_defense_penalties",
|
|
"value": {
|
|
"level_minus_1": {
|
|
"name": "Figyelmeztetés",
|
|
"restrictions": ["no_service_submissions", "reduced_search_priority"],
|
|
"duration_days": 7,
|
|
"recovery_xp": 500
|
|
},
|
|
"level_minus_2": {
|
|
"name": "Felfüggesztés",
|
|
"restrictions": ["no_service_submissions", "no_reviews", "no_messaging", "reduced_search_priority"],
|
|
"duration_days": 30,
|
|
"recovery_xp": 2000
|
|
},
|
|
"level_minus_3": {
|
|
"name": "Kitiltás",
|
|
"restrictions": ["no_service_submissions", "no_reviews", "no_messaging", "no_search", "account_frozen"],
|
|
"duration_days": 365,
|
|
"recovery_xp": 10000
|
|
}
|
|
},
|
|
"category": "gamification",
|
|
"description": "Önvédelmi rendszer büntetési szintek",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "contribution_types_config",
|
|
"value": {
|
|
"service_submission": {"points": 50, "xp": 100, "weight": 1.0},
|
|
"verified_review": {"points": 30, "xp": 50, "weight": 0.8},
|
|
"expertise_tagging": {"points": 20, "xp": 30, "weight": 0.6},
|
|
"data_validation": {"points": 15, "xp": 25, "weight": 0.5},
|
|
"community_moderation": {"points": 40, "xp": 75, "weight": 0.9}
|
|
},
|
|
"category": "gamification",
|
|
"description": "Hozzájárulási típusok és pontozási súlyok",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 7. ÉRTESÍTÉSEK ÉS KARBANTARTÁS ---
|
|
{
|
|
"key": "notif_expiry_threshold_days",
|
|
"value": 30,
|
|
"category": "notifications",
|
|
"description": "Hány nappal az okmányok lejárata előtt küldjön a rendszer automata figyelmeztetést?",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "notif_expiry_steps",
|
|
"value": [30, 7, 1, 0],
|
|
"category": "notifications",
|
|
"description": "Hány nappal a lejárat előtt küldjön a rendszer riasztást? (Lista formátum)",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "maint_km_alert_threshold",
|
|
"value": 1000,
|
|
"category": "maintenance",
|
|
"description": "Hány kilométerrel a tervezett szerviz előtt küldjön figyelmeztetést a rendszer?",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "storage_retention_days",
|
|
"value": 365,
|
|
"category": "storage",
|
|
"description": "Fájlok megőrzési ideje a NAS-on (napokban)",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "storage_delete_after_validation",
|
|
"value": False,
|
|
"category": "storage",
|
|
"description": "Törölje-e a rendszer az OCR bizonyítékokat a sikeres hitelesítés után?",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 8. GEO & LOCALIZATION ---
|
|
{
|
|
"key": "geo_default_country_code",
|
|
"value": "HU",
|
|
"category": "geo",
|
|
"description": "Alapértelmezett országkód a címek normalizálásához",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "GEO_ADDRESS_FORMAT_TEMPLATE",
|
|
"value": "{zip} {city}, {street} {type} {number}.",
|
|
"category": "geo",
|
|
"description": "Címformázási sablon (Python string format)",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "GEO_SUGGESTION_LIMIT",
|
|
"value": 15,
|
|
"category": "geo",
|
|
"description": "Hány találatot adjon vissza az utca-kiegészítő?",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 9. ÉRTESÍTÉSI MÁTRIXOK (A granuláris szabályozáshoz) ---
|
|
{
|
|
"key": "notification_categories_config",
|
|
"value": {
|
|
"insurance": {"mandatory": True, "channels": ["email", "internal"], "label": "Biztosítás lejárat"},
|
|
"mot_expiry": {"mandatory": True, "channels": ["email", "internal"], "label": "Műszaki vizsga"},
|
|
"personal_id": {"mandatory": True, "channels": ["email", "internal"], "label": "Személyi okmányok"},
|
|
"service_due": {"mandatory": False, "channels": ["internal"], "label": "Karbantartási emlékeztető"},
|
|
"system_alert": {"mandatory": True, "channels": ["email", "internal"], "label": "Rendszerüzenetek"}
|
|
},
|
|
"category": "notifications",
|
|
"description": "Értesítési típusok és biztonsági szintek mátrixa",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "NOTIFICATION_TYPE_MATRIX",
|
|
"value": {
|
|
"insurance": [45, 30, 15, 7, 1, 0], # A kötelező biztosítás kiemelt kezelése!
|
|
"mot": [30, 14, 7, 1, 0],
|
|
"personal_id": [60, 30, 15, 0],
|
|
"default": [30, 7, 1]
|
|
},
|
|
"category": "notifications",
|
|
"description": "Dokumentum alapú riasztási naptár mátrix",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 10. FLEET & TELEMETRY ---
|
|
{
|
|
"key": "FLEET_EVENT_REWARDS",
|
|
"value": {
|
|
"refuel": {"xp": 30, "social": 5}, # Tankolás rögzítése
|
|
"service": {"xp": 150, "social": 30}, # Szerviz látogatás (értékesebb adat!)
|
|
"repair": {"xp": 100, "social": 20}, # Javítás
|
|
"tire_change": {"xp": 40, "social": 5}, # Gumicsere
|
|
"accident": {"xp": 10, "social": 0}, # Baleset
|
|
"default": {"xp": 20, "social": 2}
|
|
},
|
|
"category": "fleet",
|
|
"description": "Eseményenkénti gamifikációs jutalom mátrix",
|
|
"scope_level": "global"
|
|
},
|
|
{
|
|
"key": "FLEET_ANOMALY_LOGIC",
|
|
"value": {
|
|
"odometer_drop_severity": "critical",
|
|
"excessive_daily_km": 1500,
|
|
"flag_unverified_providers": True
|
|
},
|
|
"category": "fleet",
|
|
"description": "Flotta anomália detekciós küszöbértékek",
|
|
"scope_level": "global"
|
|
},
|
|
|
|
# --- 11. KÜLSŐ API-K (DVLA, UK) ---
|
|
{
|
|
"key": "dvla_api_en |