Authored by ping

update

... ... @@ -22,6 +22,7 @@ public class UnionLogs {
private Integer createTime;
private Integer updateTime;
private String clientType;
public Integer getId() {
return id;
... ... @@ -110,4 +111,12 @@ public class UnionLogs {
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
public String getClientType() {
return clientType;
}
public void setClientType(String clientType) {
this.clientType = clientType;
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.unions.dal.IUnionLogsDAO" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionLogs" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="app_id" property="appId" jdbcType="VARCHAR" />
<result column="udid" property="udid" jdbcType="VARCHAR" />
<result column="idfa" property="idfa" jdbcType="VARCHAR" />
<result column="imei" property="imei" jdbcType="VARCHAR" />
<result column="is_activate" property="isActivate" jdbcType="TINYINT" />
<result column="union_type" property="unionType" jdbcType="TINYINT" />
<result column="add_params" property="addParams" jdbcType="VARCHAR" />
<result column="activate_params" property="activateParams" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, app_id, udid, idfa, imei, is_activate, union_type, add_params, activate_params,
create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_logs
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_logs
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionLogs" >
insert into union_logs (id, app_id, udid,
idfa, imei, is_activate,
union_type, add_params, activate_params,
create_time, update_time)
values (#{id,jdbcType=INTEGER}, #{appId,jdbcType=VARCHAR}, #{udid,jdbcType=VARCHAR},
#{idfa,jdbcType=VARCHAR}, #{imei,jdbcType=VARCHAR}, #{isActivate,jdbcType=TINYINT},
#{unionType,jdbcType=TINYINT}, #{addParams,jdbcType=VARCHAR}, #{activateParams,jdbcType=VARCHAR},
#{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionLogs" >
insert into union_logs
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="appId != null" >
app_id,
</if>
<if test="udid != null" >
udid,
</if>
<if test="idfa != null" >
idfa,
</if>
<if test="imei != null" >
imei,
</if>
<if test="isActivate != null" >
is_activate,
</if>
<if test="unionType != null" >
union_type,
</if>
<if test="addParams != null" >
add_params,
</if>
<if test="activateParams != null" >
activate_params,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="appId != null" >
#{appId,jdbcType=VARCHAR},
</if>
<if test="udid != null" >
#{udid,jdbcType=VARCHAR},
</if>
<if test="idfa != null" >
#{idfa,jdbcType=VARCHAR},
</if>
<if test="imei != null" >
#{imei,jdbcType=VARCHAR},
</if>
<if test="isActivate != null" >
#{isActivate,jdbcType=TINYINT},
</if>
<if test="unionType != null" >
#{unionType,jdbcType=TINYINT},
</if>
<if test="addParams != null" >
#{addParams,jdbcType=VARCHAR},
</if>
<if test="activateParams != null" >
#{activateParams,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionLogs" >
update union_logs
<set >
<if test="appId != null" >
app_id = #{appId,jdbcType=VARCHAR},
</if>
<if test="udid != null" >
udid = #{udid,jdbcType=VARCHAR},
</if>
<if test="idfa != null" >
idfa = #{idfa,jdbcType=VARCHAR},
</if>
<if test="imei != null" >
imei = #{imei,jdbcType=VARCHAR},
</if>
<if test="isActivate != null" >
is_activate = #{isActivate,jdbcType=TINYINT},
</if>
<if test="unionType != null" >
union_type = #{unionType,jdbcType=TINYINT},
</if>
<if test="addParams != null" >
add_params = #{addParams,jdbcType=VARCHAR},
</if>
<if test="activateParams != null" >
activate_params = #{activateParams,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionLogs" >
update union_logs
set app_id = #{appId,jdbcType=VARCHAR},
udid = #{udid,jdbcType=VARCHAR},
idfa = #{idfa,jdbcType=VARCHAR},
imei = #{imei,jdbcType=VARCHAR},
is_activate = #{isActivate,jdbcType=TINYINT},
union_type = #{unionType,jdbcType=TINYINT},
add_params = #{addParams,jdbcType=VARCHAR},
activate_params = #{activateParams,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<mapper namespace="com.yoho.unions.dal.IUnionLogsDAO">
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionLogs">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="app_id" property="appId" jdbcType="VARCHAR" />
<result column="udid" property="udid" jdbcType="VARCHAR" />
<result column="idfa" property="idfa" jdbcType="VARCHAR" />
<result column="imei" property="imei" jdbcType="VARCHAR" />
<result column="is_activate" property="isActivate" jdbcType="TINYINT" />
<result column="union_type" property="unionType" jdbcType="TINYINT" />
<result column="add_params" property="addParams" jdbcType="VARCHAR" />
<result column="activate_params" property="activateParams"
jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="client_type" property="clientType" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id, app_id, udid, idfa, imei, is_activate, union_type, add_params,
activate_params,
create_time, update_time, client_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from union_logs
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from union_logs
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionLogs">
insert into union_logs (id, app_id, udid,
idfa, imei, is_activate,
union_type, add_params, activate_params,
create_time, update_time, client_type)
values (#{id,jdbcType=INTEGER}, #{appId,jdbcType=VARCHAR},
#{udid,jdbcType=VARCHAR},
#{idfa,jdbcType=VARCHAR}, #{imei,jdbcType=VARCHAR}, #{isActivate,jdbcType=TINYINT},
#{unionType,jdbcType=TINYINT}, #{addParams,jdbcType=VARCHAR},
#{activateParams,jdbcType=VARCHAR},
#{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, #{clientType})
</insert>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionLogs">
update union_logs
set app_id = #{appId,jdbcType=VARCHAR},
udid = #{udid,jdbcType=VARCHAR},
idfa = #{idfa,jdbcType=VARCHAR},
imei = #{imei,jdbcType=VARCHAR},
is_activate = #{isActivate,jdbcType=TINYINT},
union_type = #{unionType,jdbcType=TINYINT},
add_params = #{addParams,jdbcType=VARCHAR},
activate_params = #{activateParams,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
client_type=#{clientType}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
... ...
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
... ...
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="yoho-unions-server">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>
... ...
... ... @@ -51,38 +51,53 @@ public class ActivateUnionRest {
return new ActiveUnionResponseBO(600, "error");
}
//多线程处理
exe.execute(new Runnable() {
@Override
public void run() {
MainUnionService service = null;
if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType)) {
//处理安卓的服务
for (String str : UnionConstant.andriodServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", vo);
}
exe.execute(new RunActivate(bo));
return new ActiveUnionResponseBO(200, "success");
}
public static class RunActivate implements Runnable {
public RunActivate(ActivateUnionRequestBO bo) {
this.bo = bo;
}
private ActivateUnionRequestBO bo;
@Override
public void run() {
MainUnionService service = null;
if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(bo.getClient_type())) {
//处理安卓的服务
for (String str : UnionConstant.andriodServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", bo);
}
} else if (ClientTypeEnum.IPHONE.getName().equalsIgnoreCase(clientType)) {
//处理iOS的服务
for (String str : UnionConstant.iOSServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", vo);
}
}
} else if (ClientTypeEnum.IPHONE.getName().equalsIgnoreCase(bo.getClient_type())) {
//处理iOS的服务
for (String str : UnionConstant.iOSServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", bo);
}
}
}
});
}
public ActivateUnionRequestBO getBo() {
return bo;
}
public void setBo(ActivateUnionRequestBO bo) {
this.bo = bo;
}
return new ActiveUnionResponseBO(200, "success");
}
}
... ...
... ... @@ -119,28 +119,28 @@ public class DDServiceImpl implements MainUnionService {
response.setMsg("APP IS NULL");
return response;
}
if (StringUtils.isEmpty(request.getUdid())) {
log.warn("activeunions error udid is null with param is {}", request);
if (StringUtils.isEmpty(request.getIdfa())) {
log.warn("activeunions error idfa is null with param is {}", request);
response.setIsSuccess(false);
response.setMsg("UDID IS NULL");
response.setMsg("idfa IS NULL");
return response;
}
String memKey = unions_KEY + request.getAppid() + "_" + request.getUdid();
String memKey = unions_KEY + request.getAppid() + "_" + request.getIdfa();
//检查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);
//检查memcached中是否已经有该idfa
String cacheIdfa = cacheClient.get(memKey, String.class);
log.info("activeUnion get cache key={}, cacheIdfa={}", memKey, cacheIdfa);
if (StringUtils.isEmpty(cacheIdfa)) {
log.warn("activeunions error app and idfa is not exists with param is {}", request);
response.setIsSuccess(false);
response.setMsg("APP UDID IS NOT EXISTS IN CACHE");
response.setMsg("APP idfa IS NOT EXISTS IN CACHE");
return response;
}
//检查该app和udid是否已经激活
//检查该app和idfa是否已经激活
UnionsActiveRecord unions = new UnionsActiveRecord();
unions.setApp(request.getAppid());
unions.setUdid(request.getUdid());
unions.setUdid(request.getIdfa());
unions.setType(request.getClient_type());
UnionsActiveRecord u = unionsActiveRecordDAO.selectByUdidAndApp(unions);
... ... @@ -195,6 +195,22 @@ public class DDServiceImpl implements MainUnionService {
log.debug("activeUnion delete cache success key={}", memKey);
response.setMsg("激活成功");
response.setIsSuccess(true);
try {
//组装大数据分析的日志
JSONObject j = new JSONObject();
j.put("apptype", request.getClient_type());
j.put("appid", request.getAppid());
j.put("ifda", request.getIdfa());
j.put("dateid", DateUtil.getcurrentDateTime());
SourceEnum e = SourceEnum.getSourceEnumByValue(u.getType());
j.put("source", e == null ? "" : e.getName());
j.put("ip", request.getClientIp());
j.put("collect_ip", "");
activeDingdang.info(j.toString());
} catch (Exception e) {
log.error("", e);
}
} else {
unions.setIsActive("0");
unions.setId(u.getId());
... ... @@ -202,22 +218,6 @@ public class DDServiceImpl implements MainUnionService {
response.setMsg("激活失败");
response.setIsSuccess(false);
}
try {
//组装大数据分析的日志
JSONObject j = new JSONObject();
j.put("apptype", request.getClient_type());
j.put("appid", request.getAppid());
j.put("ifda", request.getUdid());
j.put("dateid", DateUtil.getcurrentDateTime());
SourceEnum e = SourceEnum.getSourceEnumByValue(u.getType());
j.put("source", e == null ? "" : e.getName());
j.put("ip", request.getClientIp());
j.put("collect_ip", "");
activeDingdang.info(j.toString());
} catch (Exception e) {
log.error("", e);
}
return response;
}
... ...
... ... @@ -89,6 +89,7 @@ public class GDTServiceImpl implements MainUnionService {
UnionLogs unionLogs = new UnionLogs();
unionLogs.setAppId(String.valueOf(request.getAppid()));
unionLogs.setUdid("");
unionLogs.setClientType(request.getClient_type());
if (ClientTypeEnum.IPHONE.getName().equalsIgnoreCase(request.getClient_type())){
unionLogs.setIdfa(request.getIdfa());
}else{
... ...