Authored by ping

update

... ... @@ -20,6 +20,7 @@
<value>/ActivateUnionRest/activateUnion</value>
<value>/ClickUnionRest/addUnion</value>
<value>/ClickUnionRest/addUnion4Special</value>
<value>/ClickUnionRest/addMonitor</value>
<value>/ActivateUnionRest/test</value>
</list>
</property>
... ...
... ... @@ -6,6 +6,10 @@ package com.yoho.unions.server.restapi;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
... ... @@ -44,11 +48,22 @@ public class ActivateUnionRest {
* @return
*/
@RequestMapping("/activateUnion")
@ResponseBody public ActiveUnionResponseBO activateUnion(ActivateUnionRequestVO vo) {
@ResponseBody public ActiveUnionResponseBO activateUnion(ActivateUnionRequestVO vo, HttpServletRequest request, HttpServletResponse response) {
log.info("activateUnion with param is {}", vo);
if ("iphone".equals(vo.getClient_type())) {
vo.setClient_type(ClientTypeEnum.IOS.getName());
}
String agent = request.getHeader("user-agent");
log.info("addMonitor user-agent={}", agent);
if (StringUtils.isEmpty(vo.getTd()) && StringUtils.isNotEmpty(agent)) {
if (agent.toLowerCase().indexOf("mac os x") >= 0 || agent.toLowerCase().indexOf("iphone") >= 0) {
String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like"));
vo.setTd("ios_" + version.replaceAll("_", "."));
log.info("activateUnion request={}", vo);
}
}
ActivateUnionRequestBO bo = new ActivateUnionRequestBO();
BeanUtils.copyProperties(vo, bo);
String clientType = vo.getClient_type();
... ...
... ... @@ -83,5 +83,28 @@ public class ClickUnionRest {
log.error("addUnion4Special error with request={}", bo, e);
}
}
@RequestMapping("/addMonitor")
public void addMonitor(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) {
try {
bo.setClientIp(RemoteIPInterceptor.getRemoteIP());
String agent = request.getHeader("user-agent");
log.info("addMonitor user-agent={}", agent);
if (!StringUtils.isEmpty(agent)) {
if (agent.toLowerCase().indexOf("mac os x") >= 0 || agent.toLowerCase().indexOf("iphone") >= 0) {
String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
log.info("addMonitor request={}", bo);
}
}
unionService.clickUnion(bo);
log.info("addMonitor with result is {}, and request is {}", response, bo);
response.setStatus(200);
} catch (Exception e) {
log.error("addMonitor error with request={}", bo, e);
}
}
}
... ...