Просмотр исходного кода

加入登录功能,页面请求时,定义协议,及封装数据到PageData 对象,后期方便处理

wuxw7 лет назад: 8
Родитель
Сommit
28e2d5916f
36 измененных файлов с 1087 добавлено и 73 удалено
  1. 57 33
      ConsoleService/doc/consoleService.docx
  2. 1 0
      ConsoleService/doc/keystore.p12.txt
  3. 10 0
      ConsoleService/doc/page_request.json
  4. 11 0
      ConsoleService/doc/page_response.json
  5. 2 0
      ConsoleService/pom.xml
  6. 35 0
      ConsoleService/src/main/java/com/java110/console/ConsoleServiceApplicationStart.java
  7. 29 2
      ConsoleService/src/main/java/com/java110/console/rest/ConsoleController.java
  8. 65 0
      ConsoleService/src/main/java/com/java110/console/rest/LoginController.java
  9. 9 0
      ConsoleService/src/main/java/com/java110/console/smo/IConsoleServiceSMO.java
  10. 16 1
      ConsoleService/src/main/java/com/java110/console/smo/impl/ConsoleServiceSMOImpl.java
  11. 8 0
      ConsoleService/src/main/resources/application.yml
  12. 1 0
      ConsoleService/src/main/resources/html/login.html
  13. 7 23
      ConsoleService/src/main/resources/html/menu.html
  14. 0 0
      ConsoleService/src/main/resources/javascript/login.js
  15. BIN
      ConsoleService/src/main/resources/keystore.p12
  16. 139 0
      java110-bean/src/main/java/com/java110/entity/service/PageData.java
  17. 5 0
      java110-common/pom.xml
  18. 7 0
      java110-common/src/main/java/com/java110/common/constant/CommonConstant.java
  19. 189 0
      java110-common/src/main/java/com/java110/common/exception/FilterException.java
  20. 6 0
      java110-common/src/main/java/com/java110/common/factory/AuthenticationFactory.java
  21. 80 0
      java110-common/src/main/java/com/java110/common/factory/DataTransactionFactory.java
  22. 13 0
      java110-common/src/main/java/com/java110/common/factory/PageDataFactory.java
  23. 12 0
      java110-common/src/main/java/com/java110/common/util/Assert.java
  24. 13 0
      java110-common/src/main/java/com/java110/common/util/SequenceUtil.java
  25. 27 0
      java110-config/db/CenterService/create_table.db
  26. 51 0
      java110-config/db/ConsoleService/create_table.db
  27. 15 1
      java110-core/src/main/java/com/java110/core/base/controller/BaseController.java
  28. 6 0
      java110-service/pom.xml
  29. 0 13
      java110-service/src/main/java/com/java110/App.java
  30. 91 0
      java110-service/src/main/java/com/java110/service/aop/PageProcessAspect.java
  31. 21 0
      java110-service/src/main/java/com/java110/service/configuration/ServiceConfiguration.java
  32. 29 0
      java110-service/src/main/java/com/java110/service/controller/ErrorController.java
  33. 108 0
      java110-service/src/main/java/com/java110/service/filter/JwtFilter.java
  34. 7 0
      java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java
  35. 10 0
      java110-service/src/main/resources/html/error.html
  36. 7 0
      pom.xml

+ 57 - 33
ConsoleService/doc/consoleService.docx

@@ -138,40 +138,40 @@
                                  取值说明
                                      m_id
 否
-Int
+int
 
-菜单ID
+菜单id
 数据库自增
-Name
+name
 否
 varchar
 10
 菜单名称
  
-Level
+level
 否
 varchar
 2
 菜单级别
  一级菜单 为 1
  二级菜单为2
-Parent_id
+parent_id
 否
 int
 
-父类菜单ID
-如果是一类菜单则写为-1 如果是二类菜单则写父类的菜单ID
-Menu_group
+父类菜单id
+ 如果是一类菜单则写为-1 如果是二类菜单则写父类的菜单id
+menu_group
 否
-Varchar
+varchar
 10
 菜单组
-LEFT 显示在页面左边的菜单
+ left 显示在页面左边的菜单
 user_id
 否
 varchar
 12
-创建菜单的用户ID
+创建菜单的用户id
 
 create_time
 否
@@ -201,48 +201,73 @@ varchar
                                  取值说明
                                    m_ctg_id
 否
-Int
+int
 
 
 数据库自增
-M_id
+m_id
 否
 int
 10
-菜单ID
+菜单id
  
-Menu_type
+url
 否
 varchar
-10
-菜单类型
-lINK,显示模板页面;
-EVENT,调用接口处理;
-VIEW,显示弹框录入信息调接口
-Parent_id
+100
+菜单打开地址
+
+template
+是
+varchar
+50
+页面模板
+模板名称
+create_time
+否
+date
+
+创建时间
+系统自动生成
+status_cd
+否
+varchar
+2
+数据状态
+详细参考c_status表
+
+2.3、m_menu_2_user模型表
+
+                                    字段
+                                   是否空
+                                    类型
+                                    长度
+                                    描述
+                                 取值说明
+                                   m_user_id
 否
 int
 
-父类菜单ID
- 如果是一类菜单则写为-1 如果是二类菜单则写父类的菜单ID
+
+数据库自增
+m_id
+否
+int
+10
+菜单id
+ 
 user_id
 否
 varchar
