|
@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.yihu.wlyy.entity.security.Token;
|
|
|
import com.yihu.wlyy.entity.url.CudUrl;
|
|
|
import com.yihu.wlyy.logs.InterfaceCallLogs;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import com.yihu.wlyy.util.SystemData;
|
|
@ -17,6 +18,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
import java.lang.annotation.Annotation;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.lang.reflect.Type;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
@ -32,13 +34,24 @@ public class DoctorInterceptor extends BaseInterceptor {
|
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
|
boolean flag = true;
|
|
|
try {
|
|
|
request.setAttribute("log-start", new Date().getTime());
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
JSONObject json = getAgent(request);
|
|
|
|
|
|
if (json == null) {
|
|
|
// 未登录
|
|
|
response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (json.has("uid") && json.has("admin_token") && StringUtils.isNotEmpty(json.getString("admin_token"))) {
|
|
|
String adminToken = SystemConf.getInstance().getSystemProperties().getProperty("admin_token");
|
|
|
String adminUid = SystemConf.getInstance().getSystemProperties().getProperty("admin_uid");
|
|
|
if (json.getString("uid").equals(adminUid) && json.getString("admin_token").equals(adminToken)) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String tokenStr = json.has("token") ? json.getString("token") : "";
|
|
|
String uid = json.has("uid") ? json.getString("uid") : "";
|
|
|
String imei = json.has("imei") ? json.getString("imei") : "";
|
|
@ -125,7 +138,32 @@ public class DoctorInterceptor extends BaseInterceptor {
|
|
|
|
|
|
@Override
|
|
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
|
|
long start = (long) request.getAttribute("log-start");
|
|
|
long end = new Date().getTime();
|
|
|
Class cls = ((HandlerMethod) handler).getBeanType();
|
|
|
RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
|
|
|
Method method = ((HandlerMethod) handler).getMethod();
|
|
|
RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
|
|
|
String url = "";
|
|
|
String urlCls = "";
|
|
|
String urlMth = "";
|
|
|
if (clsRm.value() != null && clsRm.value().length > 0) {
|
|
|
urlCls = clsRm.value()[0];
|
|
|
}
|
|
|
if (mthRm.value() != null && mthRm.value().length > 0) {
|
|
|
urlMth = mthRm.value()[0];
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(urlCls)) {
|
|
|
url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(urlMth)) {
|
|
|
url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
|
|
|
}
|
|
|
url = url.replace("\\", "/").replace("//", "/");
|
|
|
|
|
|
JSONObject json = getAgent(request);
|
|
|
String uid = json.has("uid") ? json.getString("uid") : "";
|
|
|
InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
|
|
|
}
|
|
|
|
|
|
@Override
|