def login(user): username = user.get('username', '') password = user.get('password', '') u = UserModel.get_by_name(username) if not u: abort(500, **get_result(code=500, msg='账号或密码错误')) if password != u['password']: abort(500, **get_result(code=500, msg='账号或密码错误')) return Response(data=u)
def delete(): json = get_json() _id = json.get('_id', '') if _id == '': abort(400, **get_result(code=400, msg='参数错误')) account = {'_id': _id} return Response(account=account)
def reg(user): username = user.get('username', '') password = user.get('password', '') u = UserModel.get_by_name(username) if u: abort(500, **get_result(code=500, msg='该用户已存在')) UserModel.insert(username, password) return Response(data={})
def put(): json = get_json() _id = json.get('_id', '') if _id == '': abort(400, **get_result(code=400, msg='参数错误')) account = { '_id': _id, 'exchange': json.get('exchange', ''), 'desc': json.get('desc', ''), 'key': json.get('key', ''), 'secret': json.get('secret', ''), 'user_id': json.get('userId', '') } return Response(account=account)
def update(assert_info): if not assert_info: abort(400, **get_result(code=400, msg='参数错误')) AssertInfoModel.update(assert_info) return Response(data={})
def get(assert_info): if not assert_info: abort(400, **get_result(code=400, msg='参数错误')) doc = AssertInfoModel.get(assert_info) return Response(data=doc)
def update(account): if not account: abort(400, **get_result(code=400, msg='参数错误')) AccountModel.update(account) return Response(data={})