| | |
| | | package com.yeshi.fanli.util.factory;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.Iterator;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import com.yeshi.fanli.entity.monitor.ClientAPIMonitor;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | public class MonitorFactory {
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | public static ClientAPIMonitor createClientAPI(HttpServletRequest request, int code, int time, String beiZhu)
|
| | | throws Exception {
|
| | | if (request == null)
|
| | | throw new Exception("request 为空");
|
| | | ClientAPIMonitor monitor = new ClientAPIMonitor();
|
| | | Map<String, Object> params = (Map<String, Object>) request.getParameterMap();
|
| | | if (params != null) {
|
| | | Iterator<String> its = params.keySet().iterator();
|
| | | JSONObject json = new JSONObject();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | if ("packages".equalsIgnoreCase(key) || "appkey".equalsIgnoreCase(key)
|
| | | || "platform".equalsIgnoreCase(key) || "apiversion".equalsIgnoreCase(key)
|
| | | || "channel".equalsIgnoreCase(key) || "imei".equalsIgnoreCase(key)
|
| | | || "osVersion".equalsIgnoreCase(key) || "network".equalsIgnoreCase(key)
|
| | | || "deviceType".equalsIgnoreCase(key) || "time".equalsIgnoreCase(key)
|
| | | || "sign".equalsIgnoreCase(key))
|
| | | continue;
|
| | | json.put(key, ((Object[]) params.get(key))[0]);
|
| | | }
|
| | | monitor.setRequestData(json.toString());
|
| | | }
|
| | | monitor.setBeiZhu(beiZhu);
|
| | | monitor.setCode(code);
|
| | | monitor.setCreateTime(new Date());
|
| | | monitor.setIp(request.getRemoteHost());
|
| | | monitor.setTime(time);
|
| | | monitor.setUrl(request.getRequestURI());
|
| | | return monitor;
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.util.factory; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.monitor.ClientAPIMonitor; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | public class MonitorFactory { |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public static ClientAPIMonitor createClientAPI(HttpServletRequest request, int code, int time, String beiZhu) |
| | | throws Exception { |
| | | if (request == null) |
| | | throw new Exception("request 为空"); |
| | | ClientAPIMonitor monitor = new ClientAPIMonitor(); |
| | | Map<String, Object> params = (Map<String, Object>) request.getParameterMap(); |
| | | if (params != null) { |
| | | Iterator<String> its = params.keySet().iterator(); |
| | | JSONObject json = new JSONObject(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | if ("packages".equalsIgnoreCase(key) || "appkey".equalsIgnoreCase(key) |
| | | || "platform".equalsIgnoreCase(key) || "apiversion".equalsIgnoreCase(key) |
| | | || "channel".equalsIgnoreCase(key) || "imei".equalsIgnoreCase(key) |
| | | || "osVersion".equalsIgnoreCase(key) || "network".equalsIgnoreCase(key) |
| | | || "deviceType".equalsIgnoreCase(key) || "time".equalsIgnoreCase(key) |
| | | || "sign".equalsIgnoreCase(key)) |
| | | continue; |
| | | json.put(key, ((Object[]) params.get(key))[0]); |
| | | } |
| | | monitor.setRequestData(json.toString()); |
| | | } |
| | | monitor.setBeiZhu(beiZhu); |
| | | monitor.setCode(code); |
| | | monitor.setCreateTime(new Date()); |
| | | monitor.setIp(request.getRemoteHost()); |
| | | monitor.setTime(time); |
| | | monitor.setUrl(request.getRequestURI()); |
| | | return monitor; |
| | | } |
| | | |
| | | } |