class UserService:
    __user_dao = UserDao()

    def login(self, username, password):
        result = self.__user_dao.login(username=username, password=password)
        return result

    def search_user_role(self, username):
        role = self.__user_dao.search_user_role(username=username)
        return role

    def insert(self, username, password, email, role_id):
        self.__user_dao.insert(username=username,
                               password=password,
                               email=email,
                               role_id=role_id)

    def search_count_page(self):
        count_page = self.__user_dao.search_count_page()
        return count_page

    def search_user_list(self, page):
        result = self.__user_dao.search_user_list(page=page)
        return result

    def update_user(self, user_id, username, password, email, role_id):
        self.__user_dao.update_user(user_id=user_id,
                                    username=username,
                                    password=password,
                                    email=email,
                                    role_id=role_id)

    def delete_user(self, user_id):
        self.__user_dao.delete_user(user_id=user_id)
示例#2
0
class UserService:
    __user_dao = UserDao()

    # 验证用户登录
    def login(self, username, password):
        return self.__user_dao.login(username, password)

    # 查询用户角色
    def search_user_role(self, username):
        return self.__user_dao.search_user_role(username)

    # 添加用户
    def insert(self, username, password, email, role_id):
        self.__user_dao.insert(username, password, email, role_id)

    # 查询用户总页数
    def search_count_page(self):
        return self.__user_dao.search_count_page()

    # 查询用户分页记录
    def search_list(self, page):
        return self.__user_dao.search_list(page)

    # 修改用户信息
    def update(self, id, username, password, email, role_id):
        self.__user_dao.update(id, username, password, email, role_id)

    # 删除用户
    def delete_by_id(self, id):
        self.__user_dao.delete_by_id(id)

    # 查询用户ID
    def search_userid(self, username):
        return self.__user_dao.search_userid(username)
示例#3
0
class BusinessObject:
    """Simple class for mock demo"""

    def __init__(self, name=''):
        print('BusinessObject.__init__')
        self.name = name
        self.user_dao = UserDao()

    def get_user(self, user_id):
        try:
            user = self.user_dao.query_user(user_id)

            print('BusinessObject.get_user: user_dao.query_user returned '
                  'user ' + user.last_name if user else None)

            if user is None:
                raise ValueError('{} is not a valid user ID'.format(user_id))

            return user
        except sqlite3.Error as e:
            raise BusinessError('Problem fetching user with ID {}: {}'
                                .format(user_id, str(e)))

    def __str__(self):
        return "{self.name}".format(self=self)
示例#4
0
class UserService():
    __user_dao = UserDao()

    def login(self, username, password):
        result = self.__user_dao.login(username, password)
        return result

    def search_user_role(self, username):
        role = self.__user_dao.search_user_role(username)
        return role

    def add_user(self, username, password, email, role_id):
        self.__user_dao.add_user(username, password, email, role_id)

    def search_count_page(self):
        count_page = self.__user_dao.search_count_page()
        return count_page

    def search_user_list(self, page):
        result = self.__user_dao.search_user_list(page)
        return result

    def update_user(self, id, username, password, email, role_id):
        self.__user_dao.update_user(id, username, password, email, role_id)

    def delete_by_id(self, id):
        self.__user_dao.delete_by_id(id)
示例#5
0
 def search_user_role(username):
     """
     get the urser's role
     :param username: the user's username
     :return: the user's role if not found, return None
     """
     return UserDao.search_user_role(username)
示例#6
0
class User_service:
    __user_dao = UserDao()

    def login(self, username, password):
        return self.__user_dao.login(username, password)
    
    def get_user_role(self, username):
        return self.__user_dao.get_user_role(username)
示例#7
0
 def login(username, password):
     """
     find wether the user exist in the database
     :param username: username
     :param password: password
     :return: True if the user and password are all corrected, False, if one of them is not correct
     """
     return UserDao.login(username, password)
示例#8
0
class UserService(object):
    """ 用户服务类 """
    __user_dao = UserDao()

    def login(self, username, password):
        """ 验证用户登录 """
        result = self.__user_dao.login(username, password)
        return result

    def search_user_role(self, username):
        """ 验证用户角色 """
        role = self.__user_dao.search_user_role(username)
        return role

    def insert(self, username, password, email, role_id):
        """ 添加记录 """
        self.__user_dao.insert(username, password, email, role_id)

    def search_count_page(self):
        """ 查询用户总页数 """
        count_page = self.__user_dao.search_count_page()
        return count_page

    def search_list(self, page):
        """ 查询用户分页记录 """
        result = self.__user_dao.search_list(page)
        return result

    def update(self, id, username, password, email, role_id):
        """ 修改用户信息 """
        self.__user_dao.update(id, username, password, email, role_id)

    def delete_by_id(self, id):
        """ 删除用户 """
        self.__user_dao.delete_by_id(id)

    def search_userid(self, username):
        """ 查询用户ID """
        userid = self.__user_dao.search_userid(username)
        return userid
