[英]Keep State of Transaction
我有2种webservice方法:
RentCar()
{
// Here, i will generate an ID called TransactionID
// Insert the "TransactionID" into mysql table called Transactions, with another field called RentTime.
}
ReturnCar()
{
// At some point in time, the user returns the Car.
// But now i need the "TransactionID" that was generated from RentCar() method.
// So i could edit the Transactions Table to update a certain field called returnTime.
// Is that possible ?
}
我知道可能的一种方法是创建一个临时表并将RentCar()的值存储到其中。 然后,当用户退车时,我现在从temp删除值,并转移到包含returntime(now)的 TransactionTable中 。
考虑一下它在现实生活中的工作方式:
你租车。 租车公司在交易表中创建一个记录,其中包含已租车的ID, 并为您提供汽车 。
一个星期后,你坐车回来。 租赁公司在交易表中搜索包含退回汽车ID的记录,现在可以将此记录标记为退回。
因此,在您的代码中,只需做同样的事情:从rentCar()
服务返回一个交易ID,并将其作为returnCar()
服务的参数。 您不是在“返回”。 您将退回由transactionID标识的特定汽车 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.