标签:int ret log comm opp 锁定 logger atm false
from db import db_handler
from lib import common
user_logger = common.get_logger(‘user‘)
def login_interface(name, password):
dic = db_handler.select(name)
if dic:
if dic[‘password‘] == password and not dic[‘locked‘]:
return True, ‘登陆成功‘
else:
return False, ‘用户名或密码错误或已锁定‘
else:
return False, ‘登陆的用户名不存在‘
def locked_interface(name):
dic = db_handler.select(name)
if dic:
dic[‘locked‘] = False
db_handler.save(dic)
def register_interface(name, password, balance=15000):
dic = db_handler.select(name)
if dic:
return False, ‘用户名已存在‘
else:
dic = {‘name‘: name, ‘password‘: password, ‘balance‘: balance, ‘credit‘: balance, ‘locked‘: False,
‘bankflow‘: [], ‘shoppingcart‘: {}}
db_handler.save(dic)
user_logger.info(‘%s注册成功‘ % name)
return True, ‘%s注册成功‘ % name
标签:int ret log comm opp 锁定 logger atm false
原文地址:https://www.cnblogs.com/wangcheng9418/p/9221768.html