feat(robot): hunter v2.7, geocoding support, docker network fix, changelog update
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/app/models/__pycache__/service.cpython-312.pyc
Normal file
BIN
backend/app/models/__pycache__/service.cpython-312.pyc
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
import uuid
|
||||
from sqlalchemy import Column, String, Integer, ForeignKey, Text, DateTime
|
||||
from sqlalchemy import Column, String, Integer, ForeignKey, Text, DateTime, Float
|
||||
from sqlalchemy.dialects.postgresql import UUID as PG_UUID
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base_class import Base
|
||||
@@ -7,7 +7,6 @@ from app.db.base_class import Base
|
||||
class GeoPostalCode(Base):
|
||||
__tablename__ = "geo_postal_codes"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
country_code = Column(String(5), default="HU")
|
||||
zip_code = Column(String(10), nullable=False)
|
||||
@@ -16,7 +15,6 @@ class GeoPostalCode(Base):
|
||||
class GeoStreet(Base):
|
||||
__tablename__ = "geo_streets"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
postal_code_id = Column(Integer, ForeignKey("data.geo_postal_codes.id"))
|
||||
name = Column(String(200), nullable=False)
|
||||
@@ -24,11 +22,11 @@ class GeoStreet(Base):
|
||||
class GeoStreetType(Base):
|
||||
__tablename__ = "geo_street_types"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String(50), unique=True, nullable=False)
|
||||
|
||||
class Address(Base):
|
||||
"""Univerzális cím entitás GPS adatokkal kiegészítve."""
|
||||
__tablename__ = "addresses"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
@@ -40,6 +38,11 @@ class Address(Base):
|
||||
stairwell = Column(String(20))
|
||||
floor = Column(String(20))
|
||||
door = Column(String(20))
|
||||
parcel_id = Column(String(50)) # HRSZ
|
||||
parcel_id = Column(String(50))
|
||||
full_address_text = Column(Text)
|
||||
|
||||
# Robot és térképes funkciók számára
|
||||
latitude = Column(Float)
|
||||
longitude = Column(Float)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
@@ -1,54 +1,55 @@
|
||||
import uuid
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON, Numeric, text, Text
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, Numeric, text, Text, UniqueConstraint
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.dialects.postgresql import UUID as PG_UUID
|
||||
from sqlalchemy.dialects.postgresql import UUID as PG_UUID, JSONB
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base_class import Base
|
||||
|
||||
class AssetCatalog(Base):
|
||||
"""Globális járműkatalógus (Márka -> Típus -> Generáció -> Motor)."""
|
||||
__tablename__ = "vehicle_catalog"
|
||||
__table_args__ = {"schema": "data"}
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
'make', 'model', 'year_from', 'engine_variant', 'fuel_type',
|
||||
name='uix_vehicle_catalog_full'
|
||||
),
|
||||
{"schema": "data"}
|
||||
)
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
make = Column(String, index=True, nullable=False) # 1. Szint: Audi
|
||||
model = Column(String, index=True, nullable=False) # 2. Szint: A4
|
||||
generation = Column(String, index=True) # 3. Szint: B8 (2008-2015)
|
||||
engine_variant = Column(String) # 4. Szint: 2.0 TDI (150 LE)
|
||||
|
||||
make = Column(String, index=True, nullable=False)
|
||||
model = Column(String, index=True, nullable=False)
|
||||
generation = Column(String, index=True)
|
||||
engine_variant = Column(String, index=True)
|
||||
year_from = Column(Integer)
|
||||
year_to = Column(Integer)
|
||||
vehicle_class = Column(String)
|
||||
fuel_type = Column(String)
|
||||
fuel_type = Column(String, index=True)
|
||||
engine_code = Column(String)
|
||||
factory_data = Column(JSON, server_default=text("'{}'::jsonb")) # Technikai specifikációk
|
||||
factory_data = Column(JSONB, server_default=text("'{}'::jsonb"))
|
||||
|
||||
assets = relationship("Asset", back_populates="catalog")
|
||||
|
||||
class Asset(Base):
|
||||
"""Egyedi jármű (Asset) példány - Az ökoszisztéma magja."""
|
||||
__tablename__ = "assets"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(PG_UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
vin = Column(String(17), unique=True, index=True, nullable=False)
|
||||
license_plate = Column(String(20), index=True)
|
||||
name = Column(String)
|
||||
year_of_manufacture = Column(Integer)
|
||||
|
||||
# --- BIZTONSÁGI ÉS JOGOSULTSÁGI IZOLÁCIÓ ---
|
||||
# A current_organization_id biztosítja a gyors, adatbázis-szintű Scoped RBAC védelmet.
|
||||
current_organization_id = Column(Integer, ForeignKey("data.organizations.id"), nullable=True)
|
||||
|
||||
catalog_id = Column(Integer, ForeignKey("data.vehicle_catalog.id"))
|
||||
is_verified = Column(Boolean, default=False)
|
||||
verification_method = Column(String(20)) # 'robot', 'ocr', 'manual'
|
||||
status = Column(String(20), default="active")
|
||||
|
||||
# Moderációs mezők a Robot 3 (OCR) számára
|
||||
is_verified = Column(Boolean, default=False)
|
||||
verification_method = Column(String(20)) # 'manual', 'ocr', 'vin_api'
|
||||
verification_notes = Column(Text, nullable=True) # Eltérések jegyzőkönyve
|
||||
catalog_match_score = Column(Numeric(5, 2), nullable=True) # 0-100% egyezési arány
|
||||
|
||||
status = Column(String(20), default="active")
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
# Kapcsolatok (Digital Twin Modules)
|
||||
catalog = relationship("AssetCatalog", back_populates="assets")
|
||||
current_org = relationship("Organization")
|
||||
financials = relationship("AssetFinancials", back_populates="asset", uselist=False)
|
||||
@@ -57,6 +58,7 @@ class Asset(Base):
|
||||
events = relationship("AssetEvent", back_populates="asset")
|
||||
costs = relationship("AssetCost", back_populates="asset")
|
||||
reviews = relationship("AssetReview", back_populates="asset")
|
||||
ownership_history = relationship("VehicleOwnership", back_populates="vehicle")
|
||||
|
||||
class AssetFinancials(Base):
|
||||
__tablename__ = "asset_financials"
|
||||
@@ -87,15 +89,13 @@ class AssetReview(Base):
|
||||
asset_id = Column(PG_UUID(as_uuid=True), ForeignKey("data.assets.id"), nullable=False)
|
||||
user_id = Column(Integer, ForeignKey("data.users.id"), nullable=False)
|
||||
overall_rating = Column(Integer)
|
||||
criteria_scores = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
criteria_scores = Column(JSONB, server_default=text("'{}'::jsonb"))
|
||||
comment = Column(Text)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
asset = relationship("Asset", back_populates="reviews")
|
||||
user = relationship("User")
|
||||
|
||||
class AssetAssignment(Base):
|
||||
"""Jármű flotta-történetének nyilvántartása."""
|
||||
__tablename__ = "asset_assignments"
|
||||
__table_args__ = {"schema": "data"}
|
||||
id = Column(PG_UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
@@ -104,7 +104,6 @@ class AssetAssignment(Base):
|
||||
assigned_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
released_at = Column(DateTime(timezone=True), nullable=True)
|
||||
status = Column(String(30), default="active")
|
||||
|
||||
asset = relationship("Asset", back_populates="assignments")
|
||||
organization = relationship("Organization")
|
||||
|
||||
@@ -115,7 +114,7 @@ class AssetEvent(Base):
|
||||
asset_id = Column(PG_UUID(as_uuid=True), ForeignKey("data.assets.id"), nullable=False)
|
||||
event_type = Column(String(50), nullable=False)
|
||||
recorded_mileage = Column(Integer)
|
||||
data = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
data = Column(JSONB, server_default=text("'{}'::jsonb"))
|
||||
asset = relationship("Asset", back_populates="events")
|
||||
|
||||
class AssetCost(Base):
|
||||
@@ -129,10 +128,12 @@ class AssetCost(Base):
|
||||
amount_local = Column(Numeric(18, 2), nullable=False)
|
||||
currency_local = Column(String(3), nullable=False)
|
||||
amount_eur = Column(Numeric(18, 2), nullable=True)
|
||||
net_amount_local = Column(Numeric(18, 2))
|
||||
vat_rate = Column(Numeric(5, 2))
|
||||
exchange_rate_used = Column(Numeric(18, 6))
|
||||
date = Column(DateTime(timezone=True), server_default=func.now())
|
||||
mileage_at_cost = Column(Integer)
|
||||
data = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
|
||||
data = Column(JSONB, server_default=text("'{}'::jsonb"))
|
||||
asset = relationship("Asset", back_populates="costs")
|
||||
organization = relationship("Organization")
|
||||
driver = relationship("User")
|
||||
@@ -143,5 +144,4 @@ class ExchangeRate(Base):
|
||||
id = Column(Integer, primary_key=True)
|
||||
base_currency = Column(String(3), default="EUR")
|
||||
target_currency = Column(String(3), unique=True)
|
||||
rate = Column(Numeric(18, 6), nullable=False)
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
rate = Column(Numeric(18, 6), nullable=False)
|
||||
@@ -7,41 +7,82 @@ from sqlalchemy.sql import func
|
||||
from app.db.base_class import Base
|
||||
|
||||
class UserRole(str, enum.Enum):
|
||||
superadmin = "superadmin"; admin = "admin"; user = "user"
|
||||
service = "service"; fleet_manager = "fleet_manager"; driver = "driver"
|
||||
superadmin = "superadmin"
|
||||
admin = "admin"
|
||||
user = "user"
|
||||
service = "service"
|
||||
fleet_manager = "fleet_manager"
|
||||
driver = "driver"
|
||||
|
||||
class Person(Base):
|
||||
__tablename__ = "persons"; __table_args__ = {"schema": "data"}
|
||||
"""
|
||||
Természetes személy identitása.
|
||||
A bot által talált személyek is ide kerülnek (is_ghost=True).
|
||||
Azonosítás: Név + Anyja neve + Születési adatok alapján.
|
||||
"""
|
||||
__tablename__ = "persons"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(BigInteger, primary_key=True, index=True)
|
||||
id_uuid = Column(PG_UUID(as_uuid=True), default=uuid.uuid4, unique=True, nullable=False)
|
||||
address_id = Column(PG_UUID(as_uuid=True), ForeignKey("data.addresses.id"), nullable=True)
|
||||
last_name = Column(String, nullable=False); first_name = Column(String, nullable=False); phone = Column(String, nullable=True)
|
||||
mothers_last_name = Column(String); mothers_first_name = Column(String); birth_place = Column(String); birth_date = Column(DateTime)
|
||||
|
||||
last_name = Column(String, nullable=False)
|
||||
first_name = Column(String, nullable=False)
|
||||
phone = Column(String, nullable=True)
|
||||
|
||||
# --- TERMÉSZETES AZONOSÍTÓK (Azonosításhoz, nem publikus) ---
|
||||
mothers_last_name = Column(String)
|
||||
mothers_first_name = Column(String)
|
||||
birth_place = Column(String)
|
||||
birth_date = Column(DateTime)
|
||||
|
||||
identity_docs = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
ice_contact = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
|
||||
is_active = Column(Boolean, default=False, nullable=False)
|
||||
is_ghost = Column(Boolean, default=True, nullable=False) # Bot találta = True, Regisztrált = False
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
users = relationship("User", back_populates="person")
|
||||
memberships = relationship("OrganizationMember", back_populates="person")
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"; __table_args__ = {"schema": "data"}
|
||||
__tablename__ = "users"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
email = Column(String, unique=True, index=True, nullable=False)
|
||||
hashed_password = Column(String, nullable=True)
|
||||
role = Column(Enum(UserRole), default=UserRole.user)
|
||||
is_active = Column(Boolean, default=False); is_deleted = Column(Boolean, default=False)
|
||||
is_active = Column(Boolean, default=False)
|
||||
is_deleted = Column(Boolean, default=False)
|
||||
|
||||
person_id = Column(BigInteger, ForeignKey("data.persons.id"), nullable=True)
|
||||
folder_slug = Column(String(12), unique=True, index=True)
|
||||
|
||||
refresh_token_hash = Column(String(255), nullable=True)
|
||||
two_factor_secret = Column(String(100), nullable=True)
|
||||
two_factor_enabled = Column(Boolean, default=False)
|
||||
preferred_language = Column(String(5), server_default="hu"); region_code = Column(String(5), server_default="HU"); preferred_currency = Column(String(3), server_default="HUF")
|
||||
scope_level = Column(String(30), server_default="individual"); scope_id = Column(String(50)); custom_permissions = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
|
||||
preferred_language = Column(String(5), server_default="hu")
|
||||
region_code = Column(String(5), server_default="HU")
|
||||
preferred_currency = Column(String(3), server_default="HUF")
|
||||
|
||||
scope_level = Column(String(30), server_default="individual")
|
||||
scope_id = Column(String(50))
|
||||
custom_permissions = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
person = relationship("Person", back_populates="users"); wallet = relationship("Wallet", back_populates="user", uselist=False)
|
||||
stats = relationship("UserStats", back_populates="user", uselist=False); ownership_history = relationship("VehicleOwnership", back_populates="user")
|
||||
owned_organizations = relationship("Organization", back_populates="owner"); social_accounts = relationship("SocialAccount", back_populates="user", cascade="all, delete-orphan")
|
||||
|
||||
person = relationship("Person", back_populates="users")
|
||||
wallet = relationship("Wallet", back_populates="user", uselist=False)
|
||||
stats = relationship("UserStats", back_populates="user", uselist=False)
|
||||
ownership_history = relationship("VehicleOwnership", back_populates="user")
|
||||
owned_organizations = relationship("Organization", back_populates="owner")
|
||||
social_accounts = relationship("SocialAccount", back_populates="user", cascade="all, delete-orphan")
|
||||
|
||||
class Wallet(Base):
|
||||
__tablename__ = "wallets"; __table_args__ = {"schema": "data"}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import enum
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON, text
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON, text, Numeric, BigInteger
|
||||
from sqlalchemy.dialects.postgresql import ENUM as PG_ENUM
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
@@ -14,35 +14,43 @@ class OrgType(str, enum.Enum):
|
||||
club = "club"
|
||||
business = "business"
|
||||
|
||||
class OrgUserRole(str, enum.Enum):
|
||||
OWNER = "OWNER"
|
||||
ADMIN = "ADMIN"
|
||||
FLEET_MANAGER = "FLEET_MANAGER"
|
||||
DRIVER = "DRIVER"
|
||||
MECHANIC = "MECHANIC"
|
||||
RECEPTIONIST = "RECEPTIONIST"
|
||||
|
||||
class Organization(Base):
|
||||
"""
|
||||
Szervezet entitás. Lehet flotta (user) és szolgáltató (service) egyszerre.
|
||||
A képességeket a kapcsolódó profilok (pl. ServiceProfile) határozzák meg.
|
||||
"""
|
||||
__tablename__ = "organizations"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
address_id = Column(PG_UUID(as_uuid=True), ForeignKey("data.addresses.id"), nullable=True)
|
||||
|
||||
full_name = Column(String, nullable=False)
|
||||
name = Column(String, nullable=False)
|
||||
full_name = Column(String, nullable=False) # Hivatalos név
|
||||
name = Column(String, nullable=False) # Rövid név
|
||||
display_name = Column(String(50))
|
||||
|
||||
# --- BIZTONSÁGI BŐVÍTÉS (Mappa elszigetelés) ---
|
||||
folder_slug = Column(String(12), unique=True, index=True)
|
||||
|
||||
default_currency = Column(String(3), default="HUF")
|
||||
country_code = Column(String(2), default="HU")
|
||||
language = Column(String(5), default="hu")
|
||||
|
||||
# Cím adatok (redundáns a gyors kereséshez, de address_id a SSoT)
|
||||
address_zip = Column(String(10))
|
||||
address_city = Column(String(100))
|
||||
address_street_name = Column(String(150))
|
||||
address_street_type = Column(String(50))
|
||||
address_street_type = Column(String(50))
|
||||
address_house_number = Column(String(20))
|
||||
address_hrsz = Column(String(50))
|
||||
address_stairwell = Column(String(20))
|
||||
address_floor = Column(String(20))
|
||||
address_door = Column(String(20))
|
||||
address_hrsz = Column(String(50))
|
||||
|
||||
tax_number = Column(String(20), unique=True, index=True)
|
||||
tax_number = Column(String(20), unique=True, index=True) # Robot horgony
|
||||
reg_number = Column(String(50))
|
||||
|
||||
org_type = Column(
|
||||
@@ -52,15 +60,13 @@ class Organization(Base):
|
||||
|
||||
status = Column(String(30), default="pending_verification")
|
||||
is_deleted = Column(Boolean, default=False)
|
||||
|
||||
notification_settings = Column(JSON, server_default=text("'{ \"notify_owner\": true, \"alert_days_before\": [30, 15, 7, 1] }'::jsonb"))
|
||||
|
||||
notification_settings = Column(JSON, server_default=text("'{\"notify_owner\": true, \"alert_days_before\": [30, 15, 7, 1]}'::jsonb"))
|
||||
external_integration_config = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
|
||||
owner_id = Column(Integer, ForeignKey("data.users.id"), nullable=True)
|
||||
is_active = Column(Boolean, default=True)
|
||||
is_transferable = Column(Boolean, default=True)
|
||||
is_verified = Column(Boolean, default=False)
|
||||
verification_expires_at = Column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
@@ -69,15 +75,40 @@ class Organization(Base):
|
||||
assets = relationship("AssetAssignment", back_populates="organization", cascade="all, delete-orphan")
|
||||
members = relationship("OrganizationMember", back_populates="organization", cascade="all, delete-orphan")
|
||||
owner = relationship("User", back_populates="owned_organizations")
|
||||
financials = relationship("OrganizationFinancials", back_populates="organization", cascade="all, delete-orphan")
|
||||
service_profile = relationship("ServiceProfile", back_populates="organization", uselist=False)
|
||||
|
||||
class OrganizationMember(Base):
|
||||
__tablename__ = "organization_members"
|
||||
class OrganizationFinancials(Base):
|
||||
"""Cégek éves gazdasági adatai elemzéshez."""
|
||||
__tablename__ = "organization_financials"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
organization_id = Column(Integer, ForeignKey("data.organizations.id"), nullable=False)
|
||||
user_id = Column(Integer, ForeignKey("data.users.id"), nullable=False)
|
||||
role = Column(String, default="driver")
|
||||
year = Column(Integer, nullable=False)
|
||||
turnover = Column(Numeric(18, 2))
|
||||
profit = Column(Numeric(18, 2))
|
||||
employee_count = Column(Integer)
|
||||
source = Column(String(50)) # pl. 'manual', 'crawler', 'api'
|
||||
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
organization = relationship("Organization", back_populates="financials")
|
||||
|
||||
class OrganizationMember(Base):
|
||||
"""Kapcsolótábla a személyek és szervezetek között."""
|
||||
__tablename__ = "organization_members"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
organization_id = Column(Integer, ForeignKey("data.organizations.id"), nullable=False)
|
||||
user_id = Column(Integer, ForeignKey("data.users.id"), nullable=True)
|
||||
person_id = Column(BigInteger, ForeignKey("data.persons.id"), nullable=True) # Ghost támogatás
|
||||
|
||||
role = Column(PG_ENUM(OrgUserRole, name="orguserrole", inherit_schema=True), default=OrgUserRole.DRIVER)
|
||||
permissions = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
is_permanent = Column(Boolean, default=False)
|
||||
is_verified = Column(Boolean, default=False) # <--- JAVÍTÁS: Ez az oszlop hiányzott!
|
||||
|
||||
organization = relationship("Organization", back_populates="members")
|
||||
user = relationship("User")
|
||||
user = relationship("User")
|
||||
person = relationship("Person", back_populates="memberships")
|
||||
@@ -1,26 +0,0 @@
|
||||
import enum
|
||||
from sqlalchemy import Column, Integer, String, Boolean, Enum, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.db.base import Base
|
||||
|
||||
# Átnevezve OrgUserRole-ra, hogy ne ütközzön a globális UserRole-al
|
||||
class OrgUserRole(str, enum.Enum):
|
||||
OWNER = "OWNER"
|
||||
ADMIN = "ADMIN"
|
||||
FLEET_MANAGER = "FLEET_MANAGER"
|
||||
DRIVER = "DRIVER"
|
||||
|
||||
class OrganizationMember(Base):
|
||||
__tablename__ = "organization_members"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
org_id = Column(Integer, ForeignKey("data.organizations.id", ondelete="CASCADE"))
|
||||
user_id = Column(Integer, ForeignKey("data.users.id", ondelete="CASCADE"))
|
||||
# Itt is frissítjük a hivatkozást
|
||||
role = Column(Enum(OrgUserRole), default=OrgUserRole.DRIVER)
|
||||
|
||||
is_permanent = Column(Boolean, default=False)
|
||||
|
||||
organization = relationship("Organization", back_populates="members")
|
||||
# # # user = relationship("User", back_populates="memberships")
|
||||
@@ -1,7 +1,7 @@
|
||||
import uuid
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON, text, Text
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON, text, Text, Float
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.dialects.postgresql import UUID as PG_UUID
|
||||
from sqlalchemy.dialects.postgresql import UUID as PG_UUID, JSONB
|
||||
from geoalchemy2 import Geometry # PostGIS támogatás
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base_class import Base
|
||||
@@ -20,6 +20,19 @@ class ServiceProfile(Base):
|
||||
# PostGIS GPS pont (SRID 4326 = WGS84 koordináták)
|
||||
location = Column(Geometry(geometry_type='POINT', srid=4326), index=True)
|
||||
|
||||
# Állapotkezelés: ghost, active, flagged, inactive
|
||||
status = Column(String(20), server_default=text("'ghost'"), index=True)
|
||||
last_audit_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# --- MAGÁNNYOMOZÓ (Deep Enrichment) ADATOK ---
|
||||
google_place_id = Column(String(100), unique=True)
|
||||
rating = Column(Float)
|
||||
user_ratings_total = Column(Integer)
|
||||
|
||||
# Bentley vs BMW logika: JSONB a gyors, márkaszintű szűréshez
|
||||
# Példa: {"brands": ["Bentley", "Audi"], "specialty": ["engine", "tuning"]}
|
||||
specialization_tags = Column(JSONB, server_default=text("'{}'::jsonb"))
|
||||
|
||||
# Trust Engine (Bot Discovery=30, User Entry=50, Admin/Partner=100)
|
||||
trust_score = Column(Integer, default=30)
|
||||
is_verified = Column(Boolean, default=False)
|
||||
|
||||
Reference in New Issue
Block a user