Commit 0407e421 authored by 赵啸非's avatar 赵啸非

修改json序列化

parent 253180d8
package com.mortals.xhx.base.login.interceptor; package com.mortals.xhx.base.login.interceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.ap.CookieService; import com.mortals.framework.ap.CookieService;
import com.mortals.framework.ap.SysConstains; import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.model.CookieInfo; import com.mortals.framework.model.CookieInfo;
...@@ -9,13 +9,15 @@ import com.mortals.framework.util.AESUtil; ...@@ -9,13 +9,15 @@ import com.mortals.framework.util.AESUtil;
import com.mortals.framework.util.HttpUtil; import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.interceptor.BaseInterceptor; import com.mortals.framework.web.interceptor.BaseInterceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
@Order(1) @Order(1)
//@Component //@Component
public class AuthJsonInterceptor extends BaseInterceptor { public class AuthJsonInterceptor extends BaseInterceptor {
...@@ -35,13 +37,17 @@ public class AuthJsonInterceptor extends BaseInterceptor { ...@@ -35,13 +37,17 @@ public class AuthJsonInterceptor extends BaseInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception { throws Exception {
try { try {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
return true;
}
String uri = request.getServletPath(); String uri = request.getServletPath();
//校验配置的请求路径是否需要检查权限
if (config.needCheckAuth(uri)) { if (config.needCheckAuth(uri)) {
//需要校验权限
boolean auth = this.checkAuth(request, uri, config.getSecurityKey()); boolean auth = this.checkAuth(request, uri, config.getSecurityKey());
if (!auth) { if (!auth) {
//不存在时候 如果是管理员也不做拦截
CookieInfo cookie = CookieService.getLoginCookie(request, config.getSecurityKey()); CookieInfo cookie = CookieService.getLoginCookie(request, config.getSecurityKey());
if (cookie == null || cookie.getUser() == null) { if (cookie == null || cookie.getUser() == null) {
writeJsonResponse(response, HttpServletResponse.SC_FORBIDDEN, "用户未登录或登录失效,请重新登录"); writeJsonResponse(response, HttpServletResponse.SC_FORBIDDEN, "用户未登录或登录失效,请重新登录");
......
...@@ -11,9 +11,11 @@ spring: ...@@ -11,9 +11,11 @@ spring:
max-file-size: 500MB max-file-size: 500MB
max-request-size: 5000MB max-request-size: 5000MB
jackson: jackson:
date-format: yyyy-MM-dd HH:mm:ss serialization:
time-zone: GMT+8 WRITE_DATES_AS_TIMESTAMPS: true
default-property-inclusion: non_null default-property-inclusion: NON_NULL
# time-zone: GMT+8
# date-format: yyyy-MM-dd HH:mm:ss
dao: dao:
exceptiontranslation: exceptiontranslation:
enabled: false enabled: false
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
"baseUrl": "http://192.168.0.217:17211/base" "baseUrl": "http://192.168.0.217:17211/base"
}, },
"base-test": { "base-test": {
"baseUrl": "http://192.168.0.98:11071/zwfw" "baseUrl": "http://192.168.0.98:11071/base"
} }
} }
\ No newline at end of file
...@@ -96,9 +96,9 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -96,9 +96,9 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
} }
@Override @Override
public Rest<Map<String, Object>> list(UserEntity query) { public Rest<Object> list(UserEntity query) {
Map<String, Object> model = new HashMap(); Map<String, Object> model = new HashMap();
Rest<Map<String, Object>> ret = new Rest<>(); Rest<Object> ret = new Rest<>();
Context context = this.getContext(); Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code; int code;
...@@ -119,7 +119,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -119,7 +119,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
this.init(model, context); this.init(model, context);
ret.setCode(code); ret.setCode(code);
ret.setData(model); ret.setData(model);
ret.setDict(model.get(KEY_RESULT_DICT)==null?null:(Map<String,Object>)model.remove(KEY_RESULT_DICT));
ret.setMsg(model.get(MESSAGE_INFO)==null?"":model.remove(MESSAGE_INFO).toString()); ret.setMsg(model.get(MESSAGE_INFO)==null?"":model.remove(MESSAGE_INFO).toString());
return ret; return ret;
} }
......
...@@ -11,8 +11,11 @@ spring: ...@@ -11,8 +11,11 @@ spring:
max-file-size: 500MB max-file-size: 500MB
max-request-size: 5000MB max-request-size: 5000MB
jackson: jackson:
date-format: yyyy-MM-dd HH:mm:ss serialization:
time-zone: GMT+8 WRITE_DATES_AS_TIMESTAMPS: true
default-property-inclusion: NON_NULL
# time-zone: GMT+8
# date-format: yyyy-MM-dd HH:mm:ss
dao: dao:
exceptiontranslation: exceptiontranslation:
enabled: false enabled: false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment