if request.method == "POST": result = [{"Result": 0, "Message": "指定库位不存在!", "LocationId": "L0023B1002", "LightColor": 96, "Twinkle": 0, "IsLocked": 0, "IsMustCollect": 0, "Quantity": 0, "SubText": None, "BatchCode": None, "Name": None, "R1": None, "R2": None, "R3": None, "SubTitle": None, "Title": None, "Unit": None, "RelateToTower": True }] req = reqparse.RequestParser() req.add_argument('LocationId',type=str, required=True) req.add_argument('LightColor',type=int, required=True) req.add_argument('Twinkle',type=int, required=True) req.add_argument('IsLocked',type=int, required=True) req.add_argument('IsMustCollect',type=int, required=True) req.add_argument('Quantity',type=int, required=True) args = req.parse_args() if args['LightColor'] not in color_json: pass else: material_location_code = MaterialLocation.query.filter(MaterialLocation.location_code == args['LocationId']) if not material_location_code: return jsonify({ 'Result': 0, 'Message': None, 'Details': result }) return jsonify({ "Result": 1, "Message": None, "Details": [] })
时间: 2023-05-22 09:07:10 浏览: 96
如何做好库位规划
这是一个Python的Web应用程序请求,包含参数的解析以及对数据库的查询。如果请求中的LightColor参数不在color_json中,则程序会什么都不做。如果MaterialLocation表中不存在指定的location_code,则返回包含错误信息的JSON响应。否则,返回一个空列表作为详情。
阅读全文