|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
import sqlalchemy
|
|
|
|
|
|
|
|
|
|
sys.path.append(".")
|
|
|
|
|
import jwt
|
|
|
|
|
import base64
|
|
|
|
@ -16,13 +17,14 @@ from db_logic.db_base import Repository
|
|
|
|
|
from models.user_models import EntityUser
|
|
|
|
|
from Common.Utils import Utils
|
|
|
|
|
|
|
|
|
|
#用户操作业务逻辑类
|
|
|
|
|
|
|
|
|
|
# 用户操作业务逻辑类
|
|
|
|
|
class BllUser(Repository):
|
|
|
|
|
|
|
|
|
|
def __init__(self, entityType=EntityUser):
|
|
|
|
|
return super().__init__(entityType)
|
|
|
|
|
|
|
|
|
|
#用户账号密码登录
|
|
|
|
|
# 用户账号密码登录
|
|
|
|
|
def login(self, user_name, password):
|
|
|
|
|
user_info = self.findEntity(
|
|
|
|
|
or_(
|
|
|
|
@ -33,7 +35,7 @@ class BllUser(Repository):
|
|
|
|
|
if user_info:
|
|
|
|
|
if user_info.is_enabled:
|
|
|
|
|
if str(user_info.password).lower() == Utils.MD5(password).lower():
|
|
|
|
|
self.last_visit_date=Utils.get_str_datetime()
|
|
|
|
|
self.last_visit_date = Utils.get_str_datetime()
|
|
|
|
|
self.update(user_info)
|
|
|
|
|
return self.get_jwt(user_info), user_info
|
|
|
|
|
return False, None
|
|
|
|
@ -78,7 +80,8 @@ class BllUser(Repository):
|
|
|
|
|
return self.findEntity(payload.get('user_id'))
|
|
|
|
|
|
|
|
|
|
# 用户管理
|
|
|
|
|
def get_seach_user_list(self, user_code, real_name, role_name, is_enabled, page_param, user_id,role_name_self):
|
|
|
|
|
def get_seach_user_list(self, user_code, real_name, role_name, role_id, is_enabled, page_param, user_id,
|
|
|
|
|
role_name_self):
|
|
|
|
|
filter_base = ""
|
|
|
|
|
if user_code:
|
|
|
|
|
filter_base += f" user_code like '%{user_code}%'"
|
|
|
|
@ -90,20 +93,19 @@ class BllUser(Repository):
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f" role_name like '%{role_name}%'"
|
|
|
|
|
if role_id:
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f" role_id='{role_id}' "
|
|
|
|
|
if is_enabled:
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f" is_enabled={is_enabled}"
|
|
|
|
|
|
|
|
|
|
# if role_name_self !='管理员':
|
|
|
|
|
# if filter_base:
|
|
|
|
|
# filter_base += " and "
|
|
|
|
|
# filter_base += f" user_id != '{user_id}' "
|
|
|
|
|
# if filter_base:
|
|
|
|
|
# filter_base = f" where {filter_base}"
|
|
|
|
|
|
|
|
|
|
if role_name_self !='管理员':
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f" user_id = '{user_id}' "
|
|
|
|
|
# filter_base += f" user_id = '{user_id}' "
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base = f" where {filter_base}"
|
|
|
|
|
|
|
|
|
@ -118,8 +120,6 @@ class BllUser(Repository):
|
|
|
|
|
sql_page = Utils.sql_paging_assemble(sql_all, page_param)
|
|
|
|
|
return self.execute(sql_page).fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# #根据条码获取用户
|
|
|
|
|
# def getUserByBarCode(self, barCode):
|
|
|
|
|
# return self.findEntity(EntityUser.BarCode == barCode)
|
|
|
|
|