Example #1
0
def check_storage(model, color):
    storage = Storage.select().where(Storage.model == model,
                                     Storage.color == color).get()
    if storage and storage.num > 0:
        return True
    else:
        return False
Example #2
0
def get_storage(model):
    """通过车型获取 该车型所有库存分类

    :param model:
    :type model:
    :return: 该车型所有库存
    :rtype: json
    """
    storage = Storage.select().where(Storage.model == model)
    return storage
Example #3
0
def get_storage_total(model):
    """通过车型获取 该车型库存总数

    :param model:
    :type model:
    :return:
    :rtype:
    """
    storage = Storage.select().where(Storage.model == model)
    count = 0
    for one in storage:
        count += one.num
    return count
Example #4
0
def modify_num(model, color, num):
    """

    :param model:
    :type model:
    :param color:
    :type color:
    :param num:
    :type num:
    :return: number of row update, 0 if not find, error if modify_json is wrong
    :rtype: int
    """
    query = Storage.update(num=num).where(Storage.model == model,
                                          Storage.color == color)
    return query.execute()
Example #5
0
def add(**kwargs):
    """
    add storage
    eg = {
    "model": "E100小龟",
    "color": "红",
    "num": 50

    }
    :param kwargs:
    :type kwargs:
    :return: the added json
    :rtype: json
    """
    store_list = Storage.create(**kwargs)
    return store_list
Example #6
0
def get_by_model_color(model, color):
    storage = Storage.select().where(Storage.model == model, color == color)
    return storage
Example #7
0
def get_by_id(store_list_id):
    return Storage.get(Storage.id == store_list_id)
Example #8
0
def count_all():
    count = Storage.select().count()
    return count
Example #9
0
def get_all_paginate(page, paginate_by):
    storage = Storage.select().paginate(page, paginate_by)
    return storage
Example #10
0
def get_all():
    storage = Storage.select()
    return storage
Example #11
0
def get(*query, **kwargs):
    store_list = Storage.get(*query, **kwargs)
    return store_list
Example #12
0
def increment_num(model, color):
    query = Storage.update(num=Storage.num + 1) \
        .where(Storage.model == model, Storage.color == color)
    return query.execute()