from db import db_handler from lib import base from interface import common STATUS = 'manager' user_logger = base.get_logger('manager') # ===============登录注册相关=============== def login_interface(name, password): return common.login_interface(STATUS, name, password) def register_interface(name, password): user = db_handler.select(STATUS, name) if user: return False, '用户已经存在' else: from lib.Manager import Manager new_manager = Manager(name, password) db_handler.save(STATUS, new_manager) user_logger.info('%s 注册了' % name) return True, '注册成功' def lock_user_interface(name): common.lock_user_interface(STATUS, name) def un_lock_user_interface(name):
from db import db_handler from lib import base import interface.common as common STATUS = 'student' user_logger = base.get_logger('student') def login_interface(name, password): return common.login_interface(STATUS, name, password) def register_interface(name, password): user = db_handler.select(STATUS, name) if user: return False, '用户已经存在' else: from lib.Student import Student new_manager = Student(name, password) db_handler.save(STATUS, new_manager) user_logger.info('%s 注册了' % name) return True, '注册成功' def lock_user_interface(name): common.lock_user_interface(STATUS, name) def un_lock_user_interface(name): common.un_lock_user_interface(STATUS, name)
from db.db_handler import select_user, save_user, get_user_list,select_group_chat,save_group_chat,get_group_chat_list from lib import base user_logger = base.get_logger('user') def login_interface(name, password): user = select_user(name) if user: if user.check_login_info(password): user_logger.info('%s登录了' % name) return True, '登陆成功' else: return False, '用户密码错误或已经锁定' else: return False, '用户不存在' def register_interface(name, password): user = select_user(name) if user: return False, '用户已经存在' else: from lib.User import User new_user = User(name, password) save_user(new_user) user_logger.info('%s 注册了' % name) return True, '注册成功'
from db import db_handler from lib import base common_logger = base.get_logger('common') # ===============登录注册相关=============== def login_interface(status, name, password): user = db_handler.select(status, name) if user: if user.check_login_info(password): common_logger.info('%s登录了(身份:%s)' % (name,status)) return True, '登陆成功' else: return False, '用户密码错误或已经锁定' else: return False, '用户不存在' def register_interface(status, name, password): pass def lock_user_interface(status, name): user = db_handler.select(status, name) if user: user.lock() db_handler.save(status, user) common_logger.info('%s被锁定了' % name)
from db import db_handler import interface.common as common from lib import base user_logger = base.get_logger('teacher') STATUS = 'teacher' def login_interface(name, password): return common.login_interface(STATUS, name, password) def register_interface(name, password): user = db_handler.select(STATUS, name) if user: return False, '用户已经存在' else: from lib.Teacher import Teacher new_user = Teacher(name, password) db_handler.save(STATUS, new_user) user_logger.info('%s 注册了' % name) return True, '注册成功' def lock_user_interface(name): common.lock_user_interface(STATUS, name) def un_lock_user_interface(name): common.un_lock_user_interface(STATUS, name)