PageRenderTime 3539ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/weiganyi/dr-helper
Java | 44 lines | 30 code | 9 blank | 5 comment | 2 complexity | d1dbbd67cd42576243ec0b3b082af2b0 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 SubmitOrderService 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("SubmitOrderService.doAction(): json parse body failure: " + e.getMessage());
  17. return respBody;
  18. }
  19. //check the input param
  20. Order order = reqOrder.getOrder();
  21. if (order == null) {
  22. System.out.println("SubmitOrderService.doAction(): order is null");
  23. return respBody;
  24. }
  25. respOrder = new OrderInfo();
  26. //submit the order
  27. DBManager db = new DBManager();
  28. boolean result = db.submitOrder(order);
  29. //create the resp object
  30. respOrder.setResult(result);
  31. //serialize the object
  32. respBody = JSON.toJSONString(respOrder);
  33. return respBody;
  34. }
  35. }