Пример #1
0
def get_area_by_code():
    args = request.args
    code = args.get("code")
    return_data = {"retCode": "0000", "retMsg": ""}
    if code == None:
        return_data = {"retCode": "3000", "retMsg": "code为空"}
    else:
        data = ResidentialAreas.get_area_info(area_id=code)
        if data:
            return_data["cellList"] = data["cellList"]

    return jsonify(return_data)
Пример #2
0
def get_areas():
    residential_areas = ResidentialAreas.get_areas()
    result = {}
    final_return = None
    try:
        for r in residential_areas:
            if result.has_key(r.zone_id):
                result[r.zone_id]["areaList"].append({"areaID": r.id, "areaName": r.area_name})
            else:
                result[r.zone_id] = {
                    "zoneID": r.zone_id,
                    "zoneName": r.zone.area_name,
                    "areaList": [{"areaID": r.id, "areaName": r.area_name}],
                }
        data = list()
        for key in result.keys():
            data.append(result[key])

        final_return = {"retCode": "0000", "retMsg": "", "zoneList": data}
    except Exception, ex:
        final_return = {"retCode": "5000", "retMsg": ex.message}