| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <?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.live.mapper.LiveWatchLogMapper">
- <resultMap type="LiveWatchLog" id="LiveWatchLogResult">
- <result property="logId" column="log_id" />
- <result property="userId" column="user_id" />
- <result property="liveId" column="live_id" />
- <result property="logType" column="log_type" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="externalContactId" column="external_contact_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="companyId" column="company_id" />
- <result property="finishTime" column="finish_time" />
- <result property="createBy" column="create_by" />
- <result property="sopCreateTime" column="sop_create_time" />
- <result property="sendAppId" column="send_app_id" />
- <result property="logSource" column="log_source" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="watchType" column="watch_type" />
- <result property="corpId" column="corp_id" />
- <result property="liveBuy" column="live_buy" />
- <result property="replayBuy" column="replay_buy" />
- </resultMap>
- <sql id="selectLiveWatchLogVo">
- select log_id, user_id, live_id, log_type, create_time, update_time, external_contact_id, company_user_id, company_id, finish_time, create_by, sop_create_time,live_buy,replay_buy,
- send_app_id, log_source, qw_user_id,watch_type,corp_id from live_watch_log
- </sql>
- <select id="selectLiveWatchLogList" parameterType="LiveWatchLog" resultMap="LiveWatchLogResult">
- <include refid="selectLiveWatchLogVo"/>
- <where>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="liveId != null "> and live_id = #{liveId}</if>
- <if test="logType != null "> and log_type = #{logType}</if>
- <if test="externalContactId != null "> and external_contact_id = #{externalContactId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="finishTime != null "> and finish_time = #{finishTime}</if>
- <if test="sopCreateTime != null "> and sop_create_time = #{sopCreateTime}</if>
- <if test="sendAppId != null and sendAppId != ''"> and send_app_id = #{sendAppId}</if>
- <if test="logSource != null "> and log_source = #{logSource}</if>
- <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
- <if test="watchType != null">and watch_type = #{watchType} </if>
- <if test="corpId != null">and corp_id = #{corpId} </if>
- <if test="liveBuy != null">and live_buy = #{liveBuy} </if>
- <if test="replayBuy != null">and replay_buy = #{replayBuy} </if>
- </where>
- </select>
- <select id="selectLiveWatchLogByLogId" parameterType="Long" resultMap="LiveWatchLogResult">
- <include refid="selectLiveWatchLogVo"/>
- where log_id = #{logId}
- </select>
- <insert id="insertLiveWatchLog" parameterType="LiveWatchLog" useGeneratedKeys="true" keyProperty="logId">
- insert into live_watch_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">user_id,</if>
- <if test="liveId != null">live_id,</if>
- <if test="logType != null">log_type,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="externalContactId != null">external_contact_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="finishTime != null">finish_time,</if>
- <if test="createBy != null">create_by,</if>
- <if test="sopCreateTime != null">sop_create_time,</if>
- <if test="sendAppId != null">send_app_id,</if>
- <if test="logSource != null">log_source,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="watchType != null">watch_type,</if>
- <if test="corpId != null">corp_id,</if>
- <if test="liveBuy != null">live_buy,</if>
- <if test="replayBuy != null">replay_buy,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">#{userId},</if>
- <if test="liveId != null">#{liveId},</if>
- <if test="logType != null">#{logType},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="externalContactId != null">#{externalContactId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="finishTime != null">#{finishTime},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="sopCreateTime != null">#{sopCreateTime},</if>
- <if test="sendAppId != null">#{sendAppId},</if>
- <if test="logSource != null">#{logSource},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="watchType != null">#{watchType},</if>
- <if test="corpId != null">#{corpId},</if>
- <if test="liveBuy != null">#{liveBuy},</if>
- <if test="replayBuy != null">#{replayBuy},</if>
- </trim>
- </insert>
- <update id="updateLiveWatchLog" parameterType="LiveWatchLog">
- update live_watch_log
- <trim prefix="SET" suffixOverrides=",">
- <if test="userId != null">user_id = #{userId},</if>
- <if test="liveId != null">live_id = #{liveId},</if>
- <if test="logType != null">log_type = #{logType},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="externalContactId != null">external_contact_id = #{externalContactId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="finishTime != null">finish_time = #{finishTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="sopCreateTime != null">sop_create_time = #{sopCreateTime},</if>
- <if test="sendAppId != null">send_app_id = #{sendAppId},</if>
- <if test="logSource != null">log_source = #{logSource},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="watchType != null">watch_type = #{watchType},</if>
- <if test="corpId != null">corp_id = #{corpId},</if>
- <if test="liveBuy != null">live_buy = #{liveBuy},</if>
- <if test="replayBuy != null">replay_buy = #{replayBuy},</if>
- </trim>
- where log_id = #{logId}
- </update>
- <delete id="deleteLiveWatchLogByLogId" parameterType="Long">
- delete from live_watch_log where log_id = #{logId}
- </delete>
- <delete id="deleteLiveWatchLogByLogIds" parameterType="String">
- delete from live_watch_log where log_id in
- <foreach item="logId" collection="array" open="(" separator="," close=")">
- #{logId}
- </foreach>
- </delete>
- <insert id="insertLiveWatchLogBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="logId">
- INSERT INTO live_watch_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="liveWatchLogs != null and liveWatchLogs.size() > 0">
- <foreach collection="liveWatchLogs" item="item" index="index" open="" close="" separator="">
- <if test="index == 0">
- <if test="item.userId != null">user_id,</if>
- <if test="item.liveId != null">live_id,</if>
- <if test="item.logType != null">log_type,</if>
- <if test="item.createTime != null">create_time,</if>
- <if test="item.updateTime != null">update_time,</if>
- <if test="item.externalContactId != null">external_contact_id,</if>
- <if test="item.companyUserId != null">company_user_id,</if>
- <if test="item.companyId != null">company_id,</if>
- <if test="item.finishTime != null">finish_time,</if>
- <if test="item.createBy != null">create_by,</if>
- <if test="item.sopCreateTime != null">sop_create_time,</if>
- <if test="item.sendAppId != null">send_app_id,</if>
- <if test="item.logSource != null">log_source,</if>
- <if test="item.qwUserId != null">qw_user_id,</if>
- <if test="item.watchType != null">watch_type,</if>
- <if test="item.corpId != null">corp_id,</if>
- <if test="item.liveBuy != null">live_buy,</if>
- <if test="item.replayBuy != null">replay_buy,</if>
- </if>
- </foreach>
- </if>
- </trim>
- <trim prefix="VALUES">
- <foreach collection="liveWatchLogs" item="item" separator=",">
- (<trim suffixOverrides=",">
- <if test="item.userId != null">#{item.userId},</if>
- <if test="item.liveId != null">#{item.liveId},</if>
- <if test="item.logType != null">#{item.logType},</if>
- <if test="item.createTime != null">#{item.createTime},</if>
- <if test="item.updateTime != null">#{item.updateTime},</if>
- <if test="item.externalContactId != null">#{item.externalContactId},</if>
- <if test="item.companyUserId != null">#{item.companyUserId},</if>
- <if test="item.companyId != null">#{item.companyId},</if>
- <if test="item.finishTime != null">#{item.finishTime},</if>
- <if test="item.createBy != null">#{item.createBy},</if>
- <if test="item.sopCreateTime != null">#{item.sopCreateTime},</if>
- <if test="item.sendAppId != null">#{item.sendAppId},</if>
- <if test="item.logSource != null">#{item.logSource},</if>
- <if test="item.qwUserId != null">#{item.qwUserId},</if>
- <if test="item.watchType != null">#{item.watchType},</if>
- <if test="item.corpId != null">#{item.corpId},</if>
- <if test="item.liveBuy != null">#{item.liveBuy},</if>
- <if test="item.replayBuy != null">#{item.replayBuy},</if>
- </trim>)
- </foreach>
- </trim>
- </insert>
- <update id="updateLiveWatchLogCondition" parameterType="com.fs.live.domain.LiveWatchLog" >
- update live_watch_log
- set update_time = NOW(),
- sop_create_time = NOW(),
- send_app_id = #{liveWatchLog.sendAppId},
- log_source = #{liveWatchLog.logSource}
- where external_contact_id = #{liveWatchLog.externalContactId}
- and live_id = #{liveWatchLog.liveId}
- and qw_user_id = #{liveWatchLog.qwUserId}
- </update>
- <select id="selectOneLogByLiveIdAndQwUserIdAndExternalId" resultType="com.fs.live.domain.LiveWatchLog">
- select * from live_watch_log where live_id = #{liveId} and qw_user_id = #{qwUserId} and external_contact_id = #{externalContactId}
- </select>
- <!-- todo lmx-->
- <select id="selectLiveWatchLogByLiveId" resultType="com.fs.live.domain.LiveWatchLog">
- select * from live_watch_log where live_id = #{liveId}
- </select>
- <select id="selectLiveWatchLogListInfo" parameterType="LiveWatchLog" resultType="com.fs.live.vo.LiveWatchLogListVO">
- select
- t2.nick_name as userName,
- t2.avatar as userAvatar,
- t3.live_name,
- t4.name as qwExternalName,
- t4.avatar as qwExternalAvatar,
- t5.nick_name as companyUserName,
- t6.qw_user_name,
- t1.*
- from live_watch_log t1
- left join fs_user t2 on t1.user_id = t2.user_id
- left join live t3 on t3.live_id = t1.live_id
- left join qw_external_contact t4 on t4.id = t1.external_contact_id
- left join company_user t5 on t5.user_id = t1.company_user_id
- left join qw_user t6 on t6.id = t1.qw_user_id
- <where>
- <if test="userId != null "> and t1.user_id = #{userId}</if>
- <if test="liveId != null "> and t1.live_id = #{liveId}</if>
- <if test="logType != null "> and t1.log_type = #{logType}</if>
- <if test="externalContactId != null "> and t1.external_contact_id = #{externalContactId}</if>
- <if test="companyId != null "> and t1.company_id = #{companyId}</if>
- <if test="companyUserId != null "> and t1.company_user_id = #{companyUserId}</if>
- <if test="finishTime != null "> and t1.finish_time = #{finishTime}</if>
- <if test="sopCreateTime != null "> and t1.sop_create_time = #{sopCreateTime}</if>
- <if test="sendAppId != null and sendAppId != ''"> and t1.send_app_id = #{sendAppId}</if>
- <if test="logSource != null "> and t1.log_source = #{logSource}</if>
- <if test="qwUserId != null and qwUserId != ''"> and t1.qw_user_id = #{qwUserId}</if>
- <if test="watchType != null">and t1.watch_type = #{watchType} </if>
- <if test="corpId != null">and t1.corp_id = #{corpId} </if>
- <if test="liveBuy != null">and t1.live_buy = #{liveBuy} </if>
- <if test="replayBuy != null">and t1.replay_buy = #{replayBuy} </if>
- </where>
- </select>
- <!-- 批量更新直播看课记录 -->
- <update id="batchUpdateLiveWatchLog" parameterType="java.util.List">
- UPDATE live_watch_log
- <set>
- <if test="list != null and list.size() > 0 and list[0].logType != null">
- log_type = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.logType}
- </foreach>
- ELSE log_type
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].updateTime != null">
- update_time = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.updateTime}
- </foreach>
- ELSE update_time
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].finishTime != null">
- finish_time = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.finishTime}
- </foreach>
- ELSE finish_time
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].sopCreateTime != null">
- sop_create_time = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.sopCreateTime}
- </foreach>
- ELSE sop_create_time
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].sendAppId != null">
- send_app_id = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.sendAppId}
- </foreach>
- ELSE send_app_id
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].logSource != null">
- log_source = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.logSource}
- </foreach>
- ELSE log_source
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].watchType != null">
- watch_type = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.watchType}
- </foreach>
- ELSE watch_type
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].corpId != null">
- corp_id = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.corpId}
- </foreach>
- ELSE corp_id
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].liveBuy != null">
- live_buy = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.liveBuy}
- </foreach>
- ELSE live_buy
- END,
- </if>
- <if test="list != null and list.size() > 0 and list[0].replayBuy != null">
- replay_buy = CASE log_id
- <foreach collection="list" item="item">
- WHEN #{item.logId} THEN #{item.replayBuy}
- </foreach>
- ELSE replay_buy
- END
- </if>
- </set>
- WHERE log_id IN
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item.logId}
- </foreach>
- </update>
- </mapper>
|