示例#9
0
class UserService:
    __user_dao = UserDao()

    # 验证用户登录
    def login(self, username, password):
        result = self.__user_dao.login(username, password)
        return result

    # 查询用户角色
    def search_user_role(self, username):
        role = self.__user_dao.seach_user_role(username)
        return role

    # 添加记录
    def insert(self, username, password, email, role_id):
        self.__user_dao.insert(username, password, email, role_id)

    # 查询用户总页数
    def search_userlist_page(self):
        count_page = self.__user_dao.search_userlist_page()
        return count_page

    # 查询用户的分页
    def search_list(self, page):
        result = self.__user_dao.search_list(page)
        return result

    # 修改用户信息
    def update(self, id, username, password, email, role_id):
        self.__user_dao.update(id, username, password, email, role_id)

    # 删除用户信息
    def delete_by_id(self, id):
        self.__user_dao.delete_by_id(id)

    # 查询用户ID
    def search_userid(self, username):
        userid = self.__user_dao.search_userid(username)
        return userid
示例#10
0
class UserSercicr(object):
    __user_dao = UserDao()

    # 验证用户登录
    def login(self, username, password):
        result = self.__user_dao.login(username, password)
        return result

    # 查询用户角色
    def search_user_role(self, username):
        role = self.__user_dao.search_user_role(username)
        return role

    # 查询单个用户信息
    def search_username(self, username):
        count = self.__user_dao.search_username(username)
        return count

    # 添加用户
    def insert(self, username, password, email, rold_id):
        self.__user_dao.insert(username, password, email, rold_id)

    # 查询用户总页数
    def search_count_page(self):
        count_page = self.__user_dao.search_count_page()
        return count_page

    # 查询用户分页记录
    def search_list(self, page):
        result = self.__user_dao.search_list(page)
        return result

    # 修改用户信息
    def update(self, id, username, password, email, role_id):
        self.__user_dao.update(id, username, password, email, role_id)

    # 删除用户
    def delete_by_id(self, id):
        self.__user_dao.delete_by_id(id)
示例#11
0
class UserService:
    __user_dao = UserDao()

    # 验证用户登录
    def login(self, username, password):
        result = self.__user_dao.login(username, password)
        return result

    # 验证用户身份
    def sear_user_role(self, username):
        role = self.__user_dao.search_user_role(username)
        return role

    # 添加用户
    def insert_user(self, username, password, email, role_id):
        self.__user_dao.insert_user(username, password, email, role_id)

    # 验证用户名
    def search_username(self):
        username = self.__user_dao.search_username()
        return username

    # 查看用户表的总页数
    def search_user_page_count(self):
        page_count = self.__user_dao.search_user_page_count()
        return page_count

    # 分页查询用户
    def search_user(self, page):
        result = self.__user_dao.search_user(page)
        return result

    # 修改用户信息
    def update_user_by_username(self, username, password, email, role_id,
                                old_username):
        self.__user_dao.update_user_by_username(username, password, email,
                                                role_id, old_username)
示例#12
0
class BusinessObject:
    """Simple class for mock demo"""
    def __init__(self, name=''):
        print('BusinessObject.__init__')
        self.name = name
        self.user_dao = UserDao()

    def get_user(self, user_id):
        try:
            user = self.user_dao.query_user(user_id)

            print('BusinessObject.get_user: user_dao.query_user returned '
                  'user ' + user.last_name if user else None)

            if user is None:
                raise ValueError('{} is not a valid user ID'.format(user_id))

            return user
        except sqlite3.Error as e:
            raise BusinessError('Problem fetching user with ID {}: {}'.format(
                user_id, str(e)))

    def __str__(self):
        return "{self.name}".format(self=self)
示例#13
0
 def __init__(self, name=''):
     print('BusinessObject.__init__')
     self.name = name
     self.user_dao = UserDao()
示例#14
0
 def __init__(self, name=''):
     print('BusinessObject.__init__')
     self.name = name
     self.user_dao = UserDao()
示例#15
0
from db.user_dao import UserDao

print(UserDao.login("admin", "123456"))
r = UserDao.search_user_role("admin")
print(r)