Example #1
0
 def get_by_name(username):
     user = {'username': username}
     doc = db.query_one('user', user)
     if not doc:
         return Response({})
     return Response(_id=str(doc['_id']),
                     username=doc['username'],
                     password=doc['password'],
                     realValueAll=doc['real_value_all'],
                     profit=doc['profit'],
                     profitPct=doc['profit_pct'])
Example #2
0
 def get(assert_info):
     doc = db.query_one('assert', assert_info)
     if not doc:
         return Response({})
     return Response(_id=doc['_id'],
                     dateTime=doc['date_time'],
                     balanceEth=doc['balance_eth'],
                     balanceBusd=doc['balance_busd'],
                     curPriceETH=doc['cur_price_ETH'],
                     realValueAll=doc['real_value_all'],
                     profit=doc['profit'],
                     profitPct=doc['profit_pct'])
Example #3
0
 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)
Example #4
0
 def get():
     exchange = get_arg('exchange', '')
     query = {}
     if exchange != '':
         query = {'exchange': exchange}
     page_num = int(get_arg('pageNum', 1))
     page_size = int(get_arg('pageSize', 10))
     return Response(account=query, page_num=page_num, page_size=page_size)
Example #5
0
 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={})
Example #6
0
 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)
Example #7
0
 def post():
     json = get_json()
     account = {
         '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)
Example #8
0
 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)
Example #9
0
 def line(num, page_num, page_size):
     if page_num <= 0:
         page_num = 1
     offset = (page_num - 1) * page_size
     data_list = db.query_search_page_sort('assert', {}, page_size, offset,
                                           'date_time')
     data_arr = []
     for i in range(0, len(data_list)):
         if i % num == 0:
             data_arr.append({
                 '_id': str(data_list[i]['_id']),
                 'dateTime': data_list[i]['date_time'],
                 'realValueAll': data_list[i]['real_value_all'],
                 'profit': data_list[i]['profit'],
                 'profitPct': data_list[i]['profit_pct']
             })
     return Response(data=data_arr)
Example #10
0
 def list(assert_info, page_num, page_size):
     total_count = db.query_count('assert', assert_info)
     if page_num <= 0:
         page_num = 1
     offset = (page_num - 1) * page_size
     data_list = db.query_search_page('assert', assert_info, page_size,
                                      offset)
     data_arr = []
     for i in range(0, len(data_list)):
         data_arr.append({
             '_id': str(data_list[i]['_id']),
             'dateTime': data_list[i]['date_time'],
             'realValueAll': data_list[i]['real_value_all'],
             'profit': data_list[i]['profit'],
             'profitPct': data_list[i]['profit_pct']
         })
     return Response(total=total_count,
                     data=data_arr,
                     pageNum=page_num,
                     pageSize=page_size)
Example #11
0
 def list(account, page_num, page_size):
     total_count = db.query_count('account', account)
     if page_num <= 0:
         page_num = 1
     offset = (page_num - 1) * page_size
     data_list = db.query_search_page('account', account, page_size, offset)
     data_arr = []
     for i in range(0, len(data_list)):
         data_arr.append({
             '_id': str(data_list[i]['_id']),
             'exchange': data_list[i]['exchange'],
             'desc': data_list[i]['desc'],
             'key': data_list[i]['key'],
             'secret': data_list[i]['secret'],
             'userId': data_list[i]['user_id'],
         })
     return Response(total=total_count,
                     data=data_arr,
                     pageNum=page_num,
                     pageSize=page_size)
Example #12
0
 def insert(assert_info):
     _id = db.insert_one('assert', assert_info)
     return Response(_id=_id)
Example #13
0
 def bind_assert(user):
     _id = user.get('_id', '')
     assert_id = user.get('assert_id', '')
     UserModel.bind_assert(_id, assert_id)
     return Response(data={})
Example #14
0
 def delete(assert_info):
     doc = db.remove('assert', assert_info)
     if not doc:
         return Response({})
     return Response(_id=doc['_id'])
Example #15
0
 def update(assert_info):
     doc = db.update('assert', assert_info)
     if not doc:
         return Response({})
     return Response(_id=doc['_id'])
Example #16
0
 def get():
     json = get_json()
     assert_info = {
         '_id': json.get('_id', ''),
     }
     return Response(assert_info=assert_info)
Example #17
0
 def post():
     json = get_json()
     page_num = int(json.get('pageNum', 1))
     num = int(json.get('num', 2))
     page_size = int(json.get('pageSize', 10))
     return Response(num=num, page_num=page_num, page_size=page_size)
Example #18
0
 def update(assert_info):
     if not assert_info:
         abort(400, **get_result(code=400, msg='参数错误'))
     AssertInfoModel.update(assert_info)
     return Response(data={})
Example #19
0
 def line(num, page_num, page_size):
     data = AssertInfoModel.line(num, page_num, page_size)
     return Response(data=data)
Example #20
0
 def update(account):
     if not account:
         abort(400, **get_result(code=400, msg='参数错误'))
     AccountModel.update(account)
     return Response(data={})
Example #21
0
 def delete(account):
     db.delete_one('account', account)
     return Response({})
Example #22
0
 def insert(account):
     _id = db.insert_one('account', account)
     return Response(_id=_id)
Example #23
0
 def update(account):
     doc = db.update('account', account)
     if not doc:
         return Response({})
     return Response(_id=doc['_id'])
Example #24
0
 def get(assert_info):
     if not assert_info:
         abort(400, **get_result(code=400, msg='参数错误'))
     doc = AssertInfoModel.get(assert_info)
     return Response(data=doc)
Example #25
0
 def list(assert_info, page_num, page_size):
     page = AssertInfoModel.list(assert_info, page_num, page_size)
     return Response(data=page)
Example #26
0
 def list(account, page_num, page_size):
     page = AccountModel.list(account, page_num, page_size)
     return Response(data=page)