def selectlimitOrders(goodsId): purchaseOrders = to_json( Purchase.query.filter(Purchase.good_id.in_(goodsId)).all()) for purchaseOrder in purchaseOrders: purchaseOrder['good_name'] = Category.query.get( purchaseOrder['good_id']).name return purchaseOrders
def categoryDetails(id): # 查询当前类别的子类别对象列表,并转换成子类型字典列表 children = to_json(Category.query.filter_by(parent=id).all()) # 遍历并进行递归 for child in children: if child['level'] < 4: child['children'] = categoryDetails(child['id']) return children
def details(): purchaseOrders = to_json(Purchase.query.all()) for purchaseOrder in purchaseOrders: purchaseOrder['good_name'] = Category.query.get( purchaseOrder['good_id']).name purchaseOrder['supplier_name'] = Supplier.query.get( purchaseOrder['supplier_id']).name return purchaseOrders
def GetMenuListJson(page=1): if request.method == 'POST': print('post') if request.method == 'GET': menus = Menus.query.all() # users = User.query.all() # print(users.single_to_dict()) return jsonify(to_json(menus))
def GetUserFormJson(): data = {'Tag': 0, "Message": "", "Data": ""} id = request.args.get("id") if id != '': data["Tag"] = 1 data["Message"] = "操作成功" menu = User.query.filter(User.Id == id).all() data["Data"] = to_json(menu)[0] return jsonify(data)
def GetPositionListJson(): data = {'Tag': 0, "Message": "", "Data": ""} page = request.args.get("pageIndex", type=int) per_page = request.args.get("pageSize", type=int) if id != '': data["Tag"] = 1 data["Message"] = "操作成功" PositionName = request.args.get("PositionName") filterList = ConditionQuery.queryList( x1={Position.PositionName: PositionName}) menu = Position.query.filter(*filterList).paginate(page, per_page) data["Total"] = menu.pages data["Data"] = to_json(menu.items) return jsonify(data)
def topCats(): cats = to_json(Category.query.filter_by(parent=0).all()) return cats
def details(): sales = to_json(Sale.query.all()) for sale in sales: sale['good_name'] = Good.query.get(sale['good_id']).name return sales
def details(): stocks = to_json(Stock.query.all()) for stock in stocks: stock['good_name'] = Good.query.get(stock['good_id']).name return stocks
def details(): suppliers = Supplier.query.all() if len(suppliers) == 0: return None else: return to_json(suppliers)
def searchByPosition(province, city): suppliers = Supplier.query.filter( and_(Supplier.province.like('%' + province + '%'), Supplier.city.like('%' + city + '%'))).all() return to_json(suppliers)
def fuzzySearch(text): suppliers = Supplier.query.filter( or_(Supplier.name.like('%' + text + '%'), Supplier.mobile.like('%' + text + '%'))).all() return to_json(suppliers)
def details(role_name): role = Role.query.filter_by(name=role_name).first() if role == None: return None else: return to_json(role.users.all())
def selectOrders(): orders = to_json(Order.query.all()) for order in orders: order['good_name'] = Category.query.get(order['good_id']).name return orders