PageRenderTime 65ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/weiganyi/dr-helper
Java | 44 lines | 30 code | 9 blank | 5 comment | 2 complexity | 238a292554635ceb8c97c4e35e8fb48d 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 DeleteOrderService 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("DeleteOrderService.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("DeleteOrderService.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.deleteOrder(order);
  29. //create the resp object
  30. respOrder.setResult(result);
  31. //serialize the object
  32. respBody = JSON.toJSONString(respOrder);
  33. return respBody;
  34. }
  35. }