Spaces:
Sleeping
Sleeping
File size: 1,442 Bytes
551658a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from sqlalchemy import Column, Integer, String, DateTime, Index, text
from sqlalchemy.sql import func
from database import Base
class SiteVisit(Base):
__tablename__ = "site_visits"
id = Column(Integer, primary_key=True, index=True, comment='主键 ID')
company_code = Column(String(50), nullable=False, index=True, comment='公司编码')
ip_address = Column(String(45), nullable=False, index=True, comment='访问IP地址')
visitor_id = Column(String(100), nullable=True, index=True, comment='访客ID')
# 地理位置信息
country = Column(String(50), nullable=True, comment='国家')
region = Column(String(50), nullable=True, comment='地区/省份')
city = Column(String(50), nullable=True, comment='城市')
latitude = Column(String(20), nullable=True, comment='纬度')
longitude = Column(String(20), nullable=True, comment='经度')
# 访问信息
user_agent = Column(String(500), nullable=True, comment='用户代理')
referer = Column(String(500), nullable=True, comment='来源页面')
page_url = Column(String(500), nullable=True, comment='访问页面')
visit_date = Column(DateTime(timezone=True), nullable=False, server_default=text('CURRENT_TIMESTAMP'), comment='访问时间')
__table_args__ = (
Index('idx_company_visit_date', 'company_code', 'visit_date'),
Index('idx_company_country', 'company_code', 'country'),
)
|