ConsoleRest.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.java110.console.rest;
  2. import com.java110.common.constant.ResponseConstant;
  3. import com.java110.common.exception.SMOException;
  4. import com.java110.common.factory.DataTransactionFactory;
  5. import com.java110.console.smo.IConsoleServiceSMO;
  6. import com.java110.core.base.controller.BaseController;
  7. import com.java110.entity.service.PageData;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. import org.springframework.web.bind.annotation.RestController;
  12. import javax.servlet.http.HttpServletRequest;
  13. /**
  14. * Created by wuxw on 2018/5/8.
  15. */
  16. @RestController
  17. public class ConsoleRest extends BaseController {
  18. @Autowired
  19. private IConsoleServiceSMO consoleServiceSMOImpl;
  20. @RequestMapping(path = "/console/queryTemplateCol",method = RequestMethod.POST)
  21. public String queryTemplateCol(HttpServletRequest request){
  22. PageData pd = null;
  23. try {
  24. pd = this.getPageData(request);
  25. // 判断用户是否登录
  26. checkLogin(pd);
  27. consoleServiceSMOImpl.getTemplateCol(pd);
  28. }catch (IllegalArgumentException e){
  29. return DataTransactionFactory.pageResponseJson(pd, ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
  30. }catch (SMOException e){
  31. return DataTransactionFactory.pageResponseJson(pd,e.getResult().getCode(),e.getMessage(),null);
  32. }catch (Exception e){
  33. logger.error("异常信息:",e);
  34. return DataTransactionFactory.pageResponseJson(pd,ResponseConstant.RESULT_CODE_ERROR,"请求参数出错 ",null);
  35. }
  36. return pd.getResJson().toJSONString();
  37. }
  38. /**
  39. * 获取模板数据
  40. * @param request
  41. * @return
  42. */
  43. @RequestMapping(path = "/console/queryTemplateData",method = RequestMethod.GET)
  44. public String queryTemplateData(HttpServletRequest request){
  45. PageData pd = null;
  46. try {
  47. pd = this.getPageData(request);
  48. // 判断用户是否登录
  49. checkLogin(pd);
  50. consoleServiceSMOImpl.getTemplateData(pd);
  51. }catch (IllegalArgumentException e){
  52. return DataTransactionFactory.pageResponseJson(pd, ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
  53. }catch (SMOException e){
  54. return DataTransactionFactory.pageResponseJson(pd,e.getResult().getCode(),e.getMessage(),null);
  55. }catch (Exception e){
  56. logger.error("异常信息:",e);
  57. return DataTransactionFactory.pageResponseJson(pd,ResponseConstant.RESULT_CODE_ERROR,"请求参数出错 ",null);
  58. }
  59. return pd.getResJson().toJSONString();
  60. }
  61. @RequestMapping(path = "/console/flushCache",method = RequestMethod.POST)
  62. public String flushCache(HttpServletRequest request){
  63. PageData pd = null;
  64. try {
  65. pd = this.getPageData(request);
  66. // 判断用户是否登录
  67. checkLogin(pd);
  68. consoleServiceSMOImpl.flushCache(pd);
  69. }catch (IllegalArgumentException e){
  70. return DataTransactionFactory.pageResponseJson(pd, ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
  71. }catch (SMOException e){
  72. return DataTransactionFactory.pageResponseJson(pd,e.getResult().getCode(),e.getMessage(),null);
  73. }catch (Exception e){
  74. logger.error("异常信息:",e);
  75. return DataTransactionFactory.pageResponseJson(pd,ResponseConstant.RESULT_CODE_ERROR,"请求参数出错 ",null);
  76. }
  77. return pd.getResJson().toJSONString();
  78. }
  79. /**
  80. * 编辑模板数据
  81. * @param request
  82. * @return
  83. */
  84. @RequestMapping(path = "/console/editTemplateData",method = RequestMethod.POST)
  85. public String editTemplateData(HttpServletRequest request){
  86. PageData pd = null;
  87. try {
  88. pd = this.getPageData(request);
  89. // 判断用户是否登录
  90. checkLogin(pd);
  91. consoleServiceSMOImpl.editTemplateData(pd);
  92. }catch (IllegalArgumentException e){
  93. return DataTransactionFactory.pageResponseJson(pd, ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
  94. }catch (SMOException e){
  95. return DataTransactionFactory.pageResponseJson(pd,e.getResult().getCode(),e.getMessage(),null);
  96. }catch (Exception e){
  97. logger.error("异常信息:",e);
  98. return DataTransactionFactory.pageResponseJson(pd,ResponseConstant.RESULT_CODE_ERROR,"请求参数出错 ",null);
  99. }
  100. return pd.getResJson().toJSONString();
  101. }
  102. }