@RequestMapping(value = "/order", method = RequestMethod.POST)
public String buy(Model model, @ModelAttribute("order") Order order) {
model.addAttribute("search", new Search());
// buy the order after setting attributes not set by the UI.
//check if user is logged in!
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!(authentication instanceof AnonymousAuthenticationToken)) {
String currentUserName = authentication.getName();
logger.debug("/order ORDER: " + order);
order.setAccountId(currentUserName);
order.setCompletionDate(new Date());
Order result = marketService.sendOrder(order);
model.addAttribute("savedOrder", result);
model.addAttribute("order", new Order());
try {
model.addAttribute("portfolio",marketService.getPortfolio(currentUserName));
} catch (HttpServerErrorException e) {
model.addAttribute("portfolioRetrievalError",e.getMessage());
}
} else {
//should never get here!!!
}
return "trade";
}
TradeController.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:springBootTrader-aos
作者:
评论列表
文章目录