def get(self): parser = CustomRequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('currency', type=str, location='args') parsed_args = parser.parse_args() wallet = Wallet.query.filter( Wallet.user_id == g.current_user.id, Wallet.currency_id != 'USDT', Wallet.currency_id != 'DASH', Wallet.currency_id != 'BTG', Wallet.currency_id != 'BCH', ) if parsed_args['currency']: wallet = wallet.filter_by(currency_id=parsed_args['currency']) wallet_list = pagination_query(parsed_args['per_page'], parsed_args['page'], wallet) objects = [] sort_currency = ['BTC', 'ETH', 'LTC'] for currency in sort_currency: for item in wallet_list['objects']: if item.currency_id == currency: objects.append(item) break wallet_list['objects'] = objects Wallet.query_wallet(wallet_list['objects']) return wallet_list
def get(self): parser = CustomRequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('user_id', type=str, location='args') parser.add_argument( 'type', type=int, choices=(g_payment_type.BANK, g_payment_type.WECHAT, g_payment_type.ALIPAY, g_payment_type.USDT), location='args') parser.add_argument('invalid', type=int, default=0, location='args') parsed_args = parser.parse_args() q = Payment.query if parsed_args['user_id'] is not None: q = q.filter(Payment.user_id == parsed_args['user_id']) if parsed_args['type'] is not None: q = q.filter(Payment.type == parsed_args['type']) if parsed_args['invalid'] is not None: q = q.filter(Payment.invalid == parsed_args['invalid']) q = q.order_by(Payment.created_at.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = reqparse.RequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('number', type=str, location='args') parser.add_argument('side', type=int, choices=(g_order_side.BUY, g_order_side.SELL), location='args') parser.add_argument('status', type=int, location='args') parsed_args = parser.parse_args() q = Order.query q = q.filter(Order.status != g_order_status.DELETE) q = q.filter(Order.user_id == g.current_user.id) if parsed_args['side'] is not None: q = q.filter(Order.side == parsed_args['side']) if parsed_args['status']: q = q.filter(Order.status.op('&')(parsed_args['status']) != 0) if parsed_args['number']: q = q.filter(Order.number.contains(parsed_args['number'])) q = q.order_by(Order.id.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = CustomRequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('assets_type', type=int, location='args') parser.add_argument('record_type', type=int, location='args') parser.add_argument('create_begin_timestamp', type=int, location='args') parser.add_argument('create_end_timestamp', type=int, location='args') # delta_amount_flag用来查找兑换中大于0的记录 如果为1则查找 parser.add_argument('delta_amount_flag', type=int, location='args') parsed_args = parser.parse_args() q = AssetsBalanceRecord.query q = q.filter_by(user_id=g.current_user.id) if parsed_args['assets_type']: q = q.filter(AssetsBalanceRecord.assets_type.op('&')(parsed_args['assets_type'])) if parsed_args['record_type']: q = q.filter(AssetsBalanceRecord.record_type.op('&')(parsed_args['record_type'])) if parsed_args['create_begin_timestamp'] is not None: create_begin_datetime = timestamp_to_datetime(parsed_args['create_begin_timestamp']) q = q.filter(AssetsBalanceRecord.created_at >= create_begin_datetime) if parsed_args['create_end_timestamp'] is not None: create_end_datetime = timestamp_to_datetime(parsed_args['create_end_timestamp']) q = q.filter(AssetsBalanceRecord.created_at < create_end_datetime) if parsed_args['delta_amount_flag'] is not None: if parsed_args['delta_amount_flag']: q = q.filter(AssetsBalanceRecord.delta_amount > 0) q = q.order_by(AssetsBalanceRecord.id.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = CustomRequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parsed_args = parser.parse_args() q = LoginInfo.query.filter_by(user_id=g.current_user.id) q = q.order_by(LoginInfo.created_at.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = reqparse.RequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('number', type=str, location='args') parser.add_argument('uid', type=str, location='args') parser.add_argument('name', type=str, location='args') parser.add_argument('mobile', type=str, location='args') parser.add_argument('side', type=int, choices=(g_order_side.BUY, g_order_side.SELL), location='args') parser.add_argument('status', type=int, location='args') parser.add_argument('created_begin_timestamp', type=int, location='args') parser.add_argument('created_end_timestamp', type=int, location='args') parsed_args = parser.parse_args() q = Order.query if parsed_args['side'] is not None: q = q.filter(Order.side == parsed_args['side']) if parsed_args['status']: q = q.filter(Order.status.op('&')(parsed_args['status']) != 0) if parsed_args['uid']: q = q.filter(Order.user.has(User.uid.contains(parsed_args['uid']))) if parsed_args['name']: q = q.filter( Order.user.has(User.name.contains(parsed_args['name']))) if parsed_args['mobile']: q = q.filter(Order.user.has(User.mobile == parsed_args['mobile'])) if parsed_args['number']: q = q.filter(Order.number.contains(parsed_args['number'])) if parsed_args['created_begin_timestamp']: if not parsed_args['created_end_timestamp']: parsed_args['created_end_timestamp'] = int(time.time()) begin_timestamp = min(parsed_args['created_begin_timestamp'], parsed_args['created_end_timestamp']) end_timestamp = max(parsed_args['created_begin_timestamp'], parsed_args['created_end_timestamp']) q = q.filter( db.and_( Order.created_at >= timestamp_to_datetime(begin_timestamp), Order.created_at < timestamp_to_datetime(end_timestamp))) q = q.order_by(Order.id.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = reqparse.RequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parsed_args = parser.parse_args() news = News.query news = news.order_by(News.created_at.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], news)
def get(self): parser = reqparse.RequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('assets_type', type=int, location='args') parser.add_argument('mobile', type=str, location='args') parser.add_argument('record_type', type=int, location='args') parser.add_argument('amount_type', type=int, choices=(0, 1, 2), location='args') parser.add_argument('created_begin_timestamp', type=int, location='args') parser.add_argument('created_end_timestamp', type=int, location='args') parsed_args = parser.parse_args() q = AssetsBalanceRecord.query if parsed_args['mobile']: q = q.filter( AssetsBalanceRecord.user.has( User.mobile == parsed_args['mobile'])) if parsed_args['amount_type']: if parsed_args['amount_type'] == 1: q = q.filter(AssetsBalanceRecord.delta_amount >= 0) if parsed_args['amount_type'] == 2: q = q.filter(AssetsBalanceRecord.delta_amount < 0) if parsed_args['assets_type']: q = q.filter( AssetsBalanceRecord.assets_type.op('&')( parsed_args['assets_type'])) if parsed_args['record_type']: q = q.filter( AssetsBalanceRecord.record_type.op('&')( parsed_args['record_type'])) if parsed_args['created_begin_timestamp'] is not None: create_begin_datetime = timestamp_to_datetime( parsed_args['created_begin_timestamp']) q = q.filter( AssetsBalanceRecord.created_at >= create_begin_datetime) if parsed_args['created_end_timestamp'] is not None: create_end_datetime = timestamp_to_datetime( parsed_args['created_end_timestamp']) q = q.filter(AssetsBalanceRecord.created_at < create_end_datetime) q = q.order_by(AssetsBalanceRecord.id.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = CustomRequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('uid', type=str, location='args') parser.add_argument('mobile', type=str, location='args') parsed_args = parser.parse_args() q = Assets.query if parsed_args['uid']: q = q.filter(Assets.user.has(User.uid.contains( parsed_args['uid']))) if parsed_args['mobile']: q = q.filter( Assets.user.has(User.mobile.contains(parsed_args['mobile']))) q = q.order_by(Assets.id.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = reqparse.RequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('role', type=int, choices=(1, 2), default=2, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parsed_args = parser.parse_args() q = AdminUser.query q = q.filter(AdminUser.id != g.current_user.id) if parsed_args['role']: q = q.filter(AdminUser.role == parsed_args['role']) q = q.order_by(AdminUser.created_at.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = CustomRequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('create_begin_timestamp', type=int, location='args') parser.add_argument('create_end_timestamp', type=int, location='args') parsed_args = parser.parse_args() q = CurrencyPriceRecord.query if parsed_args['create_begin_timestamp'] is not None: create_begin_datetime = timestamp_to_datetime( parsed_args['create_begin_timestamp']) q = q.filter( CurrencyPriceRecord.created_at >= create_begin_datetime) if parsed_args['create_end_timestamp'] is not None: create_end_datetime = timestamp_to_datetime( parsed_args['create_end_timestamp']) q = q.filter(CurrencyPriceRecord.created_at < create_end_datetime) q = q.order_by(CurrencyPriceRecord.id.asc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = CustomRequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('currency', type=str, location='args') parser.add_argument('status', type=int, location='args') parser.add_argument('type', type=int, location='args') parsed_args = parser.parse_args() q = TransferOrder.query.filter( db.or_(TransferOrder.user_id == g.current_user.id, TransferOrder.to_user_id == g.current_user.id)) if parsed_args['currency']: q = q.filter(TransferOrder.currency_id == parsed_args['currency']) if parsed_args['status'] is not None: q = q.filter( TransferOrder.status.op('&')(parsed_args['status']) != 0) if parsed_args['type']: q = q.filter(TransferOrder.type == parsed_args['type']) q = q.order_by(TransferOrder.created_at.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)
def get(self): parser = reqparse.RequestParser() parser.add_argument('page', type=int, default=1, location='args') parser.add_argument('per_page', type=int, default=5, location='args') parser.add_argument('locked', type=int, choices=(0, 1, 2), location='args') parser.add_argument('name', type=str, location='args') parser.add_argument('nickname', type=str, location='args') parser.add_argument('uid', type=str, location='args') parser.add_argument('sponsor', type=str, location='args') parser.add_argument('mobile', type=str, location='args') parser.add_argument('wechat', type=str, location='args') parser.add_argument('state', type=str, location='args') parser.add_argument('allow_transaction', type=int, choices=(0, 1), location='args') parser.add_argument('is_community_node', type=int, choices=(0, 1), location='args') parser.add_argument('transaction_level', type=int, choices=(g_user_transaction_level.NORMAL, g_user_transaction_level.PRIORITY, g_user_transaction_level.ULTIMATE), location='args') parser.add_argument('created_begin_timestamp', type=int, location='args') parser.add_argument('created_end_timestamp', type=int, location='args') parsed_args = parser.parse_args() q = User.query.filter(User.locked != 2) if parsed_args['name']: q = q.filter(User.name.contains(parsed_args['name'])) if parsed_args['nickname']: q = q.filter(User.nickname.contains(parsed_args['nickname'])) if parsed_args['uid']: q = q.filter(User.uid.contains(parsed_args['uid'])) if parsed_args['mobile']: q = q.filter(User.mobile.contains(parsed_args['mobile'])) if parsed_args['wechat']: q = q.filter(User.wechat.contains(parsed_args['wechat'])) if parsed_args['sponsor']: q = q.filter( User.sponsor.has(User.mobile.contains(parsed_args['sponsor']))) if parsed_args['locked'] is not None: q = q.filter(User.locked == parsed_args['locked']) if parsed_args['state']: q = q.filter(User.state == parsed_args['state']) if parsed_args['is_community_node'] is not None: q = q.filter( User.is_community_node == parsed_args['is_community_node']) if parsed_args['allow_transaction'] is not None: q = q.filter( User.allow_transaction == parsed_args['allow_transaction']) if parsed_args['transaction_level'] is not None: q = q.filter( User.transaction_level == parsed_args['transaction_level']) if parsed_args['is_community_node'] is not None: q = q.filter( User.is_community_node == parsed_args['is_community_node']) if parsed_args['created_begin_timestamp']: if not parsed_args['created_end_timestamp']: parsed_args['created_end_timestamp'] = int(time.time()) begin_timestamp = min(parsed_args['created_begin_timestamp'], parsed_args['created_end_timestamp']) end_timestamp = max(parsed_args['created_begin_timestamp'], parsed_args['created_end_timestamp']) q = q.filter( db.and_( User.created_at >= timestamp_to_datetime(begin_timestamp), User.created_at < timestamp_to_datetime(end_timestamp))) q = q.order_by(User.created_at.desc()) return pagination_query(parsed_args['per_page'], parsed_args['page'], q)