-12
-创建菜单的用户ID
-
+100
+用户id
+用户id
 create_time
 否
 date
 
 创建时间
 系统自动生成
-remark
-是
-varchar
-200
-备注
-
 status_cd
 否
 varchar
@@ -250,5 +275,4 @@ varchar
 数据状态
 详细参考c_status表
 
-2.3、m_menu_2_user模型表
 

+ 1 - 0
ConsoleService/doc/keystore.p12.txt

@@ -0,0 +1 @@
+keytool -genkey -alias tomcat  -storetype PKCS12 -keyalg RSA -keysize 2048  -keystore keystore.p12 -validity 3650

+ 10 - 0
ConsoleService/doc/page_request.json

@@ -0,0 +1,10 @@
+{
+  "meta":{
+    "method":"",//主要用于,日志记录
+    "requestTime":"",
+    "transactionId":"请求流水" //不需要填 有系统统一设置
+  },
+  "param":{
+    //这里写参数
+  }
+}

+ 11 - 0
ConsoleService/doc/page_response.json

@@ -0,0 +1,11 @@
+{
+  "meta":{
+    "code":"",//主要用于,日志记录
+    "message":"",
+    "responseTime":"",
+    "transactionId":"请求流水" //由系统返回
+  },
+  "data":{
+    //这里是返回参数
+  }
+}

+ 2 - 0
ConsoleService/pom.xml

@@ -32,6 +32,8 @@
             <artifactId>spring-boot-starter-freemarker</artifactId>
         </dependency>
 
+
+
         <dependency>
             <groupId>com.java110</groupId>
             <artifactId>java110-config</artifactId>

+ 35 - 0
ConsoleService/src/main/java/com/java110/console/ConsoleServiceApplicationStart.java

@@ -1,7 +1,13 @@
 package com.java110.console;
 
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Connector;
+import org.apache.tomcat.util.descriptor.web.SecurityCollection;
+import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
+import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.context.ApplicationContext;
@@ -33,6 +39,35 @@ public class ConsoleServiceApplicationStart {
         return new RestTemplate();
     }
 
