Blame view

dal/src/main/resources/META-INF/mybatis/UnionLogsMapper.xml 10.5 KB
zhengwen.ge authored
1 2
<?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" >
ping authored
3
<mapper namespace="com.yoho.unions.dal.IUnionLogsDAO">
linlong authored
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    <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="VARCHAR"/>
        <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"/>
        <result column="td" property="td" jdbcType="VARCHAR"/>
        <result column="app_key" property="appKey" jdbcType="VARCHAR"/>
        <result column="interface_type" property="interfaceType" jdbcType="VARCHAR"/>
        <result column="union_name" property="unionName" jdbcType="VARCHAR"/>
    </resultMap>
    <resultMap id="ActivateMap" type="com.yoho.service.model.union.response.ActivateDeviceIdRspBO">
        <result column="union_type" property="unionType" jdbcType="VARCHAR"/>
        <result column="union_name" property="unionName" jdbcType="VARCHAR"/>
        <result column="idfa_count" property="idfaCount" jdbcType="INTEGER"/>
        <result column="imei_count" property="imeiCount" jdbcType="INTEGER"/>
28
        <result column="total_count" property="totalCount" jdbcType="INTEGER"/>
linlong authored
29
    </resultMap>
linlong authored
30 31 32 33 34 35
    <resultMap id="YHActivateMap" type="com.yoho.service.model.union.response.YHActivateDeviceIdRspBO">
        <result column="union_type" property="unionType" jdbcType="VARCHAR"/>
        <result column="union_name" property="unionName" jdbcType="VARCHAR"/>
        <result column="idfa_count" property="idfaCount" jdbcType="INTEGER"/>
        <result column="imei_count" property="imeiCount" jdbcType="INTEGER"/>
    </resultMap>
linlong authored
36
    <sql id="Base_Column_List">
ping authored
37 38
		id, app_id, udid, idfa, imei, is_activate, union_type, add_params,
		activate_params,
linlong authored
39
		create_time, update_time, client_type, td, app_key,interface_type,union_name
ping authored
40
	</sql>
linlong authored
41 42 43 44 45 46 47 48
    <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">
ping authored
49 50 51
		delete from union_logs
		where id = #{id,jdbcType=INTEGER}
	</delete>
linlong authored
52
    <insert id="insert" parameterType="com.yoho.unions.dal.model.UnionLogs">
ping authored
53 54 55
		insert into union_logs (id, app_id, udid,
		idfa, imei, is_activate,
		union_type, add_params, activate_params,
linlong authored
56
		create_time, update_time, client_type, td, app_key,interface_type,union_name)
ping authored
57 58 59
		values (#{id,jdbcType=INTEGER}, #{appId,jdbcType=VARCHAR},
		#{udid,jdbcType=VARCHAR},
		#{idfa,jdbcType=VARCHAR}, #{imei,jdbcType=VARCHAR}, #{isActivate,jdbcType=TINYINT},
ping authored
60
		#{unionType,jdbcType=INTEGER}, #{addParams,jdbcType=VARCHAR},
ping authored
61
		#{activateParams,jdbcType=VARCHAR},
linlong authored
62
		#{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, #{clientType}, #{td}, #{appKey}, #{interfaceType},#{unionName})
ping authored
63
	</insert>
linlong authored
64
    <update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionLogs">
ping authored
65 66 67 68 69 70
		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},
ping authored
71
		union_type = #{unionType,jdbcType=INTEGER},
ping authored
72 73 74
		add_params = #{addParams,jdbcType=VARCHAR},
		activate_params = #{activateParams,jdbcType=VARCHAR},
		update_time = #{updateTime,jdbcType=INTEGER},
bblu authored
75
		client_type=#{clientType},
linlong authored
76
		app_key=#{appKey},
linlong authored
77 78
		interface_type=#{interfaceType},
		union_name=#{unionName}
ping authored
79 80
		where id = #{id,jdbcType=INTEGER}
	</update>
linlong authored
81
    <update id="updateUnionLogs">
ping authored
82 83
		update union_logs set udid=#{udid}, idfa=#{idfa}, imei=#{imei}, is_activate=#{isActivate}, activate_params=#{activateParams}, update_time=#{updateTime} where id=#{id}
	</update>
