monitoring/models/model.py

30 lines
1.1 KiB
Python

# _*_ coding: utf-8 _*_
# @Time :2022/5/29 09:40
# @Email :508737091@qq.com
# @Author :qiangyanwen
# @File :model.py
from datetime import datetime
from sqlalchemy import Column, INT, String, DATETIME,Integer
from config.database import DatabaseModel
class User(DatabaseModel):
"""
用户表
"""
__tablename__ = "user"
id = Column(INT, primary_key=True, comment='主键id')
username = Column(String(16), unique=True, index=True, comment="用户名")
password = Column(String(256), comment="密码")
email = Column(String(64), unique=True, nullable=False, comment="邮箱")
status = Column(Integer,nullable=False,comment="用户状态,0是禁用1是启用",default=1)
created_time = Column(DATETIME, comment='创建时间')
deleted_time = Column(DATETIME, comment="更新时间")
__table_args__ = ({'comment': '用户表'})
def __init__(self, username, password, email):
self.username = username
self.password = password
self.email = email
self.created_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")