Advertisement
Guest User

Untitled

a guest
May 17th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. package com.axisj.axboot.admin.controllers;
  2.  
  3. import com.axisj.axboot.admin.parameter.CommonListResponseParams;
  4. import com.axisj.axboot.admin.parameter.PageableResponseParams;
  5. import com.axisj.axboot.core.api.response.ApiResponse;
  6. import com.axisj.axboot.core.controllers.BaseController;
  7. import com.axisj.axboot.core.domain.order.Order;
  8. import com.axisj.axboot.core.domain.order.OrderService;
  9. import com.axisj.axboot.core.domain.order.OrderVO;
  10. import com.axisj.axboot.core.domain.sample.parent.ParentSample;
  11. import com.axisj.axboot.core.domain.sample.parent.ParentSampleService;
  12. import com.axisj.axboot.core.domain.sample.parent.ParentSampleVO;
  13. import org.springframework.data.domain.Page;
  14. import org.springframework.data.domain.PageRequest;
  15. import org.springframework.web.bind.annotation.*;
  16. import org.springframework.stereotype.Controller;
  17. import org.springframework.data.domain.Pageable;
  18.  
  19. import javax.inject.Inject;
  20. import java.sql.Connection;
  21. import java.sql.DriverManager;
  22. import java.sql.PreparedStatement;
  23. import java.sql.ResultSet;
  24. import java.util.ArrayList;
  25. import java.util.List;
  26.  
  27.  
  28. @Controller
  29. @RequestMapping(value = "/api/v1/orders")
  30. public class OrderController extends BaseController {
  31.  
  32. @Inject
  33. private OrderService orderService;
  34.  
  35. @Inject
  36. private ParentSampleService parentService;
  37.  
  38.  
  39. @RequestMapping(value = "/order", method = RequestMethod.GET, produces = APPLICATION_JSON)
  40. public PageableResponseParams.PageResponse list(Pageable pageable) {
  41. Page<Order> orderPage = orderService.findAll(pageable);
  42. return PageableResponseParams.PageResponse.of(OrderVO.of(orderPage.getContent()), orderPage);
  43. }
  44.  
  45. /*
  46. @RequestMapping(value = "/test", method = RequestMethod.GET, produces = APPLICATION_JSON)
  47. public OrderVO orderVO(String orderUserNm){
  48. OrderVO orderVO = new OrderVO();
  49.  
  50. String url = "jdbc:mysql://14.63.169.27:3306/test";
  51. String id = "jhma";
  52. String pass = "jhma";
  53. Connection con = null;
  54. String SQL = "SELECT * FROM TB_ORDER WHERE ORDER_CD = '" + 1 + "'";
  55. PreparedStatement pstmt = null;
  56. ResultSet rs = null;
  57.  
  58. try {
  59. Class.forName("com.mysql.jdbc.Driver");
  60. con = DriverManager.getConnection(url, id, pass);
  61.  
  62.  
  63. pstmt = con.prepareStatement(SQL);
  64. rs = pstmt.executeQuery();
  65.  
  66. while(rs.next()){
  67. orderVO.setOrderCd(rs.getInt(1));
  68. orderVO.setOrderUserNm(rs.getString(2));
  69. orderVO.setAcceptedOrnot(rs.getInt(3));
  70. orderVO.setManagedOrnot(rs.getInt(4));
  71. orderVO.setTicketCd(rs.getInt(5));
  72. orderVO.setOrderCnt(rs.getInt(6));
  73. }
  74. }catch(Exception e){
  75. e.printStackTrace();
  76. }
  77. return orderVO;
  78. }
  79. */
  80. @RequestMapping(value = "/tests", method = RequestMethod.GET, produces = APPLICATION_JSON)
  81. public ArrayList<OrderVO> orderVOs(String orderUserNm) {
  82. ArrayList<OrderVO> orderVOs = new ArrayList<OrderVO>();
  83.  
  84. String url = "jdbc:mysql://14.63.169.27:3306/test";
  85. String id = "jhma";
  86. String pass = "jhma";
  87. Connection con = null;
  88. String SQL = "SELECT * FROM TB_ORDER";
  89. PreparedStatement pstmt = null;
  90. ResultSet rs = null;
  91.  
  92. try {
  93. Class.forName("com.mysql.jdbc.Driver");
  94. con = DriverManager.getConnection(url, id, pass);
  95.  
  96.  
  97. pstmt = con.prepareStatement(SQL);
  98. rs = pstmt.executeQuery();
  99.  
  100. while (rs.next()) {
  101. OrderVO orderVO = new OrderVO();
  102.  
  103. orderVO.setOrderCd(rs.getInt(1));
  104. orderVO.setOrderUserNm(rs.getString(2));
  105. orderVO.setAcceptedOrnot(rs.getInt(3));
  106. orderVO.setManagedOrnot(rs.getInt(4));
  107. orderVO.setTicketCd(rs.getInt(5));
  108. orderVO.setOrderCnt(rs.getInt(6));
  109.  
  110. orderVOs.add(orderVO);
  111. }
  112. } catch (Exception e) {
  113. e.printStackTrace();
  114. }
  115. return orderVOs;
  116. }
  117.  
  118. @RequestMapping(method = {RequestMethod.PUT}, produces = APPLICATION_JSON)
  119. public Order save(@RequestBody Order request) {
  120. orderService.save(request);
  121. return request;
  122. }
  123.  
  124.  
  125. @RequestMapping(value = "/parent", method = RequestMethod.GET, produces = APPLICATION_JSON)
  126. public PageableResponseParams.PageResponse parentList(Pageable pageable) {
  127. Page<ParentSample> pages = parentService.findAll(pageable);
  128. return PageableResponseParams.PageResponse.of(ParentSampleVO.of(pages.getContent()), pages);
  129. }
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement