课程: Applied Concurrency in Go

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Extending the Orders app

Solution: Extending the Orders app - Go教程

课程: Applied Concurrency in Go

Solution: Extending the Orders app

(upbeat music) - [Instructor] Let's have a look at my implementation of our final challenge. The aim for this challenge was to implement order reversal. Let's begin with the request reversal method. First, we begin by finding the order with the given ID, and getting it from the orders database on line 158. If no order is found, or if the order status is not completed, then we return an error on line 159 to 164. Next, we set the order status of ReversalRequested to the order on line 166. Finally, just like during order creation, we add a select statement with two cases on line 168. The first case sends the reversal for processing on line 169, while the second case on line 172 respects the done channel, which indicates app closing. We Upsert the order with status ReversalRequested to the database on line 170. This will ensure that the payload returned to the user, as well as additional calls to the Get Order endpoint…

内容