2023-06-13 10:16:40 +08:00
|
|
|
import uuid
|
|
|
|
|
|
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from Context.common import common_db
|
|
|
|
from sqlalchemy import Column, Integer, Boolean, String, ForeignKey, Text, DateTime, func, Date, Double
|
|
|
|
|
|
|
|
|
|
|
|
class AdminUser(common_db.Base):
|
|
|
|
"""
|
|
|
|
管理员用户表
|
|
|
|
"""
|
|
|
|
__tablename__ = "admin_user"
|
|
|
|
|
|
|
|
id = Column(String(255), primary_key=True, comment='用户ID', default=lambda: uuid.uuid4().hex)
|
|
|
|
email = Column(String(255), comment="邮箱")
|
|
|
|
phone = Column(String(255), comment="手机号")
|
|
|
|
passwd = Column(String(255), comment="hash密码")
|
|
|
|
name = Column(String(255), comment="名称")
|
|
|
|
create_time = Column(DateTime, server_default=func.now(), comment='创建时间')
|
|
|
|
|
|
|
|
def to_dict(self):
|
|
|
|
data = {c.name: getattr(self, c.name) for c in self.__table__.columns}
|
|
|
|
return data
|
2023-06-13 11:00:25 +08:00
|
|
|
|
|
|
|
def to_safe_dict(self):
|
|
|
|
data = {c.name: getattr(self, c.name) for c in self.__table__.columns if c.name != 'passwd'}
|
|
|
|
return data
|