You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yy_rms_39zhiyao_duizhao/models/user_models.py

76 lines
3.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/07/18 15:29:38
'''
import sys
sys.path.append(".")
from sqlalchemy import Column, String, Text, Integer
from Common.Utils import Utils
from models.models_base import Base, get_uuid
from werkzeug.security import check_password_hash, generate_password_hash
# 已同步本地数据库
class EntityUser(Base):
__tablename__ = "rms_user"
__table_args__ = (
{
"comment": "RMS用户表"
}
)
user_id = Column(String(50), primary_key=True, comment='用户ID', default=get_uuid) # 用户ID
customer_id = Column(String(50), comment='客户ID') # 客户ID
role_id = Column(String(50), comment='角色ID') # 角色ID
role_name = Column(String(50), comment='角色名称') # 角色名称
bar_code = Column(String(50), comment='条码') # 条码
user_code = Column(String(50), comment='用户编号') # 用户编号
account = Column(String(50), comment='账户') # 账户
password = Column(String(255), comment='密码') # 密码
real_name = Column(String(50), comment='真实名称') # 真实名称
avatar_url = Column(String(50), comment='头像地址') # 头像地址
avatar_base64 = Column(Text, comment='头像base64值') # 头像base64值
sex = Column(Integer, comment='性别') # 性别 0女1男
birthday = Column(String(50), comment='生日') # 生日
mobile = Column(String(50), comment='手机号码') # 手机号码
email = Column(String(50), comment='Enail') # Enail
qq = Column(String(50), comment='QQ') # QQ
is_enabled = Column(Integer, comment='是否启用') # 是否启用
first_visit_date = Column(String(50), comment='首次登陆日期') # 首次登陆日期
last_visit_date = Column(String(50), comment='最后登陆日期') # 最后登陆日期
description = Column(String(50), comment='备注') # 备注
create_date = Column(String(50), comment='创建日期') # 创建日期
create_user_id = Column(String(50), comment='创建用户ID') # 创建用户ID
create_user_name = Column(String(50), comment='创建用户名称') # 创建用户名称
is_add = Column(Integer, comment='是否添加', default=1)
def update_last_visit_date(self):
self.last_visit_date=Utils.get_str_datetime()
def set_password(self, password):
'''设置用户密码,保存为 Hash 值'''
self.password = generate_password_hash(password)
def check_password(self, password):
'''验证密码与保存的 Hash 值是否匹配'''
return check_password_hash(self.password, password)
class EntityRole(Base):
__tablename__ = "rms_role"
__table_args__ = (
{
"comment": "用户角色实体类"
}
)
role_id = Column(
String(50), primary_key=True, comment="角色ID", default=get_uuid)
role_code = Column(String(50), comment="角色编号")
role_name = Column(String(50), comment="角色名")
role_level = Column(Integer, comment="角色级别")
sort_index = Column(Integer, comment="排序序号")
is_enabled = Column(Integer, comment="是否启用", default=1)
description = Column(String(50), comment="备注")
is_add = Column(Integer, comment="", default=1)