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.
46 lines
1.6 KiB
46 lines
1.6 KiB
#!/usr/bin/env python
|
|
# -*- encoding: utf-8 -*-
|
|
'''
|
|
@Date:2022/07/18 16:44:57
|
|
'''
|
|
|
|
from sqlalchemy import and_, or_, desc
|
|
from db_logic.db_base import Repository
|
|
from models.user_models import EntityUser
|
|
from common.utils import Utils
|
|
|
|
#用户操作业务逻辑类
|
|
class BllUser(Repository):
|
|
#_instance_lock = threading.Lock()
|
|
##实现单例模式
|
|
#def __new__(cls, *args, **kwargs):
|
|
# if not hasattr(BllUser, "_instance"):
|
|
# with BllUser._instance_lock:
|
|
# if not hasattr(BllUser, "_instance"):
|
|
# BllUser._instance = object.__new__(cls)
|
|
# return BllUser._instance
|
|
|
|
def __init__(self, entityType=EntityUser):
|
|
return super().__init__(entityType)
|
|
|
|
#用户账号密码登录
|
|
def login(self, userAccount, userPwd):
|
|
d = Utils.MD5(userPwd)
|
|
print(d)
|
|
return self.findEntity(and_(EntityUser.Account == userAccount, EntityUser.Password == Utils.MD5(userPwd)))
|
|
|
|
#根据条码获取用户
|
|
def getUserByBarCode(self, barCode):
|
|
return self.findEntity(EntityUser.BarCode == barCode)
|
|
|
|
#获取用户列表
|
|
def getUserList(self, customerId, pageParam, keyWord=''):
|
|
keyWord = '%' + keyWord + '%'
|
|
orm_query = self.findList().filter(EntityUser.CustomerId == customerId
|
|
).filter(or_(EntityUser.UserCode.like(keyWord), EntityUser.RealName.like(keyWord))).order_by(desc(EntityUser.CreateDate))
|
|
return self.queryPage(orm_query, pageParam)
|
|
|
|
#获取用户详情信息
|
|
def getUserInfo(self, userId):
|
|
return self.findEntity(userId)
|