SocialUserDetailMapper.xml
2.15 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
<?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.yoho.search.dal.SocialUserDetailMapper" >
<resultMap id="followerMap" type="com.yoho.search.dal.model.UserFollower" >
<result column="s_uid" property="s_uid" jdbcType="INTEGER" />
<result column="s_followers_number" property="s_followers_number" jdbcType="INTEGER" />
<result column="s_talent" property="s_talent" jdbcType="INTEGER" />
</resultMap>
<resultMap id="followingMap" type="com.yoho.search.dal.model.UserFollowing" >
<result column="s_uid" property="s_uid" jdbcType="INTEGER" />
<result column="t_uid" property="t_uid" jdbcType="INTEGER" />
<result column="t_followers_number" property="t_followers_number" jdbcType="INTEGER" />
<result column="t_follow_back" property="t_follow_back" jdbcType="INTEGER" />
</resultMap>
<select id="selectUserFollower" resultMap="followerMap" timeout="20000">
select s.uid_attention as s_uid,
count(distinct s.uid) as s_followers_number,
(
select 1
from tbl_shoes_doctor_talent tal
where tal.uid=s.uid_attention
and tal.is_certification=1
) as s_talent
from tbl_attention_user s
where 1=1
<if test="uids!=null">
and s.uid_attention
<foreach collection="uids" item="uid" open="in(" separator="," close=")">
#{uid}
</foreach>
</if>
group by s.uid_attention
</select>
<select id="selectUserFollowing" resultMap="followingMap" timeout="20000">
select distinct s.uid as s_uid,s.uid_attention as t_uid,
(
select count(distinct t1.uid)
from tbl_attention_user t1
where t1.uid_attention=s.uid_attention
) as t_followers_number,
(
select 1
from tbl_attention_user t2
where t2.uid=s.uid_attention
and t2.uid_attention=s.uid
) as t_follow_back
from tbl_attention_user s
where 1=1
<if test="uids!=null">
and s.uid
<foreach collection="uids" item="uid" open="in(" separator="," close=")">
#{uid}
</foreach>
</if>
</select>
</mapper>