from sqlalchemy import Column, Integer, String
from utils.rdbmsUtil.modelBase import Base
from utils.rdbmsUtil.factoryRegistry import FactoryRegistry

# 实体类
class User(Base):
    def __init__(self, **kwargs):
        for key, value in kwargs.items():
            setattr(self, key, value)

    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    age = Column(Integer)
    companyid=Column(Integer)

    def __repr__(self):
        return f"<User(name={self.name}, age={self.age},companyid={self.companyid})>"
    
def user_factory(**kwargs):
    return User(**kwargs)

FactoryRegistry.register_factory('user', user_factory)
print("User factory registered.")  # 打印确认消息