+    @Bean
+    public EmbeddedServletContainerFactory servletContainer() {
+        TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
+            @Override
+            protected void postProcessContext(Context context) {
+                SecurityConstraint constraint = new SecurityConstraint();
+                constraint.setUserConstraint("CONFIDENTIAL");
+                SecurityCollection collection = new SecurityCollection();
+                collection.addPattern("/*");
+                constraint.addCollection(collection);
+                context.addConstraint(constraint);
+            }
+        };
+        tomcat.addAdditionalTomcatConnectors(httpConnector());
+        return tomcat;
+    }
+
+    @Bean
+    public Connector httpConnector() {
+        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
+        connector.setScheme("http");
+        //Connector监听的http的端口号
+        connector.setPort(7001);
+        connector.setSecure(false);
+        //监听到http的端口号后转向到的https的端口号
+        connector.setRedirectPort(8443);
+        return connector;
+    }
+
     public static void main(String[] args) throws Exception{
         ApplicationContext context = SpringApplication.run(ConsoleServiceApplicationStart.class, args);
 

+ 29 - 2
ConsoleService/src/main/java/com/java110/console/rest/ConsoleController.java

@@ -9,6 +9,8 @@ import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -27,9 +29,24 @@ public class ConsoleController extends BaseController {
         String template = "index";
         try {
             //1.0 判断用户是否登录
-            checkLogin();
+            String managerId = checkLogin();
             //2.0 查询菜单信息
-            List<Map> menuItems = consoleServiceSMOImpl.getMenuItemsByManageId("");
+            List<Map> menuItems = consoleServiceSMOImpl.getMenuItemsByManageId(managerId);
+            for(Map menuItem : menuItems){
+                if(!"-1".equals(menuItem.get("parentId")) && !"1".equals(menuItem.get("level"))){
+                    Map parentMenuItem = this.getMenuItemFromList(menuItems,menuItem.get("parentId").toString());
+                    if(parentMenuItem.containsKey("subMenus")){
+                        List<Map> subMenus = (List<Map>) parentMenuItem.get("subMenus");
+                        subMenus.add(menuItem);
+                    }else{
+                        List<Map> subMenus = new ArrayList<Map>();
+                        subMenus.add(menuItem);
+                        parentMenuItem.put("subMenus",subMenus);
+                    }
+
+                    menuItems.remove(menuItem);
+                }
+            }
             model.addAttribute("menus",menuItems);
             //3.0 查询各个系统调用量
         }catch (NoAuthorityException e){
@@ -44,6 +61,16 @@ public class ConsoleController extends BaseController {
         }
     }
 
+
+    private Map getMenuItemFromList(List<Map> menuItems,String parentId){
+        for(Map menuItem : menuItems){
+            if(menuItem.get("mId").equals(parentId)){
+                return menuItem;
+            }
+        }
+        return null;
+    }
+
     public IConsoleServiceSMO getConsoleServiceSMOImpl() {
         return consoleServiceSMOImpl;
     }

+ 65 - 0
ConsoleService/src/main/java/com/java110/console/rest/LoginController.java

@@ -0,0 +1,65 @@
+package com.java110.console.rest;
+
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.factory.DataTransactionFactory;
+import com.java110.console.smo.IConsoleServiceSMO;
+import com.java110.core.base.controller.BaseController;
+import com.java110.entity.service.PageData;
+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/2.
+ */
+@RestController
+public class LoginController extends BaseController {
+
+    @Autowired
+    private IConsoleServiceSMO consoleServiceSMOImpl;
+
+    /**
+     * 登录
+     * 协议:
+     * {
+     "meta":{
+     "method":"",//主要用于,日志记录
+     "requestTime":"",
+     "transactionId":"请求流水" //不需要填 有系统统一设置
+     },
+     "param":{
+     *     "userCode":"",
+     *     "userPwd":"",
+     *     "code":"",
+     * }
+     }
+     *
+     * @param request
+     * @return
+     */
+    @RequestMapping(path = "/login",method = RequestMethod.POST)
+    public String login(HttpServletRequest request) {
+        PageData pd = null;
+        try{
+            pd = this.getPageData(request);
+
+
+        }catch (Exception e){
+            return DataTransactionFactory.pageResponseJson(ResponseConstant.RESULT_CODE_ERROR,"请求参数出错 ",null);
+        }
+
+        return pd.getResJson().toJSONString();
+    }
+
+    public IConsoleServiceSMO getConsoleServiceSMOImpl() {
+        return consoleServiceSMOImpl;
+    }
+
+    public void setConsoleServiceSMOImpl(IConsoleServiceSMO consoleServiceSMOImpl) {
+        this.consoleServiceSMOImpl = consoleServiceSMOImpl;
+    }
+}

+ 9 - 0
ConsoleService/src/main/java/com/java110/console/smo/IConsoleServiceSMO.java

@@ -1,5 +1,6 @@
 package com.java110.console.smo;
 
+import com.alibaba.fastjson.JSONObject;
 import com.java110.common.exception.SMOException;
 
 import java.util.List;
@@ -17,4 +18,12 @@ public interface IConsoleServiceSMO {
      * @return
      */
     public List<Map> getMenuItemsByManageId(String manageId) throws SMOException,IllegalArgumentException;
+
+    /**
+     * 用户登录
+     * @param userObj
+     * @return
+     * @throws SMOException
+     */
+    public String login(JSONObject userObj) throws SMOException;
 }

+ 16 - 1
ConsoleService/src/main/java/com/java110/console/smo/impl/ConsoleServiceSMOImpl.java

@@ -1,5 +1,7 @@
 package com.java110.console.smo.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.java110.common.cache.MappingCache;
 import com.java110.common.constant.CommonConstant;
 import com.java110.common.constant.MappingConstant;
@@ -16,6 +18,7 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -51,6 +54,7 @@ public class ConsoleServiceSMOImpl extends LoggerEngine implements IConsoleServi
             Assert.hasLength(securityCode, "签名秘钥没有配置");
             Map paramIn = new HashMap();
             paramIn.put("manageId", manageId);
+            paramIn.put("menuGroup",CommonConstant.MENU_GROUP_LEFT);
             String responseMsg = "";
             String requestBody = DataTransactionFactory.createQueryOneCenterServiceRequestJson(appId, manageId, securityCode,
                     DataTransactionFactory.createQueryOneBusinessRequestJson(ServiceCodeConstant.SERVICE_CODE_QUERY_MENU_ITEM,
@@ -73,8 +77,19 @@ public class ConsoleServiceSMOImpl extends LoggerEngine implements IConsoleServi
                 responseMsg = restTemplate.postForObject(centerServiceUrl,requestBody,String.class);
             }
 
+        JSONObject businessObj = DataTransactionFactory.getOneBusinessFromCenterServiceResponseJson(responseMsg);
+        JSONArray menus = businessObj.getJSONArray("menus");
+        return menus.toJavaList(Map.class);
+    }
 
-        //根据
+    /**
+     * 用户登录
+     * @param userObj
+     * @return
+     * @throws SMOException
+     */
+    @Override
+    public String login(JSONObject userObj) throws SMOException {
         return null;
     }
 

+ 8 - 0
ConsoleService/src/main/resources/application.yml

@@ -5,6 +5,14 @@ eureka:
       #defaultZone: http://localhost:8761/eureka/
 server:
   port: 7001
+  ssl:
+    keyStoreType: PKCS12
+    keyAlias: tomcat
+    key-store: keystore.p12
+    key-store-password: 12345678
+  session:
+      cookie:
+        http-only: true
 spring:
   application:
     name: console-service

+ 1 - 0
ConsoleService/src/main/resources/html/login.html

@@ -117,6 +117,7 @@
 		<!--[if IE]>
 <script src="../assets/js/jquery-1.11.3.min.js"></script>
 <![endif]-->
+		<script src="../javascript/login.js"></script>
 		<script type="text/javascript">
 			if('ontouchstart' in document.documentElement) document.write("<script src='../assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
 		</script>

+ 7 - 23
ConsoleService/src/main/resources/html/menu.html

@@ -14,12 +14,12 @@
 
             <b class="arrow"></b>
         </li>
-
+        <#list menus as menu>
         <li class="">
             <a href="#" class="dropdown-toggle">
                 <i class="menu-icon fa fa-desktop"></i>
                 <span class="menu-text">
-								编码映射管理
+								${menu.name}
 							</span>
 
                 <b class="arrow fa fa-angle-down"></b>
@@ -28,35 +28,19 @@
             <b class="arrow"></b>
 
             <ul class="submenu">
+                <#list menu.subMenus as subMenu>
                 <li class="">
-                    <a href="#">
-                        <i class="menu-icon fa fa-caret-right"></i>
-                        添加映射关系
-                    </a>
-
-                    <b class="arrow"></b>
-                </li>
-
-                <li class="">
-                    <a href="#">
+                    <a href="${subMenu.url}">
                         <i class="menu-icon fa fa-caret-right"></i>
-                        删除映射关系
-                    </a>
-
-                    <b class="arrow"></b>
-                </li>
-
-                <li class="">
-                    <a href="#">
-                        <i class="menu-icon fa fa-caret-right"></i>
-                        修改映射关系
+                        ${subMenu.name}
                     </a>
 
                     <b class="arrow"></b>
                 </li>
+                </#list>
             </ul>
         </li>
-
+        </#list>
     </ul><!-- /.nav-list -->
 
     <div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">

+ 0 - 0
ConsoleService/src/main/resources/javascript/login.js


BIN
ConsoleService/src/main/resources/keystore.p12


+ 139 - 0
java110-bean/src/main/java/com/java110/entity/service/PageData.java

@@ -0,0 +1,139 @@
+package com.java110.entity.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.Serializable;
+
+/**
+ * 页面请求数据封装
+ * Created by wuxw on 2018/5/2.
+ */
+public class PageData implements Serializable {
+
+    private String transactionId;
+
+    private String requestTime;
+
+    private String method;
+
+    private JSONObject param;
+
+    private JSONObject meta;
+
+    private JSONObject reqJson;
+
+    private JSONObject resJson;
+
+    private String code;
+
+    private String message;
+
+    private String responseTime;
+
+    private JSONObject data;
+
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public PageData setTransactionId(String transactionId) {
+        this.transactionId = transactionId;
+        return this;
+    }
+
+    public String getRequestTime() {
+        return requestTime;
+    }
+
+    public void setRequestTime(String requestTime) {
+        this.requestTime = requestTime;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public JSONObject getParam() {
+        return param;
+    }
+
+    public void setParam(JSONObject param) {
+        this.param = param;
+    }
+
+    public JSONObject getMeta() {
+        return meta;
+    }
+
+    public void setMeta(JSONObject meta) {
+        this.meta = meta;
+    }
+
+    public JSONObject getReqJson() {
+        return reqJson;
+    }
+
+    public void setReqJson(JSONObject reqJson) {
+        this.reqJson = reqJson;
+    }
+
+    public JSONObject getResJson() {
+        return resJson;
+    }
+
+    public void setResJson(JSONObject resJson) {
+        this.resJson = resJson;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public String getResponseTime() {
+        return responseTime;
+    }
+
+    public void setResponseTime(String responseTime) {
+        this.responseTime = responseTime;
+    }
+
+    public JSONObject getData() {
+        return data;
+    }
+
+    public void setData(JSONObject data) {
+        this.data = data;
+    }
+
+    public PageData builder(String requestJson) throws IllegalArgumentException{
+        JSONObject reqJson = null;
+        try {
+            reqJson = JSONObject.parseObject(requestJson);
+        }catch (Exception e){
+            throw new IllegalArgumentException("请求参数错误",e);
+        }
+        this.setMeta(reqJson.getJSONObject("meta"));
+        this.setMethod(this.getMeta().getString("method"));
+        this.setRequestTime(this.getMeta().getString("requestTime"));
+        this.setParam(reqJson.getJSONObject("param"));
+        this.setReqJson(reqJson);
+        return this;
+    }
+}

+ 5 - 0
java110-common/pom.xml

@@ -115,6 +115,11 @@
             <artifactId>spring-kafka</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>commons-net</groupId>
             <artifactId>commons-net</artifactId>

+ 7 - 0
java110-common/src/main/java/com/java110/common/constant/CommonConstant.java

@@ -40,4 +40,11 @@ public class CommonConstant {
 
     public final static String ENCRYPT_KEY_SIZE = "ENCRYPT_KEY_SIZE";
 
+    public final static String MENU_GROUP_LEFT = "LEFT";
+
+    /**
+     * 鉴权token
+     */
+    public final static String COOKIE_AUTH_TOKEN = "java110_token";
+
 }

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/FilterException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 无权限异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class FilterException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public FilterException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public FilterException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public FilterException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public FilterException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public FilterException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public FilterException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public FilterException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public FilterException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 6 - 0
java110-common/src/main/java/com/java110/common/factory/AuthenticationFactory.java

@@ -223,6 +223,12 @@ public class AuthenticationFactory {
         return keyPairGenerator.generateKeyPair();
     }
 
+
+    /***********************************JWT start***************************************/
+
+
+
+    /***********************************JWT end***************************************/
     public static void main(String[] args) throws Exception{
         KeyPair keyPair=genKeyPair(1024);
 

+ 80 - 0
java110-common/src/main/java/com/java110/common/factory/DataTransactionFactory.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.constant.MappingConstant;
 import com.java110.common.constant.OrderTypeCdConstant;
+import com.java110.common.constant.ResponseConstant;
 import com.java110.common.util.DateUtil;
 import com.java110.common.util.SequenceUtil;
 import com.java110.common.util.StringUtil;
@@ -171,6 +172,31 @@ public class DataTransactionFactory {
         return paramIn.toJSONString();
     }
 
+    /**
+     * 获取Business 内容
+     * @return
+     */
+    public static JSONArray getBusinessFromCenterServiceResponseJson(String resJson){
+
+        JSONObject paramOut = JSONObject.parseObject(resJson);
+        return paramOut.getJSONArray("business");
+    }
+
+    public static JSONObject getOneBusinessFromCenterServiceResponseJson(String resJson){
+        JSONArray paramOut = getBusinessFromCenterServiceResponseJson(resJson);
+
+        if(paramOut != null && paramOut.size() > 0){
+           JSONObject business =  paramOut.getJSONObject(0);
+           if(!"0000".equals(business.getJSONObject("response").getString("code"))){
+               return null;
+            }
+
+            return business;
+        }
+
+        return null;
+    }
+
     /**
      * 数据加密
      * @param reqInfo
@@ -194,4 +220,58 @@ public class DataTransactionFactory {
         return new String(AuthenticationFactory.decrypt(resInfo.getBytes("UTF-8"), AuthenticationFactory.loadPrivateKey(MappingConstant.KEY_OUT_PRIVATE_STRING)
                 ,keySize),"UTF-8");
     }
+
+
+    /**
+     * 页面返回报文封装
+     *
+     * {
+     "meta":{
+     "code":"",//主要用于,日志记录
+     "message":"",
+     "responseTime":"",
+     "transactionId":"请求流水" //由系统返回
+     },
+     "data":{
+     //这里是返回参数
+     }
+     }
+     * @return
+     * @throws Exception
+     */
+    public static String pageResponseJson(String transactionId,String code,String message,JSONObject data){
+        JSONObject paramOut = JSONObject.parseObject("{\"meta\":{}}");
+        JSONObject metaObj = paramOut.getJSONObject("meta");
+        metaObj.put("transactionId",transactionId);
+        metaObj.put("code",transactionId);
+        metaObj.put("message",message);
+        metaObj.put("responseTime",DateUtil.getNowDefault());
+        if(data != null) {
+            paramOut.put("data", data);
+        }
+        return paramOut.toJSONString();
+    }
+
+    /**
+     * 页面返回封装
+     * @param code 编码
+     * @param message 信息
+     * @param data 数据
+     * @return
+     * @throws Exception
+     */
+    public static String pageResponseJson(String code,String message,JSONObject data){
+        return pageResponseJson(ResponseConstant.NO_TRANSACTION_ID,code,message,data);
+    }
+
+    /**
+     * 页面处理成功信息封装
+     * @param transactionId
+     * @return
+     * @throws Exception
+     */
+    public static String pageResponseJson(String transactionId){
+        return pageResponseJson(transactionId,ResponseConstant.RESULT_CODE_SUCCESS,"成功",null);
+    }
+
 }

+ 13 - 0
java110-common/src/main/java/com/java110/common/factory/PageDataFactory.java

@@ -0,0 +1,13 @@
+package com.java110.common.factory;
+
+import com.java110.entity.service.PageData;
+
+/**
+ * Created by wuxw on 2018/5/2.
+ */
+public class PageDataFactory {
+
+    public static PageData newInstance(){
+        return new PageData();
+    }
+}

+ 12 - 0
java110-common/src/main/java/com/java110/common/util/Assert.java

@@ -94,4 +94,16 @@ public class Assert extends org.springframework.util.Assert{
         }
         return true;
     }
+
+    public static Boolean isPageJsonObject(String msg){
+        try{
+            JSONObject jsonObject = JSONObject.parseObject(msg);
+            if(!jsonObject.containsKey("meta") || !jsonObject.containsKey("param")){
+                return false;
+            }
+        }catch (Exception e){
+            return false;
+        }
+        return true;
+    }
 }

+ 13 - 0
java110-common/src/main/java/com/java110/common/util/SequenceUtil.java

@@ -37,6 +37,7 @@ public class SequenceUtil {
         //(11+yyyymmdd+八位序列)
         prefixMap.put("attrId","11");
         prefixMap.put("transactionId","1000001");
+        prefixMap.put("pageTransactionId","1000002");
         prefixMap.put("dataFlowId","2000");
     }
 
@@ -72,6 +73,18 @@ public class SequenceUtil {
         return prefixMap.get("transactionId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId();
     }
 
+    /**
+     * 获取交易流水ID
+     *
+     * @return
+     */
+    public static String getPageTransactionId() {
+
+        //从内存中获取平台随机码
+
+        return prefixMap.get("pageTransactionId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId();
+    }
+
     public static String getOId(){
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
             return prefixMap.get("oId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");

+ 27 - 0
java110-config/db/CenterService/create_table.db

@@ -206,12 +206,19 @@ insert into c_route(app_id,service_id,order_type_cd,status_cd) values(
 '8000418001','3','Q','0'
 );
 
+insert into c_route(app_id,service_id,order_type_cd,status_cd) values(
+'8000418002','4','Q','0'
+);
+
 insert into c_service(service_code,invoke_model,business_type_cd,`name`,seq,url,provide_app_id,status_cd)
 values('query.user.userInfo','1','Q','用户信息查询',1,'http://...','8000418001','0');
 
 insert into c_service(service_code,invoke_model,business_type_cd,`name`,seq,url,provide_app_id,status_cd)
 values('query.order.orderInfo','1','Q','订单信息',1,'http://center-service/businessApi/query','8000418001','0');
 
+insert into c_service(service_code,invoke_model,business_type_cd,`name`,seq,url,provide_app_id,status_cd)
+values('query.console.menu','1','Q','查询菜单',1,'http://console-service/businessApi/query','8000418002','0');
+
 INSERT INTO c_service_sql(service_code,`name`,params,query_model,`sql`,proc,template,remark,status_cd)
 VALUES('query.order.orderInfo','订单信息','oId','1','{
                                                  	"param1":"SELECT co.app_id appId,co.create_time createTime,co.ext_transaction_id extTransactionId,co.finish_time finishTime
@@ -229,6 +236,26 @@ VALUES('query.order.orderInfo','订单信息','oId','1','{
                                                          }
                                                        }"}','','0');
 
+INSERT INTO c_service_sql(service_code,`name`,params,query_model,`sql`,proc,template,remark,status_cd)
+VALUES('query.console.menu','查询菜单','manageId,menuGroup','1','{
+                                                 	"param1":"select mm.m_id mId,mm.name name,mm.level level,mm.parent_id parentId,mm.menu_group menuGroup,mm.user_id userId,mm.create_time createTime,
+                                                              mm.remark remark,mmc.url url,mmc.template template
+                                                              from m_menu_2_user mm2u,m_menu mm, m_menu_ctg mmc
+                                                              where mm2u.user_id = #manageId#
+                                                              and mm2u.m_id = mm.m_id
+                                                              AND mm.menu_group = #menuGroup#
+                                                              and mm2u.status_cd = ''0''
+                                                              and mm.status_cd = ''0''
+                                                              and mmc.m_id = mm.m_id
+                                                              and mmc.status_cd = ''0''"
+                                                 }','','{"PARAM:"{
+                                                            "param1": "$.#menus#Array"
+                                                            },"TEMPLATE":"{
+                                                         "response": {
+                                                           "code": "0000",
+                                                           "message": "成功"
+                                                         }
+                                                       }"}','','0');
 
 
 

+ 51 - 0
java110-config/db/ConsoleService/create_table.db

@@ -0,0 +1,51 @@
+-- m_menu
+
+create table m_menu(
+    m_id INT NOT NULL AUTO_INCREMENT KEY COMMENT '菜单ID',
+    name varchar(10) not null comment '菜单名称',
+    level varchar(2) not null comment '菜单级别 一级菜单 为 1 二级菜单为2',
+    parent_id int not null comment '父类菜单id 如果是一类菜单则写为-1 如果是二类菜单则写父类的菜单id',
+    menu_group varchar(10) not null comment '菜单组 left 显示在页面左边的菜单',
+    user_id varchar(12) not null comment '创建菜单的用户id',
+    remark VARCHAR(200) COMMENT '描述',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
+);
+
+-- m_menu_ctg
+
+create table m_menu_ctg(
+    m_ctg_id INT NOT NULL AUTO_INCREMENT KEY COMMENT '菜单配置ID',
+    m_id INT NOT NULL COMMENT '菜单ID',
+    url varchar(100) not null comment '菜单打开地址',
+    template varchar(50) comment '页面模板 模板名称',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
+);
+
+-- m_menu_2_user
+
+create table m_menu_2_user(
+    m_user_id INT NOT NULL AUTO_INCREMENT KEY COMMENT '菜单用户ID',
+    m_id int not null comment '菜单id',
+    user_id varchar(100) not null comment '用户id',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
+);
+
+insert into m_menu(name,level,parent_id,menu_group,user_id,remark) values('系统配置','1','-1','LEFT','10001','');
+insert into m_menu(name,level,parent_id,menu_group,user_id,remark) values('映射管理','2','1','LEFT','10001','');
+insert into m_menu(name,level,parent_id,menu_group,user_id,remark) values('外部应用','2','1','LEFT','10001','');
+insert into m_menu(name,level,parent_id,menu_group,user_id,remark) values('路由管理','2','1','LEFT','10001','');
+insert into m_menu(name,level,parent_id,menu_group,user_id,remark) values('服务管理','2','1','LEFT','10001','');
+
+insert into m_menu_ctg(m_id,url,template) values(2,'http://www.java110.com','');
+insert into m_menu_ctg(m_id,url,template) values(3,'http://www.java110.com','');
+insert into m_menu_ctg(m_id,url,template) values(4,'http://www.java110.com','');
+insert into m_menu_ctg(m_id,url,template) values(5,'http://www.java110.com','');
+
+insert into m_menu_2_user(m_id,user_id) values(1,'10001');
+insert into m_menu_2_user(m_id,user_id) values(2,'10001');
+insert into m_menu_2_user(m_id,user_id) values(3,'10001');
+insert into m_menu_2_user(m_id,user_id) values(4,'10001');
+insert into m_menu_2_user(m_id,user_id) values(5,'10001');

+ 15 - 1
java110-core/src/main/java/com/java110/core/base/controller/BaseController.java

@@ -4,9 +4,12 @@ package com.java110.core.base.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.constant.ResponseConstant;
 import com.java110.common.exception.NoAuthorityException;
+import com.java110.common.factory.PageDataFactory;
 import com.java110.common.log.LoggerEngine;
 
+import com.java110.common.util.SequenceUtil;
 import com.java110.core.base.AppBase;
+import com.java110.entity.service.PageData;
 import org.springframework.util.StringUtils;
 
 import javax.servlet.http.HttpServletRequest;
@@ -26,10 +29,11 @@ public class BaseController extends AppBase {
      * 检查用户登录
      * @throws NoAuthorityException
      */
-    protected void checkLogin() throws NoAuthorityException{
+    protected String checkLogin() throws NoAuthorityException{
         if(false){
             throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"用户未登录,请登录!");
         }
+        return "10001";
     }
 
 
@@ -117,4 +121,14 @@ public class BaseController extends AppBase {
         return ip;
     }
 
+    /**
+     * 创建 PageData 对象
+     * @param request
+     * @return
+     * @throws IllegalArgumentException
+     */
+    protected PageData getPageData(HttpServletRequest request){
+        return request.getAttribute("pd") != null ?(PageData) request.getAttribute("pd") : null;
+    }
+
 }

+ 6 - 0
java110-service/pom.xml

@@ -37,11 +37,17 @@
             <artifactId>druid</artifactId>
         </dependency>
 
+
         <!--mapper-->
         <dependency>
             <groupId>tk.mybatis</groupId>
             <artifactId>mapper-spring-boot-starter</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
         <!--pagehelper
         <dependency>
             <groupId>com.github.pagehelper</groupId>

+ 0 - 13
java110-service/src/main/java/com/java110/App.java

@@ -1,13 +0,0 @@
-package com.java110;
-
-/**
- * Hello world!
- *
- */
-public class App 
-{
-    public static void main( String[] args )
-    {
-        System.out.println( "Hello World!" );
-    }
-}

+ 91 - 0
java110-service/src/main/java/com/java110/service/aop/PageProcessAspect.java

@@ -0,0 +1,91 @@
+package com.java110.service.aop;
+
+import com.java110.common.factory.PageDataFactory;
+import com.java110.common.util.Assert;
+import com.java110.common.util.SequenceUtil;
+import com.java110.entity.service.PageData;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * 数据初始化
+ * Created by wuxw on 2018/5/2.
+ */
+@Aspect
+@Component
+public class PageProcessAspect {
+    @Pointcut("execution(public * com.java110..*.*Controller.*(..))")
+    public void dataProcess(){}
+
+    /**
+     * 初始化数据
+     *
+     * @param joinPoint
+     * @throws Throwable
+     */
+    @Before("dataProcess()")
+    public void deBefore(JoinPoint joinPoint) throws Throwable {
+        // 接收到请求,记录请求内容
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = attributes.getRequest();
+
+        if("POST".equals(request.getMethod())){
+            BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
+            //reader.
+            StringBuffer sb = new StringBuffer();
+            String str = "";
+            while ((str = reader.readLine()) != null) {
+                sb.append(str);
+            }
+            str = sb.toString();
+            if(Assert.isPageJsonObject(str)){
+                PageData pd = PageDataFactory.newInstance().builder(str).setTransactionId(SequenceUtil.getPageTransactionId());
+                request.setAttribute("pd",pd);
+            }
+        }
+
+    }
+
+    @AfterReturning(returning = "ret", pointcut = "dataProcess()")
+    public void doAfterReturning(Object ret) throws Throwable {
+        // 处理完请求,返回内容
+    }
+
+    //后置异常通知
+    @AfterThrowing("dataProcess()")
+    public void throwss(JoinPoint jp){
+    }
+
+    //后置最终通知,final增强,不管是抛出异常或者正常退出都会执行
+    @After("dataProcess()")
+    public void after(JoinPoint jp){
+        // 接收到请求,记录请求内容
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = attributes.getRequest();
+        PageData pd =request.getAttribute("pd") != null ?(PageData)request.getAttribute("pd"):null ;
+        //保存日志处理
+        if(pd != null){
+
+        }
+    }
+
+    //环绕通知,环绕增强,相当于MethodInterceptor
+    @Around("dataProcess()")
+    public Object arround(ProceedingJoinPoint pjp) {
+        try {
+            Object o =  pjp.proceed();
+            return o;
+        } catch (Throwable e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+}

+ 21 - 0
java110-service/src/main/java/com/java110/service/configuration/ServiceConfiguration.java

@@ -0,0 +1,21 @@
+package com.java110.service.configuration;
+
+import com.java110.service.filter.JwtFilter;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created by wuxw on 2018/5/2.
+ */
+@Configuration
+public class ServiceConfiguration {
+    @Bean
+    public FilterRegistrationBean jwtFilter() {
+        final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
+        registrationBean.setFilter(new JwtFilter());
+        registrationBean.addUrlPatterns("/secure/*");
+
+        return registrationBean;
+    }
+}

+ 29 - 0
java110-service/src/main/java/com/java110/service/controller/ErrorController.java

@@ -0,0 +1,29 @@
+package com.java110.service.controller;
+
+import com.java110.common.exception.NoAuthorityException;
+import com.java110.common.exception.SMOException;
+import com.java110.core.base.controller.BaseController;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 错误页面
+ * Created by wuxw on 2018/5/2.
+ */
+@Controller
+public class ErrorController extends BaseController {
+
+    @RequestMapping(path = "/error")
+    public String error(Model model,@RequestParam("code") String code,@RequestParam("msg") String msg) {
+            model.addAttribute("code",code);
+            model.addAttribute("msg",msg);
+            //3.0 查询各个系统调用量
+            return "error";
+    }
+}

+ 108 - 0
java110-service/src/main/java/com/java110/service/filter/JwtFilter.java

@@ -0,0 +1,108 @@
+package com.java110.service.filter;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.auth0.jwt.interfaces.Claim;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.java110.common.constant.CommonConstant;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.exception.FilterException;
+import com.java110.common.factory.DataTransactionFactory;
+import com.java110.common.util.StringUtil;
+import org.springframework.web.filter.GenericFilterBean;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+/**
+ * Created by wuxw on 2018/5/2.
+ */
+public class JwtFilter extends GenericFilterBean {
+
+    public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain)
+            throws IOException, ServletException {
+
+        final HttpServletRequest request = (HttpServletRequest) req;
+        final HttpServletResponse response = (HttpServletResponse) res;
+        String token = "";
+        try {
+            //获取token
+            token = this.getToken(request);
+            try {
+                Algorithm algorithm = Algorithm.HMAC256("secret");
+                JWTVerifier verifier = JWT.require(algorithm).withIssuer("auth0").build();
+                DecodedJWT jwt = verifier.verify(token);
+
+                Map<String, Claim> claims = jwt.getClaims();
+                // Add the claim to request header
+                request.setAttribute("claims", claims);
+            } catch (UnsupportedEncodingException e) {
+                logger.error("解析token 失败 :", e);
+                throw new FilterException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "您还没有登录,请先登录");
+            } catch (JWTVerificationException e) {
+                //Invalid signature/claims
+                logger.error("解析token 失败 :", e);
+                throw new FilterException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "您还没有登录,请先登录");
+            }
+
+            chain.doFilter(req, res);
+        }catch (FilterException e){
+            if("POST".equals(request.getMethod())){
+                writeJson(response,
+                        DataTransactionFactory.pageResponseJson(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,e.getMessage(),null),
+                        "UTF-8");
+            }else{
+                response.sendRedirect("/error?code="+e.getResult().getCode()+"&msg="+e.getResult().getMsg());
+            }
+
+        }catch (Exception e){
+            response.sendRedirect("/error?code="+ResponseConstant.RESULT_CODE_INNER_ERROR+"&msg=鉴权失败");
+        }
+    }
+
+    /**
+     * 获取TOKEN
+     * @param request
+     * @return
+     */
+    private String getToken(HttpServletRequest request) throws FilterException{
+        String token = "";
+        for (Cookie cookie : request.getCookies()) {
+            if (CommonConstant.COOKIE_AUTH_TOKEN.equals(cookie.getName())) {
+                token = cookie.getValue();
+            }
+        }
+
+        if (StringUtil.isNullOrNone(token)) {
+            throw new FilterException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "您还没有登录,请先登录");
+        }
+        return token;
+    }
+
+    private void writeJson(HttpServletResponse response, String data, String encoding){
+        //设置编码格式
+        response.setContentType("text/plain;charset=" + encoding);
+        response.setCharacterEncoding(encoding);
+
+        PrintWriter out = null;
+        try{
+            out = response.getWriter();
+            out.write(data);
+            out.flush();
+        }catch(IOException e){
+            e.printStackTrace();
+        }
+    }
+
+}

+ 7 - 0
java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java

@@ -45,6 +45,13 @@ public class QueryServiceSMOImpl extends LoggerEngine implements IQueryServiceSM
             if ("".equals(currentServiceSql.getQueryModel())) {
                 throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"配置服务 serviceCode = " + dataQuery.getServiceCode() + " 错误,未配置QueryModel,请联系管理员");
             }
+            //请求参数校验
+            List<String> sysParams = currentServiceSql.getParamList();
+            for(String param : sysParams) {
+                if(!dataQuery.getRequestParams().containsKey(param)){
+                    throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,"请求参数错误,请求报文中未包含参数 " + param + " 信息");
+                }
+            }
             dataQuery.setServiceSql(currentServiceSql);
             if (CommonConstant.QUERY_MODEL_SQL.equals(currentServiceSql.getQueryModel())) {
                 doExecuteSql(dataQuery);

+ 10 - 0
java110-service/src/main/resources/html/error.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>出错了</title>
+</head>
+<body>
+<h1>${code},${msg}</h1>
+</body>
+</html>

+ 7 - 0
pom.xml

@@ -115,6 +115,13 @@
                 <artifactId>pagehelper-spring-boot-starter</artifactId>
                 <version>1.1.0</version>
             </dependency>
+
+            <dependency>
+                <groupId>com.auth0</groupId>
+                <artifactId>java-jwt</artifactId>
+                <version>3.3.0</version>
+            </dependency>
+
             <dependency>
                 <groupId>com.java110</groupId>
                 <artifactId>java110-common</artifactId>