Authored by ping

联盟架构调整

package com.yoho.unions.common.enums;
import com.yoho.service.model.union.request.ActivateDingdangRequestBO;
import com.yoho.service.model.union.request.AddDingdangRequestBO;
import com.yoho.service.model.union.request.MainUnionRequestBO;
/**
* 描述:
* 联盟类型的枚举
* @author ping.huang
* 2016年3月10日
*/
public enum UnionTypeEnum {
DINGDANG(1, "dingdang", "顶当互动", "dingdangServiceImpl2", AddDingdangRequestBO.class, ActivateDingdangRequestBO.class),
DUOMENG(2, "duomeng", "多盟", "dingdangServiceImpl2", AddDingdangRequestBO.class, ActivateDingdangRequestBO.class),
;
private int value;
private String name;
private String desc;
//处理具体逻辑的实现类
private String beanName;
//添加联盟的请求对象
private Class<? extends MainUnionRequestBO> addRequestClass;
//激活联盟的请求对象
private Class<? extends MainUnionRequestBO> activateRequestClass;
private UnionTypeEnum(int value, String name, String desc, String beanName, Class<? extends MainUnionRequestBO> addRequestClass, Class<? extends MainUnionRequestBO> activateRequestClass) {
this.value = value;
this.name = name;
this.desc = desc;
this.beanName = beanName;
this.addRequestClass = addRequestClass;
this.activateRequestClass = activateRequestClass;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
public String getDesc() {
return desc;
}
public static UnionTypeEnum getSourceEnumByValue(int value) {
if (value == 0) {
return null;
}
for (UnionTypeEnum e : values()) {
if (e.getValue() == value) {
return e;
}
}
return null;
}
public String getBeanName() {
return beanName;
}
public Class<? extends MainUnionRequestBO> getAddRequestClass() {
return addRequestClass;
}
public Class<? extends MainUnionRequestBO> getActivateRequestClass() {
return activateRequestClass;
}
}
... ...
/**
*
*/
package com.yoho.unions.common.utils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.response.AddDingdangResponseBO;
import com.yoho.service.model.union.response.MainUnionResponseBO;
/**
* 描述:
*
* @author ping.huang
* 2016年3月11日
*/
public class ObjectUtil {
static Logger log = LoggerFactory.getLogger(ObjectUtil.class);
/**
* 遍历该对象以及父对象,复制到json
* @param obj
* @param isSuper
* @return
*/
public static JSONObject getDeclaredFields(Object obj, boolean isSuper) {
if (obj == null) {
return null;
}
JSONObject json = new JSONObject();
try {
Field[] declaredFields = obj.getClass().getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
if ("serialVersionUID".equalsIgnoreCase(field.getName())) {
continue;
}
json.put(field.getName(), field.get(obj));
}
if (isSuper) {
declaredFields = obj.getClass().getSuperclass().getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
if ("serialVersionUID".equalsIgnoreCase(field.getName())) {
continue;
}
json.put(field.getName(), field.get(obj));
}
}
} catch (Exception e) {
log.error("", e);
}
return json;
}
/**
* 获取该对象的所有属性
* @param clazz
* @param isSuper---是否包含父对象
* @return
*/
public static List<String> getFields(Class<?> clazz, boolean isSuper) {
if (clazz == null) {
return null;
}
List<String> list = new ArrayList<String>();
try {
Field[] declaredFields = clazz.getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
if ("serialVersionUID".equalsIgnoreCase(field.getName())) {
continue;
}
list.add(field.getName());
}
if (isSuper) {
declaredFields = clazz.getSuperclass().getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
if ("serialVersionUID".equalsIgnoreCase(field.getName())) {
continue;
}
list.add(field.getName());
}
}
} catch (Exception e) {
log.error("", e);
}
return list;
}
public static void main(String[] args) {
MainUnionResponseBO bo = new AddDingdangResponseBO();
bo.setIsSuccess(false);
ObjectUtil.getDeclaredFields(bo, true);
}
}
... ...
package com.yoho.unions.common.utils;
import java.util.Map;
import java.util.Map.Entry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
/**
* spring上下文对象,用来获取bean
* @author huangping <br />
* 2012-12-1
*/
public class SpringContextUtil implements ApplicationContextAware {
static ApplicationContext applicationContext;
@Override
public synchronized void setApplicationContext(ApplicationContext ctx) throws BeansException {
SpringContextUtil.applicationContext = ctx;
}
/**
* 动态注册bean到spring容器中
* @param beanName
* @param className
* @param property
*/
public static void loadBean(String beanName, Class<?> className, Map<String, Object> property) throws Exception {
if (containsBean(beanName)) {
throw new Exception("【"+ beanName +"】,spring bean名称重复");
}
ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) applicationContext;
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ctx.getBeanFactory();
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(className);
if (property != null && !property.isEmpty()) {
for (Entry<String, Object> entry : property.entrySet()) {
builder.addPropertyValue(entry.getKey(), entry.getValue());
}
}
registry.registerBeanDefinition(beanName, builder.getBeanDefinition());
}
/**
* 根据bean的名称,获取bean对象
* @param beanName bean名称
* @return 返回获取到的对象
*/
public static Object getBean(String beanName) {
return applicationContext.getBean(beanName);
}
/**
* 根据bean的名称和class类型,获取bean对象
* @param beanName bean名称
* @param clazz 对象的class
* @return 返回获取到的对象
*/
public static <T> T getBean(String beanName, Class<T> clazz) {
return applicationContext.getBean(beanName, clazz);
}
/**
* 根据class类型,获取bean对象
* @param clazz 对象的class
* @return 返回获取到的对象
*/
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
/**
* 查询spring工厂中是否包含该名称的bean对象
* @param beanName bean名称
* @return spring工厂中是否包含该名称的bean对象
*/
public static boolean containsBean(String beanName) {
return applicationContext.containsBean(beanName);
}
/**
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype。<br />
* 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
* @param beanName bean名称
* @return 返回该对象是否是singleton
* @throws NoSuchBeanDefinitionException
*/
public static boolean isSingleton(String beanName) throws NoSuchBeanDefinitionException {
return applicationContext.isSingleton(beanName);
}
/**
* 如果给定的bean名字在bean定义中有别名,则返回这些别名
* @param beanName bean名称
* @return 返回该对象的别名
* @throws NoSuchBeanDefinitionException
*/
public static String[] getAliases(String beanName) throws NoSuchBeanDefinitionException {
return applicationContext.getAliases(beanName);
}
}
... ...
/**
*
*/
package com.yoho.unions.adapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yoho.unions.common.enums.UnionTypeEnum;
/**
* 描述:
* 对联盟类型进行适配
* @author ping.huang
* 2016年3月10日
*/
public class UnionServiceAdapter {
static Logger log = LoggerFactory.getLogger(UnionServiceAdapter.class);
/**
* 根据联盟传入的类型,查找具体的实现枚举
* @param unionType
* @return
* @throws Exception
*/
public static UnionTypeEnum getUnionService(int unionType) {
UnionTypeEnum union = UnionTypeEnum.getSourceEnumByValue(unionType);
if (union == null) {
return null;
}
return union;
}
}
... ...
/**
*
*/
package com.yoho.unions.server.restapi;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.request.MainUnionRequestBO;
import com.yoho.service.model.union.response.ActiveUnionResponseBO;
import com.yoho.service.model.union.response.MainUnionResponseBO;
import com.yoho.unions.adapter.UnionServiceAdapter;
import com.yoho.unions.common.enums.UnionTypeEnum;
import com.yoho.unions.common.utils.SpringContextUtil;
import com.yoho.unions.server.service.MainUnionService;
/**
* 描述:
* 统一的联盟的入口
* @author ping.huang
* 2016年3月10日
*/
@Controller
@RequestMapping("/MainUnionRest")
public class MainUnionRest {
static Logger log = LoggerFactory.getLogger(MainUnionRest.class);
/**
* 添加联盟
* @param req
* @return
*/
@RequestMapping("/addUnion")
@ResponseBody public JSONObject addUnion(HttpServletRequest request) {
Map<String, String[]> requestMap = request.getParameterMap();
log.info("enter addunions with param is {}", requestMap);
String unionType = request.getParameter("unionType");
log.info("addUnion with unionType={}", unionType);
JSONObject response = new JSONObject();
//请求的对象中必须要包含unionType字段,而且该值必须是数字
if (StringUtils.isEmpty(unionType)) {
response.put("msg", "unionType must not be null");
response.put("isSuccess", false);
return response;
}
//unionType必须是数字
if (!unionType.matches("\\d+")) {
response.put("msg", "unionType must be a number");
response.put("isSuccess", false);
return response;
}
//根据unionType获取具体的实现类
UnionTypeEnum union = UnionServiceAdapter.getUnionService(Integer.parseInt(unionType.toString()));
MainUnionService service = null;
try {
service = SpringContextUtil.getBean(union.getBeanName(), MainUnionService.class);
} catch (Exception e) {
log.error("getUnionService error with unionType={}", unionType, e);
service = null;
}
if (service == null) {
//该类型的服务不存在
response.put("msg", "unionType error");
response.put("isSuccess", false);
return response;
}
//转换为所需的对象
MainUnionRequestBO requestBO = service.toAddRequestBO(request, union.getAddRequestClass());
log.info("addUnion with param is {}", requestBO);
//调用添加接口
MainUnionResponseBO responseBO = service.addUnionInfo(requestBO);
//转换为返回对象
response = service.toResponse(responseBO);
return response;
}
/**
* 激活联盟
* @param request
* @return
*/
@RequestMapping("/activateUnion")
@ResponseBody public ActiveUnionResponseBO activateUnion(HttpServletRequest request) {
Map<String, String[]> requestMap = request.getParameterMap();
log.info("enter activateUnion with param is {}", requestMap);
String unionType = request.getParameter("unionType");
log.info("activateUnion with unionType={}", unionType);
//请求的对象中必须要包含unionType字段,而且该值必须是数字
if (StringUtils.isEmpty(unionType)) {
return new ActiveUnionResponseBO(600, "unionType must not be null");
}
//unionType必须是数字
if (!unionType.matches("\\d+")) {
return new ActiveUnionResponseBO(601, "unionType must be a number");
}
//根据unionType获取具体的实现类
UnionTypeEnum union = UnionServiceAdapter.getUnionService(Integer.parseInt(unionType.toString()));
MainUnionService service = null;
try {
service = SpringContextUtil.getBean(union.getBeanName(), MainUnionService.class);
} catch (Exception e) {
log.error("getUnionService error with unionType={}", unionType, e);
service = null;
}
if (service == null) {
//该类型的服务不存在
return new ActiveUnionResponseBO(602, "unionType error");
}
//转换为所需的对象
MainUnionRequestBO requestBO = service.toActivateRequestBO(request, union.getActivateRequestClass());
log.info("activateUnion with param is {}", requestBO);
//调用激活接口
MainUnionResponseBO responseBO = service.activateUnionInfo(requestBO);
//转换为返回对象
if (!responseBO.getIsSuccess()) {
return new ActiveUnionResponseBO(400, responseBO.getMsg());
} else {
return new ActiveUnionResponseBO(200, "success");
}
}
}
... ...
/**
*
*/
package com.yoho.unions.server.service;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.request.MainUnionRequestBO;
import com.yoho.service.model.union.response.MainUnionResponseBO;
import com.yoho.unions.common.utils.ObjectUtil;
/**
* 描述:联盟的主函数入口
*
* @author ping.huang 2016年3月9日
*/
public interface MainUnionService {
static Logger log = LoggerFactory.getLogger(MainUnionService.class);
/////添加开始---------------------------------------------------------------
/**
* 添加联盟,转换对象为具体联盟的请求对象
* @param request
* @param addRequestClass
* @return
*/
default public MainUnionRequestBO toAddRequestBO(HttpServletRequest request, Class<? extends MainUnionRequestBO> addRequestClass) {
if (request == null) {
log.warn("request is null");
return null;
}
if (addRequestClass == null) {
log.warn("addRequestClass is null");
return null;
}
MainUnionRequestBO obj = null;
try {
obj = addRequestClass.newInstance();
List<String> fields = ObjectUtil.getFields(addRequestClass, true);
if (fields == null) {
return obj;
}
for (String field : fields) {
BeanUtils.setProperty(obj, field, request.getParameter(field));
}
} catch (Exception e) {
log.error("", e);
}
return obj;
}
/**
* 添加联盟的检查
* @param request
* @return
*/
public MainUnionResponseBO addUnionCheck(MainUnionRequestBO request);
/**
* 调用联盟添加
*
* @param requestBO
* @return
* @throws Exception
*/
default public MainUnionResponseBO addUnionInfo(MainUnionRequestBO requestBO) {
//检查输入参数
MainUnionResponseBO responseBO = addUnionCheck(requestBO);
if (!responseBO.getIsSuccess()) {
return responseBO;
}
try {
// 调用添加接口
responseBO = addUnion(requestBO);
} catch (Exception e) {
log.error("addUnionInfo error with request is {}", requestBO, e);
return responseBO;
}
return responseBO;
}
/**
* 添加联盟
* @param request
* @return
*/
public MainUnionResponseBO addUnion(MainUnionRequestBO request);
/**
* 具体的返回对象转为jsonObject 该方法一般情况下,子类不需要实现
*
* @param responseBO
* @return
* @throws Exception
*/
default public JSONObject toResponse(MainUnionResponseBO responseBO) {
if (responseBO == null) {
return null;
}
JSONObject json = ObjectUtil.getDeclaredFields(responseBO, true);
return json;
}
/////添加结束---------------------------------------------------------------
/////激活开始--------------------------------------------------------------
/**
* 激活联盟,转换对象为具体联盟的请求对象
* @param request
* @param activateRequestClass
* @return
*/
default public MainUnionRequestBO toActivateRequestBO(HttpServletRequest request, Class<? extends MainUnionRequestBO> activateRequestClass) {
if (request == null) {
log.warn("request is null");
return null;
}
if (activateRequestClass == null) {
log.warn("activateRequestClass is null");
return null;
}
MainUnionRequestBO obj = null;
try {
obj = activateRequestClass.newInstance();
List<String> fields = ObjectUtil.getFields(activateRequestClass, true);
if (fields == null) {
return obj;
}
for (String field : fields) {
BeanUtils.setProperty(obj, field, request.getParameter(field));
}
} catch (Exception e) {
log.error("", e);
}
return obj;
}
/**
* 激活联盟的检查
* @param request
* @return
*/
public MainUnionResponseBO activateUnionCheck(MainUnionRequestBO request);
/**
* 调用联盟激活
*
* @param requestBO
* @return
* @throws Exception
*/
default public MainUnionResponseBO activateUnionInfo(MainUnionRequestBO requestBO) {
//检查输入参数
MainUnionResponseBO responseBO = activateUnionCheck(requestBO);
if (!responseBO.getIsSuccess()) {
return responseBO;
}
try {
// 调用激活接口
responseBO = activateUnion(requestBO);
} catch (Exception e) {
log.error("activityUnionInfo error with request is {}", requestBO, e);
return responseBO;
}
return responseBO;
}
/**
* 激活联盟
* @param request
* @return
*/
public MainUnionResponseBO activateUnion(MainUnionRequestBO request);
/////激活结束--------------------------------------------------------------
}
... ...
/**
*
*/
package com.yoho.unions.server.service.impl;
import javax.annotation.Resource;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.netflix.config.DynamicIntProperty;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.core.cache.CacheClient;
import com.yoho.service.model.union.request.ActivateDingdangRequestBO;
import com.yoho.service.model.union.request.AddDingdangRequestBO;
import com.yoho.service.model.union.request.MainUnionRequestBO;
import com.yoho.service.model.union.response.ActivateDingdangResponseBO;
import com.yoho.service.model.union.response.AddDingdangResponseBO;
import com.yoho.service.model.union.response.MainUnionResponseBO;
import com.yoho.unions.common.enums.SourceEnum;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.common.utils.HttpUtils;
import com.yoho.unions.dal.IUnionsActiveRecordDAO;
import com.yoho.unions.dal.model.UnionsActiveRecord;
import com.yoho.unions.server.service.MainUnionService;
/**
* 描述:
* 顶当联盟实现
* @author ping.huang
* 2016年3月10日
*/
@Service
public class DingdangServiceImpl2 implements MainUnionService {
static Logger log = LoggerFactory.getLogger(DingdangServiceImpl2.class);
static Logger addDingdang = LoggerFactory.getLogger("addDingdang");
static Logger activeDingdang = LoggerFactory.getLogger("activeDingdang");
private static final String unions_KEY = "yh:unions:dingdang_";
@Resource
IUnionsActiveRecordDAO unionsActiveRecordDAO;
@Resource
CacheClient cacheClient;
@Override
public MainUnionResponseBO addUnionCheck(MainUnionRequestBO request) {
AddDingdangRequestBO requestBO = (AddDingdangRequestBO) request;
if (StringUtils.isEmpty(requestBO.getApp())) {
log.warn("addunions error app is null with param is {}", request);
return new AddDingdangResponseBO(false, "APP IS NULL");
}
if (StringUtils.isEmpty(requestBO.getUdid())) {
log.warn("addunions error udid is null with param is {}", request);
return new AddDingdangResponseBO(false, "UDID IS NULL");
}
if (StringUtils.isEmpty(requestBO.getCallbackurl())) {
log.warn("addunions error callbackurl is null with param is {}", request);
return new AddDingdangResponseBO(false, "CALLBACKURL IS NULL");
}
return new AddDingdangResponseBO();
}
@Override
public MainUnionResponseBO addUnion(MainUnionRequestBO request) {
AddDingdangRequestBO requestBO = (AddDingdangRequestBO) request;
log.debug("addunions with param is {}", request);
//检查memcached中是否已经有该udid
String cacheUdid = cacheClient.get(unions_KEY + requestBO.getApp() + "_" + requestBO.getUdid(), String.class);
log.info("addunions get cache key={}, cacheUdid={}", unions_KEY + requestBO.getApp() + "_" + requestBO.getUdid(), cacheUdid);
if (StringUtils.isNotEmpty(cacheUdid)) {
log.warn("addunions error app and udid is added with param is {}", request);
return new AddDingdangResponseBO(false, "APP UDID IS EXISTS");
}
//保存到memcached,时间,一个小时
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime", 60 * 60);
cacheClient.set(unions_KEY + requestBO.getApp() + "_" + requestBO.getUdid(), activeTime.get(), requestBO.getUdid());
log.debug("addunions set cache success");
//插入数据库
try {
UnionsActiveRecord unions = new UnionsActiveRecord();
unions.setApp(requestBO.getApp());
unions.setUdid(requestBO.getUdid());
unions.setCallbackurl(requestBO.getCallbackurl());
unions.setType(requestBO.getType());
log.debug("add to unionsLog db with param is {}", unions);
unionsActiveRecordDAO.insert(unions);
} catch (Exception e) {
log.error("", e);
}
log.info("addunions success with param is {}", request);
addDingdang.info("addunions success with param is {}", request);
return new AddDingdangResponseBO(true, "成功");
}
@Override
public MainUnionResponseBO activateUnionCheck(MainUnionRequestBO request) {
ActivateDingdangRequestBO requestBO = (ActivateDingdangRequestBO) request;
if (StringUtils.isEmpty(requestBO.getAppid())) {
log.warn("activeunions error app is null with param is {}", request);
return new ActivateDingdangResponseBO(false, "APP IS NULL");
}
if (StringUtils.isEmpty(requestBO.getUdid())) {
log.warn("activeunions error udid is null with param is {}", request);
return new ActivateDingdangResponseBO(false, "UDID IS NULL");
}
return new ActivateDingdangResponseBO();
}
@Override
public MainUnionResponseBO activateUnion(MainUnionRequestBO request) {
ActivateDingdangRequestBO requestBO = (ActivateDingdangRequestBO) request;
log.debug("activeunions with param is {}", requestBO);
String memKey = unions_KEY + requestBO.getAppid() + "_" + requestBO.getUdid();
//检查memcached中是否已经有该udid
String cacheUdid = cacheClient.get(memKey, String.class);
log.info("activeUnion get cache key={}, cacheUdid={}", memKey, cacheUdid);
if (StringUtils.isEmpty(cacheUdid)) {
log.warn("activeunions error app and udid is not exists with param is {}", request);
return new ActivateDingdangResponseBO(false, "APP UDID IS NOT EXISTS IN CACHE");
}
//检查该app和udid是否已经激活
UnionsActiveRecord unions = new UnionsActiveRecord();
unions.setApp(requestBO.getAppid());
unions.setUdid(requestBO.getUdid());
unions.setType(requestBO.getApptype());
UnionsActiveRecord u = unionsActiveRecordDAO.selectByUdidAndApp(unions);
if (u == null) {
log.warn("activeunions error app and udid is not exists with param is {}", request);
return new ActivateDingdangResponseBO(false, "database has not exists this udid but cache exists");
}
//已经激活
if ("1".equals(u.getIsActive())) {
log.warn("activeunions error app is actived with param is {}", request);
return new ActivateDingdangResponseBO(false, "app udid had actived");
}
//调用联盟激活接口
int repeatCount = 0;
Pair<Integer, String> pair = null;
JSONObject json = null;
boolean isSuccess = false;
String url = "";
while (true) {
//如果已经成功,或者重试次数大于3次,则不再调用
if (isSuccess || repeatCount >= 3) {
break;
}
try {
url = u.getCallbackurl();
pair = HttpUtils.httpGet(url);
if (pair.getLeft() == HttpStatus.SC_OK) {
log.debug("call " + u.getCallbackurl() + " url success return message is {}", pair.getRight());
json = JSONObject.parseObject(pair.getRight());
isSuccess = json.getBooleanValue("isSuccess");
}
} catch (Exception e) {
log.error("", e);
}
repeatCount++;
}
log.info("call " + u.getCallbackurl() + " url return message is {}", pair.getRight());
MainUnionResponseBO response = null;
//更新数据库
if (isSuccess) {
unions.setIsActive("1");
unions.setId(u.getId());
unionsActiveRecordDAO.updateByPrimaryKey(unions);
//激活成功,从memcached中删除
cacheClient.delete(memKey);
log.debug("activeUnion delete cache success key={}", memKey);
response = new ActivateDingdangResponseBO(true, "激活成功");
} else {
unions.setIsActive("0");
unions.setId(u.getId());
unionsActiveRecordDAO.updateByPrimaryKey(unions);
response = new ActivateDingdangResponseBO(false, "激活失败");
}
try {
//组装大数据分析的日志
JSONObject j = new JSONObject();
j.put("apptype", requestBO.getApptype());
j.put("appid", requestBO.getAppid());
j.put("udid", requestBO.getUdid());
j.put("dateid", DateUtil.getcurrentDateTime());
SourceEnum e = SourceEnum.getSourceEnumByValue(u.getType());
j.put("source", e == null ? "" : e.getName());
j.put("ip", requestBO.getClientIP());
j.put("collect_ip", "");
activeDingdang.info(j.toString());
} catch (Exception e) {
log.error("", e);
}
return response;
}
}
... ...
... ... @@ -15,6 +15,8 @@
<context:component-scan base-package="com.yoho" />
<bean id="springContextUtil" class="com.yoho.unions.common.utils.SpringContextUtil" />
<bean id="memcachedClientFactory" class="com.yoho.core.cache.impl.MemcachedClientFactory">
<constructor-arg name="memcachedServers" value="${cache.servers.memcached.address}"/>
</bean>
... ...