ymt-python / models /operation_log.py
hsailorj's picture
Add application file
551658a
Raw
History Blame Contribute Delete
1.23 kB
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
from sqlalchemy.sql import text
from database import Base
class OperationLog(Base):
__tablename__ = "operation_logs"
id = Column(Integer, primary_key=True, index=True, comment='主键ID')
user_id = Column(Integer, nullable=False, server_default="0", comment='操作人ID')
username = Column(String(50), nullable=False, server_default="", comment='操作人用户名')
company_code = Column(String(50), nullable=False, server_default="", index=True, comment='操作所属公司编码')
module = Column(String(50), nullable=False, server_default="", comment='操作模块(如:user, company, product等)')
operation_type = Column(String(20), nullable=False, server_default="", comment='操作类型:add, edit, delete')
operation_detail = Column(Text, nullable=False, default="", comment='操作详情')
before_data = Column(Text, nullable=False, default="", comment='修改前的数据')
after_data = Column(Text, nullable=False, default="", comment='修改后的数据')
created_at = Column(DateTime(timezone=True), nullable=False, server_default=text('CURRENT_TIMESTAMP'), comment='操作时间')