linlong authored
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    <select id="selectByClientType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from union_logs where update_time + 7776000 >= UNIX_TIMESTAMP()
        <if test="clientType=='ios'">
            and idfa=#{idfa}
        </if>
        <if test="clientType=='android'">
            and imei=#{imei}
        </if>
        <if test="appKey!=null">
            and app_key=#{appKey}
        </if>
        limit 1
    </select>
    <select id="selectUnionList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from union_logs where app_id = #{appId} and client_type=#{clientType} and union_type=#{unionType}
        <if test="clientType == 'ios'">
            and idfa=#{idfa}
        </if>
        <if test="clientType == 'android'">
            and imei=#{imei}
        </if>
        and update_time + 7776000 >= UNIX_TIMESTAMP() limit 1
    </select>

    <select id="selectIOS" resultMap="BaseResultMap" parameterType="com.yoho.unions.dal.model.UnionLogs">
        select
        <include refid="Base_Column_List"/>
        from union_logs
        where app_id = #{appId,jdbcType=VARCHAR} and
        idfa = #{idfa,jdbcType=VARCHAR} and
        client_type=#{clientType}
        <if test="appKey!=null">
            and app_key=#{appKey}
        </if>
        and union_type=#{unionType} limit 1
    </select>
    <select id="selectAndroid" resultMap="BaseResultMap" parameterType="com.yoho.unions.dal.model.UnionLogs">
        select
        <include refid="Base_Column_List"/>
        from union_logs
        where app_id = #{appId,jdbcType=VARCHAR} and
        imei = #{imei,jdbcType=VARCHAR} and
        client_type=#{clientType} and union_type=#{unionType}
        <if test="appKey!=null">
            and app_key=#{appKey}
        </if>
        limit 1
    </select>
    <select id="selectListCountByParam" resultType="java.lang.Integer"
            parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO">
        select count(DISTINCT union_type)
        from union_logs where 1=1
        <if test="interfaceType != null and interfaceType !='' ">
            and interface_type=#{interfaceType}
        </if>
        <if test="activateTimeStr != null and activateTimeStr>0">
            and create_time>=#{activateTimeStr,jdbcType=INTEGER} and create_time-86400 &lt;=#{activateTimeStr,jdbcType=INTEGER}
        </if>
        <if test="unionType !=null and unionType !='' ">
            and union_type = #{unionType}
        </if>
    </select>
    <select id="selectListByParam" resultMap="ActivateMap"
            parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO">
152
        select union_type,union_name,count(*) as total_count, count(idfa) as idfa_count,count(imei) as imei_count
linlong authored
153 154 155 156 157
        from union_logs
        where 1=1
        <if test="interfaceType != null and interfaceType !='' ">
            and interface_type=#{interfaceType}
        </if>
linlong authored
158 159 160 161 162
        <if test="activateTimeBegin != null and activateTimeBegin>0">
            and create_time>=#{activateTimeBegin,jdbcType=INTEGER}
        </if>
        <if test="activateTimeEnd != null and activateTimeEnd>0">
             and create_time &lt;=#{activateTimeEnd,jdbcType=INTEGER}
linlong authored
163 164 165 166
        </if>
        <if test="unionType !=null and unionType !='' ">
            and union_type = #{unionType}
        </if>
linlong authored
167
        group by union_type
168
        order by count(*) desc,count(idfa) desc
linlong authored
169
    </select>
linlong authored
170
    <select id="matchIdfa" resultMap="BaseResultMap">
linlong authored
171
        select
linlong authored
172
        <include refid="Base_Column_List"/>
linlong authored
173 174 175 176 177 178 179 180 181
        from union_logs
        where
        <if test="isIdfa==1">
            idfa
        </if>
        <if test="isIdfa==0">
            imei
        </if>
         in
linlong authored
182 183 184 185
        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
linlong authored
186 187 188 189
    <select id="queryByDeviceId" resultMap="BaseResultMap" parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO">
        select
        <include refid="Base_Column_List"/>
        from union_logs where 1=1
linlong authored
190
        <if test="idfa!=null and idfa!='' ">
linlong authored
191 192
            and idfa = #{idfa}
        </if>
linlong authored
193
        <if test="imei!=null and imei!='' ">
linlong authored
194 195 196 197
            and imei = #{imei}
        </if>
        limit 1
    </select>
linlong authored
198
    <select id="selectListByHour" resultMap="BaseResultMap"
linlong authored
199
            parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO">
linlong authored
200
        select  <include refid="Base_Column_List"/>
linlong authored
201 202 203 204 205 206 207 208 209
        from union_logs
        where union_type = #{unionType}
        <if test="activateHourBegin != null and activateHourBegin>0">
            and create_time>=#{activateHourBegin,jdbcType=INTEGER}
        </if>
        <if test="activateHourEnd != null and activateHourEnd>0">
            and create_time &lt;=#{activateHourEnd,jdbcType=INTEGER}
        </if>
    </select>
linlong authored
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228

    <select id="selectYHListByParam" resultMap="YHActivateMap">
        select union_type,union_name,count(idfa) as idfa_count,count(imei) as imei_count
        from union_logs
        where 1=1
        <if test="list!=null and list.size()>0">
            and  union_type IN
            <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="yhActivateDeviceIdReqBO.activateTimeBegin != null and yhActivateDeviceIdReqBO.activateTimeBegin>0">
            and create_time>=#{yhActivateDeviceIdReqBO.activateTimeBegin,jdbcType=INTEGER}
        </if>
        <if test="yhActivateDeviceIdReqBO.activateTimeEnd != null and yhActivateDeviceIdReqBO.activateTimeEnd>0">
            and create_time &lt;=#{yhActivateDeviceIdReqBO.activateTimeEnd,jdbcType=INTEGER}
        </if>
        group by union_type
    </select>
zhengwen.ge authored
229 230 231 232 233

    <select id="selectByBeginAndEnd" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from union_logs where create_time &lt;=#{endTime} and create_time &gt;= #{beginTime}
    </select>
zhengwen.ge authored
234
</mapper>