LiveMapper.xml
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?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="LiveMapper">
<resultMap id="LiveRobotMap" type="com.bjivt.job.robot.entity.Live">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="record_addr" jdbcType="VARCHAR" property="recordAddr" />
<result column="chatroom_addr" jdbcType="VARCHAR" property="chatroomAddr" />
<result column="video_addr" jdbcType="VARCHAR" property="videoAddr" />
<result column="audience_total_num" jdbcType="INTEGER" property="audienceTotalNum" />
<result column="audience_now_num" jdbcType="INTEGER" property="audienceNowNum" />
<result column="heartbeat" jdbcType="BIGINT" property="heartbeat" />
<result column="like_num" jdbcType="INTEGER" property="likeNum" />
<result column="tag" jdbcType="VARCHAR" property="tag" />
<result column="is_allow_location" jdbcType="SMALLINT" property="isAllowLocation" />
<result column="type" jdbcType="SMALLINT" property="type" />
<result column="location" jdbcType="VARCHAR" property="location" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="recommend" jdbcType="INTEGER" property="recommend" />
<result column="active" jdbcType="SMALLINT" property="active" />
<result column="is_robot_use" jdbcType="INTEGER" property="isRobotUse" />
</resultMap>
<sql id="Live_Column_List">
id, name, user_id, record_addr, chatroom_addr, video_addr, audience_total_num, audience_now_num,
heartbeat, like_num, tag, is_allow_location, type, location, create_time, recommend,
active,is_robot_use
</sql>
<sql id="Base_Column_List">
id,
name,
userId,
avatar,
audience_total_num,
level,
chatroom_addr
</sql>
<select id="findListByMap" parameterType="java.util.Map" resultMap="LiveRobotMap">
select
<include refid="Live_Column_List" />
from tbl_live_list tl
where tl.type = #{type,jdbcType=INTEGER}
<if test="isrobotuse !=null and isrobotuse ==0">
and (tl.is_robot_use = #{isrobotuse,jdbcType=INTEGER} or tl.is_robot_use is null)
</if>
<if test="isrobotuse !=null and isrobotuse ==1">
and tl.is_robot_use = #{isrobotuse,jdbcType=INTEGER}
</if>
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(tl.create_time,'%Y-%m-%d %T') > str_to_date(#{startTime},'%Y-%m-%d %T') ]]>
</if>
order by tl.id limit 0,10
</select>
<update id="updateByIdSelective" parameterType="com.bjivt.job.robot.entity.Live">
update tbl_live_list
<set>
<if test="audienceTotalNum != null">
audience_total_num =audience_total_num+ #{audienceTotalNum,jdbcType=INTEGER},
audience_now_num =audience_now_num+ 1,
</if>
<if test="isRobotUse != null">
is_robot_use = #{isRobotUse,jdbcType=INTEGER}
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<!-- 查询出已经下线了的最近一条直播
<select id="findMaxTimeLive" resultType="com.bjivt.job.robot.entity.Live">
select
<include refid="Live_Column_List" />
from db_showtime_platform.tbl_live_list where type = 2
<![CDATA[ and create_time >= (select max(b.create_time) from db_showtime_platform.tbl_live_list b
where b.type=2 and b.is_robot_use=1 order by b.create_time desc) ]]>
</select>
-->
<select id="findMaxTimeLive" resultMap="LiveRobotMap">
select
<include refid="Live_Column_List" />
from tbl_live_list where type = 2
<![CDATA[ and create_time >= (select max(b.create_time) from tbl_live_list b
where b.type=2 and b.is_robot_use=1 order by b.create_time desc) ]]>
</select>
<select id="findSingleLive" resultMap="LiveRobotMap" >
select
<include refid="Live_Column_List" />
from tbl_live_list where id=#{id}
</select>
</mapper>