コード例 #1
0
def table_ins():
    requestJson = request.get_json(force=True)
    #if ('roomtype' in list(requestJson.keys()) and requestJson['roomtype'] is not None):
        #roomType = RoomType.query.filter_by(id=requestJson['roomtype'])
        #if (roomType is not None):
            #for key in Room.__table__.columns.keys():
                #if (key not in list(requestJson.keys()) and key != "guid"):
                    #requestJson[key] = roomType[key]
    if ('pricechd' not in list(requestJson.keys())):
        requestJson['pricechd'] = requestJson['price']
    item = Room(**requestJson)
    item.guid = item.guid or uuid.uuid4()
    db.session.add(item)
    db.session.commit()
    return dataResultSuccess(item.to_dict(), code=201, spuriousParameters=list(request.args.to_dict().keys()))