PageRenderTime 77ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/Server/tomcat/WEB-INF/src/com/drhelper/android/service/LoadOrderService.java

https://github.com/weiganyi/dr-helper
Java | 50 lines | 36 code | 9 blank | 5 comment | 4 complexity | 544408240221042bb514b71f66dd7eee MD5 | raw file
  1. package com.drhelper.android.service;
  2. import javax.servlet.http.HttpSession;
  3. import com.alibaba.fastjson.JSON;
  4. import com.drhelper.android.bean.com.OrderInfo;
  5. import com.drhelper.common.db.DBManager;
  6. import com.drhelper.common.entity.Order;
  7. public class LoadOrderService extends Service {
  8. public String doAction(HttpSession session, String reqBody) {
  9. OrderInfo reqOrder = null;
  10. OrderInfo respOrder = null;
  11. String respBody = null;
  12. //parse the body
  13. try{
  14. reqOrder = JSON.parseObject(reqBody, OrderInfo.class);
  15. }catch (Exception e) {
  16. System.out.println("LoadOrderService.doAction(): json parse body failure: " + e.getMessage());
  17. return respBody;
  18. }
  19. //check the input param
  20. int orderNum = reqOrder.getOrder().getOrder();
  21. if (orderNum == 0) {
  22. System.out.println("LoadOrderService.doAction(): orderNum is null");
  23. return respBody;
  24. }
  25. respOrder = new OrderInfo();
  26. //fetch the order
  27. DBManager db = new DBManager();
  28. Order order = db.getOrderObjByOrder(orderNum);
  29. if (order == null) {
  30. respOrder.setResult(false);
  31. respBody = JSON.toJSONString(respOrder);
  32. return respBody;
  33. }
  34. //create the resp object
  35. respOrder.setOrder(order);
  36. respOrder.setResult(true);
  37. //serialize the object
  38. respBody = JSON.toJSONString(respOrder);
  39. return respBody;
  40. }
  41. }