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