| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?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.LiveWatchUserMapper">
- <resultMap type="LiveWatchUser" id="LiveWatchUserResult">
- <result property="id" column="id" />
- <result property="liveId" column="live_id" />
- <result property="userId" column="user_id" />
- <result property="msgStatus" column="msg_status" />
- <result property="online" column="online" />
- <result property="createTime" column="create_time" />
- <result property="createBy" column="create_by" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- <result property="onlineSeconds" column="online_seconds" />
- </resultMap>
- <sql id="selectLiveWatchUserVo">
- select id, live_id,user_id, msg_status, online, create_time, create_by, update_by, update_time, remark,online_seconds from live_watch_user
- </sql>
- <select id="selectLiveWatchUserList" parameterType="LiveWatchUser" resultMap="LiveWatchUserResult">
- <include refid="selectLiveWatchUserVo"/>
- <where>
- <if test="liveId != null "> and live_id = #{liveId}</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="msgStatus != null "> and msg_status = #{msgStatus}</if>
- <if test="online != null "> and online = #{online}</if>
- <if test="onlineSeconds != null "> and online_seconds = #{onlineSeconds}</if>
- </where>
- </select>
- <select id="selectLiveWatchUserById" parameterType="Long" resultMap="LiveWatchUserResult">
- <include refid="selectLiveWatchUserVo"/>
- where id = #{id}
- </select>
- <select id="selectWatchUserListByLiveId" resultType="com.fs.live.vo.LiveWatchUserVO">
- select
- lwu.live_id liveId,
- lwu.user_id userId,
- lwu.msg_status msgStatus,
- lwu.online online,
- fu.nick_name nickName,
- fu.avatar avatar
- from live_watch_user lwu
- left join fs_user fu on lwu.user_id = fu.user_id
- where lwu.live_id = #{params.liveId}
- <if test="params.msgStatus != null "> and msg_status = #{params.msgStatus}</if>
- <if test="params.online != null "> and online = #{params.online}</if>
- <if test="params.userName != null and params.userName != ''"> and fs.nickname like concat('%',#{params.userName},'%')</if>
- order by lwu.create_time desc
- </select>
- <select id="selectWatchUserListAllByLiveId" resultType="com.fs.live.vo.LiveWatchUserVO">
- select
- lwu.live_id liveId,
- lwu.user_id userId,
- lwu.msg_status msgStatus,
- lwu.online online,
- fu.nick_name nickName,
- fu.avatar avatar
- from live_watch_user lwu
- left join fs_user fu on lwu.user_id = fu.user_id
- where lwu.live_id = #{params.liveId}
- <if test="params.userName != null and params.userName != ''"> and fs.nickname like concat('%',#{params.userName},'%')</if>
- order by lwu.create_time desc
- </select>
- <select id="selectLiveWatchUserByIdAndCompanyIdAndCompanyUserId" resultMap="LiveWatchUserResult">
- <include refid="selectLiveWatchUserVo"/>
- where id = #{id} and company_id = #{companyId} and company_user_id = #{companyUserId}
- </select>
- <select id="selectWatchUserByLiveIdAndUserId" resultType="com.fs.live.vo.LiveWatchUserVO">
- select
- lwu.live_id liveId,
- lwu.user_id userId,
- lwu.msg_status msgStatus,
- lwu.online online,
- fu.nickname nickName,
- fu.avatar avatar
- from live_watch_user lwu
- left join fs_user fu on lwu.user_id = fu.user_id
- where lwu.live_id = #{liveId} and lwu.user_id = #{userId}
- </select>
- <select id="selectOnlineUserList" parameterType="LiveWatchUser" resultType="com.fs.live.vo.LiveWatchUserVO">
- select lwu.*,
- fu.nickname nickName,
- fu.avatar avatar
- from live_watch_user lwu
- left join fs_user fu on lwu.user_id = fu.user_id
- <where>
- <if test="liveId != null "> and live_id = #{liveId}</if>
- <if test="online != null "> and online = #{online}</if>
- </where>
- </select>
- <insert id="insertLiveWatchUser" parameterType="LiveWatchUser" useGeneratedKeys="true" keyProperty="id">
- insert into live_watch_user
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="liveId != null">live_id,</if>
- <if test="userId != null">user_id,</if>
- <if test="msgStatus != null">msg_status,</if>
- <if test="online != null">online,</if>
- <if test="createTime != null">create_time,</if>
- <if test="createBy != null">create_by,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- <if test="onlineSeconds != null">online_seconds,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="liveId != null">#{liveId},</if>
- <if test="userId != null">#{userId},</if>
- <if test="msgStatus != null">#{msgStatus},</if>
- <if test="online != null">#{online},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="onlineSeconds != null">#{onlineSeconds},</if>
- </trim>
- </insert>
- <update id="updateLiveWatchUser" parameterType="LiveWatchUser">
- update live_watch_user
- <trim prefix="SET" suffixOverrides=",">
- <if test="liveId != null">live_id = #{liveId},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="msgStatus != null">msg_status = #{msgStatus},</if>
- <if test="online != null">online = #{online},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="onlineSeconds != null">online_seconds = #{onlineSeconds},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteLiveWatchUserById" parameterType="Long">
- delete from live_watch_user where id = #{id}
- </delete>
- <delete id="deleteLiveWatchUserByIds" parameterType="String">
- delete from live_watch_user where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="checkOnlineNoRewardUser" resultType="com.fs.live.domain.LiveWatchUser">
- SELECT lwu.*
- FROM live_watch_user lwu
- WHERE lwu.live_id = #{liveId}
- AND lwu.online = 0
- AND NOT EXISTS (
- SELECT 1
- FROM live_reward_record lrr
- WHERE lrr.user_id = lwu.user_id
- AND lrr.live_id = lwu.live_id
- and lrr.source_type = 3
- AND DATE(lrr.create_time) = DATE(#{now})
- )
- </select>
- </mapper>
|