Example #1
0
def update():
    hotelId = request.form.get("hotelId")
    if (hotelId is None):
        return ResData.paramEmpty(hotelId)
    hotel = Hotel.query.filter(Hotel.hotelId == hotelId).first()

    address = request.form.get('address')
    hotelName = request.form.get('hotelName')
    price = request.form.get('price')
    score = request.form.get('score')
    number = request.form.get('number')
    hotelId = request.form.get('hotelId')
    introduction = request.form.get('introduction')
    pic = request.form.get('pic')

    hotel.address = address
    hotel.hotelName = hotelName
    hotel.price = price
    hotel.score = score
    hotel.number = number
    hotel.hotelId = hotelId
    hotel.introduction = introduction
    hotel.pic = pic

    db.session.add(hotel)
    db.session.commit()
    return ResData.success(None)
Example #2
0
def update():
    flightId = request.form.get("flightId")
    if (flightId is None):
        return ResData.paramEmpty(flightId)
    flight = Flight.query.filter(Flight.flightId == flightId).first()

    startingPlace = request.form.get('startingPlace')
    endPlace = request.form.get('endPlace')
    startTime = request.form.get('startTime')
    endTime = request.form.get('endTime')
    flightNumber = request.form.get('flightNumber')
    price = request.form.get('price')
    flightName = request.form.get('flightName')
    number = request.form.get('number')

    flight.startingPlace = startingPlace
    flight.endPlace = endPlace
    flight.startTime = startTime
    flight.endTime = endTime
    flight.flightNumber = flightNumber
    flight.price = price
    flight.flightName = flightName
    flight.number = number

    db.session.add(flight)
    db.session.commit()
    return ResData.success(None)
Example #3
0
def delete():
    hotelId = request.form.get('hotelId')
    if (hotelId is None):
        return ResData.paramEmpty(hotelId)
    hotel = Hotel.query.filter(Hotel.hotelId == hotelId).first()
    db.session.delete(hotel)
    db.session.commit()
    return ResData.success(None)
Example #4
0
def delete():
    flightId = request.form.get('flightId')
    if (flightId is None):
        return ResData.paramEmpty(flightId)
    flight = Flight.query.filter(Flight.flightId == flightId).first()
    db.session.delete(flight)
    db.session.commit()
    return ResData.success(None)
Example #5
0
def delete():
    postRecordId = request.form.get('postRecordId')
    if (postRecordId is None):
        return ResData.paramEmpty(postRecordId)
    postRecord = PostRecord.query.filter(
        PostRecord.postId == postRecordId).first()
    db.session.delete(postRecord)
    db.session.commit()
    return ResData.success(None)
Example #6
0
def queryByPostRecordId():
    postRecordId = request.form.get('postRecordId')
    if (postRecordId is None):
        return ResData.paramEmpty(postRecordId)
    postRecord = PostRecord.query.filter(
        PostRecord.postId == postRecordId).first()
    res = postRecord.to_json()
    replys = querReplyByPostRecordId(postRecordId)
    postRecordList = []
    for one in replys:
        postRecordList.append(one.to_json())
    res["postRecords"] = postRecordList
    return make_response(ResData.success(res))
Example #7
0
def buy():
    userName = request.cookies.get('username')
    if (userName is None):
        return ResData.needLogin(userName)
    hotelId = request.form.get('hotelId')
    if (hotelId is None):
        return ResData.paramEmpty(hotelId)
    hotel = Hotel.query.filter(Hotel.hotelId == hotelId).first()
    Hotel.number = Hotel.number - 1

    userBuyRecord = UserBuyRecord()
    userBuyRecord.productId = hotelId
    userBuyRecord.productType = "hotel"
    userBuyRecord.userName = userName

    db.session.add(hotel)
    db.session.add(userBuyRecord)
    db.session.commit()
    return ResData.success(None)
Example #8
0
def buy():
    flightId = request.form.get('flightId')
    userName = request.cookies.get('username')
    if (userName is None):
        return ResData.needLogin(flightId)
    if (flightId is None):
        return ResData.paramEmpty(flightId)
    flight = Flight.query.filter(Flight.flightId == flightId).first()
    flight.number = flight.number - 1

    userBuyRecord = UserBuyRecord()
    userBuyRecord.productId = flightId
    userBuyRecord.productType = "flight"
    userBuyRecord.userName = userName

    db.session.add(flight)
    db.session.add(userBuyRecord)
    db.session.commit()
    return ResData.success(None)