UserGiftDetailMapper.xml
6.83 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
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
152
153
154
<?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.bjivt.entity.vo.UserGiftDetail">
<resultMap id="BaseResultMap" type="com.bjivt.entity.showtime.GiftDetail">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="from_user_id" jdbcType="INTEGER" property="fromUserId" />
<result column="to_user_id" jdbcType="INTEGER" property="toUserId" />
<result column="live_id" jdbcType="INTEGER" property="liveId" />
<result column="gift_id" jdbcType="INTEGER" property="giftId" />
<result column="count" jdbcType="INTEGER" property="count" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<resultMap id="UserDetailMap" type="com.bjivt.entity.vo.UserGiftDetail">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="from_user_id" jdbcType="INTEGER" property="fromUserId" />
<result column="to_user_id" jdbcType="INTEGER" property="toUserId" />
<result column="live_id" jdbcType="INTEGER" property="liveId" />
<result column="gift_id" jdbcType="INTEGER" property="giftId" />
<result column="count" jdbcType="INTEGER" property="count" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="name" jdbcType="VARCHAR" property="fromUserName" />
<result column="name" jdbcType="VARCHAR" property="toUserName" />
<result column="name" jdbcType="VARCHAR" property="liveName" />
<result column="name" jdbcType="VARCHAR" property="giftName" />
</resultMap>
<sql id="Base_Column_List">
id, from_user_id, to_user_id, live_id, gift_id, count, create_time
</sql>
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tbl_user_gift_detail
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
delete from tbl_user_gift_detail
where id = #{id,jdbcType=INTEGER}
</delete>
<select id="getCountBy" resultType="java.lang.Integer" parameterType="com.bjivt.entity.vo.UserGiftDetail">
SELECT
count(1)
FROM
tbl_user_gift_detail
<trim prefix="where" prefixOverrides="and|or">
<if test="liveId != null and liveId != ''" >
and tbl_user_gift_detail.live_id = #{liveId}
</if>
</trim>
</select>
<!-- 获取用户得到礼物的列表信息 -->
<select id="findListByMap" resultMap="UserDetailMap" parameterType="java.util.Map">
select a.*,
(select name from tbl_user_list where id=a.from_user_id) fromUserName,
(select name from tbl_user_list where id=a.to_user_id) toUserName,
(select name from tbl_live_list where id=a.live_id) liveName,
(select name from tbl_gift_list where id=a.gift_id) giftName
from tbl_user_gift_detail a
<trim prefix="where" prefixOverrides="and|or">
<if test="UserGiftDetail.liveId != null and UserGiftDetail.liveId != ''" >
and a.live_id = #{UserGiftDetail.liveId}
</if>
<if test="UserGiftDetail.fromUserId!= null and UserGiftDetail.fromUserId!= ''" >
and a.from_user_id = #{UserGiftDetail.fromUserId}
</if>
<if test="UserGiftDetail.toUserId!= null and UserGiftDetail.toUserId!= ''" >
and a.to_user_id = #{UserGiftDetail.toUserId}
</if>
<if test="UserGiftDetail.giftId!= null and UserGiftDetail.giftId!= ''" >
and a.gift_id = #{UserGiftDetail.giftId}
</if>
</trim>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'createDate asc'">
order by a.create_time asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'createDate desc'">
order by a.create_time desc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'count asc'">
order by a.count asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'count desc'">
order by a.count desc
</if>
<if test="page != null and page !=''">
<if test="page.from != null and page.size != null">
limit #{page.from},#{page.size}
</if>
</if>
</select>
<!-- 获取用户得到礼物的列表信息 -->
<select id="findUserGiftListByMap" resultMap="UserDetailMap" parameterType="java.util.Map">
select a.*,
b.name fromUserName,
e.name toUserName,
c.name liveName,
d.name giftName
from tbl_user_gift_detail a
left join tbl_user_list b on b.id=a.from_user_id
left join tbl_user_list e on e.id=a.to_user_id
left join tbl_live_list c on c.id=a.live_id
left join tbl_gift_list d on d.id=a.gift_id
<trim prefix="where" prefixOverrides="and|or">
<if test="UserGiftDetail.liveName != null and UserGiftDetail.liveName != ''" >
and c.name like '%${UserGiftDetail.liveName}%'
</if>
<if test="UserGiftDetail.fromUserName!= null and UserGiftDetail.fromUserName!= ''" >
and b.name = #{UserGiftDetail.fromUserName}
</if>
<if test="UserGiftDetail.toUserName!= null and UserGiftDetail.toUserName!= ''" >
and e.name = #{UserGiftDetail.toUserName}
</if>
<if test="UserGiftDetail.giftName!= null and UserGiftDetail.giftName!= ''" >
and d.name = #{UserGiftDetail.giftName}
</if>
</trim>
order by a.create_time
<if test="page != null and page !=''">
<if test="page.from != null and page.size != null">
limit #{page.from},#{page.size}
</if>
</if>
</select>
<select id="findListByTime" resultMap="UserDetailMap" parameterType="java.util.Map">
select a.*, a.count(count),
(select name from tbl_user_list where id=a.from_user_id) fromUserName,
(select name from tbl_user_list where id=a.to_user_id) toUserName,
from tbl_user_gift_detail a
<!--
select from_user_id, sum(numTotal), sum(moneyTotal) from tbl_user_gift_statistics where to_user_id=2 and
date between '2016-01-09' and '2016-11-09'
group by from_user_id
-->
<trim prefix="where" prefixOverrides="and|or">
<if test="UserGiftDetail.fromUserId!= null and UserGiftDetail.fromUserId!= ''" >
and a.from_user_id = #{GiftList.fromUserId}
</if>
<if test="UserGiftDetail.toUserId!= null and UserGiftDetail.toUserId!= ''" >
and a.to_user_id = #{UserGiftDetail.toUserId}
</if>
</trim>
add a.create_time between #{s_startTime} and #{s_endTime}
order by a.create_time
<if test="page != null and page !=''">
<if test="page.from != null and page.size != null">
limit #{page.from},#{page.size}
</if>
</if>
</select>
</mapper>