|
@@ -0,0 +1,133 @@
|
|
|
+<?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.fs.gtPush.mapper.PushLogMapper">
|
|
|
+
|
|
|
+ <resultMap type="UniPushLog" id="PushLogResult">
|
|
|
+ <result property="id" column="id" />
|
|
|
+ <result property="jpushId" column="jpush_id" />
|
|
|
+ <result property="type" column="type" />
|
|
|
+ <result property="desType" column="des_type" />
|
|
|
+ <result property="userId" column="user_id" />
|
|
|
+ <result property="businessId" column="business_id" />
|
|
|
+ <result property="pushMsg" column="push_msg" />
|
|
|
+ <result property="pushRes" column="push_res" />
|
|
|
+ <result property="returnMsg" column="return_msg" />
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
+ <result property="isRead" column="is_read" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectPushLogVo">
|
|
|
+ select id, jpush_id,`type`,des_type,user_id,business_id, push_msg, push_res, return_msg, create_time,
|
|
|
+ update_time,is_read from uni_push_log
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectPushLogList" parameterType="com.fs.gtPush.param.UniPushLogParam" resultMap="PushLogResult">
|
|
|
+ <include refid="selectPushLogVo"/>
|
|
|
+ <where>
|
|
|
+ <if test="jpushId != null and jpushId != ''"> and jpush_id = #{jpushId}</if>
|
|
|
+ <if test="type != null"> and CAST(`type` AS CHAR) = #{type}</if>
|
|
|
+ <if test="desType != null"> and des_type = #{desType}</if>
|
|
|
+ <if test="userId != null "> and user_id = #{userId}</if>
|
|
|
+ <if test="businessId != null"> and business_id = #{businessId}</if>
|
|
|
+ <if test="pushMsg != null and pushMsg != ''"> and push_msg = #{pushMsg}</if>
|
|
|
+ <if test="pushRes != null and pushRes !='' "> and push_res = #{pushRes}</if>
|
|
|
+ <if test="returnMsg != null and returnMsg != ''"> and return_msg = #{returnMsg}</if>
|
|
|
+ <if test="isRead != null"> and is_read = #{isRead}</if>
|
|
|
+ </where>
|
|
|
+ order by create_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectPushLogById" parameterType="String" resultMap="PushLogResult">
|
|
|
+ <include refid="selectPushLogVo"/>
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+ <select id="getLast" resultType="com.fs.gtPush.domain.UniPushLog">
|
|
|
+ <include refid="selectPushLogVo"/>
|
|
|
+ where user_id = #{userId} and push_res = 1
|
|
|
+ order by create_time desc limit 1
|
|
|
+ </select>
|
|
|
+ <select id="getNumByIsRead" resultType="java.lang.Integer">
|
|
|
+ SELECT count(1) FROM uni_push_log WHERE user_id = #{userId} and is_read = 0 and push_res = 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertPushLog" parameterType="UniPushLog" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ insert into uni_push_log
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="jpushId != null">jpush_id,</if>
|
|
|
+ <if test="type != null">`type`,</if>
|
|
|
+ <if test="desType != null">`des_type`,</if>
|
|
|
+ <if test="userId != null "> user_id,</if>
|
|
|
+ <if test="businessId != null">business_id,</if>
|
|
|
+ <if test="pushMsg != null">push_msg,</if>
|
|
|
+ <if test="pushRes != null and pushRes !=''">push_res,</if>
|
|
|
+ <if test="returnMsg != null">return_msg,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ <if test="updateTime != null">update_time,</if>
|
|
|
+ <if test="isRead != null">is_read,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="jpushId != null">#{jpushId},</if>
|
|
|
+ <if test="type != null">#{type},</if>
|
|
|
+ <if test="desType != null">#{desType},</if>
|
|
|
+ <if test="userId != null ">#{userId},</if>
|
|
|
+ <if test="businessId != null">#{businessId},</if>
|
|
|
+ <if test="pushMsg != null">#{pushMsg},</if>
|
|
|
+ <if test="pushRes != null and pushRes !=''">#{pushRes},</if>
|
|
|
+ <if test="returnMsg != null">#{returnMsg},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ <if test="updateTime != null">#{updateTime},</if>
|
|
|
+ <if test="isRead != null">#{isRead},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+ <insert id="insertLogBatch">
|
|
|
+ INSERT INTO uni_push_log (jpush_id, push_msg, `type`, des_type, user_id, business_id, create_time,push_res,return_msg)
|
|
|
+ VALUES
|
|
|
+ <foreach collection="uniPushLogs" item="log" separator=",">
|
|
|
+ (#{log.jpushId}, #{log.pushMsg}, #{log.type}, #{log.desType}, #{log.userId}, #{log.businessId}, #{log.createTime},#{log.pushRes},#{log.returnMsg})
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updatePushLog" parameterType="UniPushLog">
|
|
|
+ update uni_push_log
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="jpushId != null">jpush_id = #{jpushId},</if>
|
|
|
+ <if test="type != null">`type` = #{type},</if>
|
|
|
+ <if test="desType != null">`des_type` = #{desType},</if>
|
|
|
+ <if test="userId != null ">user_id = #{userId},</if>
|
|
|
+ <if test="businessId != null"> business_id = #{businessId},</if>
|
|
|
+ <if test="pushMsg != null">push_msg = #{pushMsg},</if>
|
|
|
+ <if test="pushRes != null and pushRes !=''">push_res = #{pushRes},</if>
|
|
|
+ <if test="returnMsg != null">return_msg = #{returnMsg},</if>
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="isRead != null">is_read = #{isRead},</if>
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="setIsRead">
|
|
|
+ update uni_push_log set
|
|
|
+ is_read = 1
|
|
|
+ where user_id = #{userId}
|
|
|
+ <if test="logIds != null and logIds.size > 0">
|
|
|
+ and id in
|
|
|
+ <foreach collection="logIds" item="logId" open="(" close=")" separator=",">
|
|
|
+ #{logId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deletePushLogById" parameterType="String">
|
|
|
+ delete from uni_push_log where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deletePushLogByIds" parameterType="String">
|
|
|
+ delete from uni_push_log where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+</mapper>
|