2022-04-06 15:15:44 +08:00
|
|
|
from werkzeug.security import generate_password_hash
|
|
|
|
|
2022-04-06 04:30:30 +08:00
|
|
|
from Utils.ValidateUtil import ValidateAttr, Validate
|
|
|
|
|
|
|
|
|
|
|
|
class VerifyInfo(object):
|
2022-04-06 15:15:44 +08:00
|
|
|
"""认证信息"""
|
|
|
|
name = ValidateAttr(field='name', default=None, type=str, error_info='企业名称异常', error_code=200)
|
|
|
|
code = ValidateAttr(field='code', default=None, type=str, error_info='统一社会信用代码异常', error_code=200)
|
|
|
|
legal_person = ValidateAttr(field='legal_person', default=None, type=str, error_info='法人姓名异常', error_code=200)
|
|
|
|
legal_person_id = ValidateAttr(field='legal_person_id', default=None, type=str, error_info='法人身份证号异常', error_code=200)
|
|
|
|
|
|
|
|
def dict_to_save(self, **kwargs):
|
|
|
|
""""""
|
|
|
|
_dict_ = {
|
|
|
|
"企业名称": self.name,
|
|
|
|
"统一社会信用代码": self.code,
|
|
|
|
"法人姓名": self.legal_person,
|
|
|
|
"法人身份证": self.legal_person_id,
|
|
|
|
}
|
|
|
|
|
|
|
|
if 'columns' in kwargs:
|
|
|
|
_dict_ = {key: _dict_[key] for key in kwargs['columns']}
|
|
|
|
|
|
|
|
return _dict_
|
2022-04-06 04:30:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
class CompanyUser(object):
|
2022-04-06 15:15:44 +08:00
|
|
|
"""企业用户"""
|
2022-04-06 04:30:30 +08:00
|
|
|
cid = ValidateAttr(field='cid', type=str, length=8, error_info='企业ID异常', error_code=200)
|
|
|
|
name = ValidateAttr(field='name', type=str, error_info='企业名称异常', error_code=200)
|
2022-04-06 15:15:44 +08:00
|
|
|
email = ValidateAttr(field='email', func=Validate.email, error_info='邮箱格式异常', error_code=200)
|
|
|
|
pwd = ValidateAttr(field='pwd', func=Validate.password, error_info='密码强度异常', error_code=200)
|
2022-04-06 04:30:30 +08:00
|
|
|
avatar_id = ValidateAttr(field='avatar_id', type=str, length=24, error_info='头像ID异常', error_code=200)
|
|
|
|
verify_status = ValidateAttr(field='verify_status', type=str, in_list=["是", "否"], error_info='认证状态异常', error_code=200)
|
|
|
|
verify_info = ValidateAttr(field='verify_info', type=VerifyInfo, error_info='认证信息异常', error_code=200)
|
2022-04-06 15:15:44 +08:00
|
|
|
register_time = ValidateAttr(field='register_time', default=None, type=str, error_info='注册时间异常', error_code=200)
|
2022-04-06 04:30:30 +08:00
|
|
|
|
|
|
|
def dict_to_show(self, **kwargs):
|
|
|
|
""""""
|
|
|
|
_dict_ = {
|
|
|
|
"企业ID": self.cid,
|
|
|
|
"企业名称": self.name,
|
|
|
|
"邮箱": self.email,
|
2022-04-06 15:15:44 +08:00
|
|
|
"认证状态": self.verify_status,
|
|
|
|
"token": None
|
2022-04-06 04:30:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if 'columns' in kwargs:
|
|
|
|
_dict_ = {key: _dict_[key] for key in kwargs['columns']}
|
|
|
|
|
|
|
|
return _dict_
|
|
|
|
|
|
|
|
def dict_to_save(self, **kwargs):
|
|
|
|
""""""
|
|
|
|
_dict_ = {
|
|
|
|
"企业ID": self.cid,
|
|
|
|
"企业名称": self.name,
|
|
|
|
"邮箱": self.email,
|
|
|
|
"头像fid": self.avatar_id,
|
2022-04-06 15:15:44 +08:00
|
|
|
"密码": generate_password_hash(self.pwd),
|
2022-04-06 04:30:30 +08:00
|
|
|
"注册时间": self.register_time,
|
|
|
|
"已认证": self.verify_status,
|
2022-04-06 15:15:44 +08:00
|
|
|
"认证信息": self.verify_info.dict_to_save()
|
2022-04-06 04:30:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if 'columns' in kwargs:
|
|
|
|
_dict_ = {key: _dict_[key] for key in kwargs['columns']}
|
|
|
|
|
|
|
|
return _dict_
|
|
|
|
|
2022-04-06 15:15:44 +08:00
|
|
|
def login(self):
|
|
|
|
"""登录"""
|
|
|
|
|
|
|
|
def register(self, **kwargs):
|
|
|
|
"""注册"""
|
|
|
|
|
|
|
|
def get_company_user_info(self):
|
|
|
|
"""获取企业用户信息"""
|
|
|
|
|
|
|
|
def get_avatar(self):
|
|
|
|
"""获取用户头像"""
|
|
|
|
|
|
|
|
def change_avatar(self):
|
|
|
|
"""修改用户头像"""
|
|
|
|
|
|
|
|
def change_password(self):
|
|
|
|
"""修改登录密码"""
|
2022-04-06 04:30:30 +08:00
|
|
|
|
2022-04-06 15:15:44 +08:00
|
|
|
def change_email(self):
|
|
|
|
"""修改登录邮箱"""
|
2022-04-06 04:30:30 +08:00
|
|
|
|
|
|
|
|
2022-04-06 15:15:44 +08:00
|
|
|
class VerifyMaterial(object):
|
|
|
|
"""认证材料"""
|
2022-04-06 04:30:30 +08:00
|
|
|
|
2022-04-06 15:15:44 +08:00
|
|
|
image = ValidateAttr(field='image', error_info='上传文件异常', error_code=200)
|
2022-04-06 04:30:30 +08:00
|
|
|
|
2022-04-06 15:15:44 +08:00
|
|
|
def upload_id_card(self):
|
|
|
|
"""上传身份证"""
|
2022-04-06 04:30:30 +08:00
|
|
|
|
2022-04-06 15:15:44 +08:00
|
|
|
def upload_business_license(self):
|
|
|
|
"""上传营业执照"""
|