码迷,mamicode.com
首页 > 其他好文 > 详细

ATM-interface-user

时间:2018-06-24 21:38:34      阅读:171      评论:0      收藏:0      [点我收藏+]

标签: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

ATM-interface-user

标签:int   ret   log   comm   opp   锁定   logger   atm   false   

原文地址:https://www.cnblogs.com/wangcheng9418/p/9221768.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!